Searching for the Best Scripting Language
prostoalex writes "Folks at the Scriptometer conducted a practical survey of which scripting language is the best. While question like that is bound to generate flamewars between the usual Perl vs PHP, Python vs Perl, VBScript vs everything crowds, the Scriptometer survey is practical: if I have to write a script, I have to write it fast, it has to be small (less typing), it should allow me to either debug itself via a debugger or just verbose output mode. sh, Perl and Ruby won the competition, and with the difference of 1-2 points they were essentially tied for first place. Smalltalk, tcc, C# and Java are the last ones, with Java being completely unusable in scripting environment (part of that could be the fact that neither Java nor C# are scripting languages). See the 'Hello world' examples and the smallest code examples. Interesting that ICFP contests lately pronounced OCaml as the winner for rapid development."
Two languages missing are:
Io, which is an awesome, prototype-based scripting language that's super-easy to embed in C applications, and has an incredibly simple and consistent syntax.
REXX (Regina's just one implementation). REXX makes it incredibly easy to do system scripting, with powerful string-manipulation and I/O redirection.
Another one's ficl, which is basically an embedable Forth interpreter. (To all you young geeks out there - LEARN FORTH. You may never need to write a line of it ever in your life, but you'll learn a hell of a lot about how computers work. Trust me on this.)
...but it's being eaten...by some...Linux or something...
If you'd like to try scripting with Java, then I suggest looking into Mozilla Rhino, which allows one to script Java via JavaScript.
I'm a writer, a poet, a genius, I know it. I don't buy software, I grow it.
The flip side is that before becoming productive one has to get used to a whole new way of thinking about problems: immutable data, everything is a function evaluation, no sequential statements, no side-effects, rely on recursion as much as possible, especially tail-recursion. But ocaml isn't religious about it: it has imperative features, including for and while loops, sequential statements (essentially successive function calls with side-effects and null output), and so on. After a while, though, you find you hardly need any of that. Maybe it's just me, but the sort of work I do is well suited to the functional approach. Also, it has a rich set of data structures and is pretty much agnostic about them: you can use linked lists, hashes, mutable arrays or records, sets, whatever suits your purposes.
The other drawback is the libraries (modules) aren't as complete as the Perl and Python equivalents (though far ahead of most other competition). I imagine that will get cured with time.
One-letter class names? Is he nuts? That guy never had to maintain code I guess...
--- Hindsight is 20/20, but walking backwards is not the answer.
But it really does depend. I'd use Perl over Python for web development any day of the week (exception: Zope seems pretty cool, but I've not fooled with it enough. The 'everything is an object' metaphor is heaps cool though :)). Perl is faster to write and more expressive, Python is easier to read and - IMHO - often better structured.
... yeah ... the language itself seems a little hacked together - PHP5 fixes a lot of things, mind you so my opinion might change in a few months time after I've used it a little more.
PHP is great for hacking web stuff together, but
It worries me that a "feature complete" version of PHP instantly becomes a release candidate, rather than stewing in Beta for a while.
I don't see PHP listed. It's possition on the list is arguable, but it certainly belongs there.
And it made a good impression in one of my job applications, where the contact person knows it pretty well. It won't impress most people, sure, but (a) people who don't know Ruby will understand that means you could do Python, PHP or Perl; (b) people who do know Ruby will think better of you.
Are you adequate?
Most copies of PHP use the equivalent of mod_perl -- i.e. they cache the compilation. Use mod_perl, cache your compilations, and you will find performance is as good if not better than PHP.
Check out my site for some Ruby GUI stuff:
:-)
(the gotcha is it's mostly in Portuguese. So jump to the "Exemplos Meus" (My Examples) section. Or use babelfish: http://babelfish.altavista.com)
http://geocities.com/canalruby
Hey, web stuff is easy with Ruby as well. But I don't have such examples for you. You have to get a taste of Ruby to find about its web capabilities. I Know IOWA has an example:
http://enigo.com/projects/iowa/index.html
Further enlightening at:
http://www.ruby-doc.com
http://www.rubyforge.org
http://raa.ruby-lang.org
You know, once you get addicted, there is no going back!
It never was an acronym. See an explanation of Perl's name for an explanation of the backronym.
how to invest, a novice's guide
now lets say i put Ruby on my resume....how much respect will that get?
I just hired my replacement for a contract I was doing (I accepted another offer that was more in line with my field). One of the requirements was that the person hired would have to know Ruby because much of the code base was in Ruby. They hired someone from our local Ruby User's Group.
So to answer your question: for this particular job if you didn't have Ruby on your resume it wouldn't get a second look. If you had Ruby on your resume, but it became apparent in the interview that you didn't know Ruby... well, the interview was over.
Forth? No.
Learning forth will help you learn reverse polish notation, one specific trick for building high-performance interpreted languages and a very lightweight, easily extensible and embeddable scripting language.
It won't, though, teach you anything about computers work beyond the small amount you'll pick up by learning any new language. Including French.
If you want to learn how computers work there are far better things to play with. Assembly language, obviously, whether it be a synthetic assembly language such as DLX or a real architecture. x86 isn't the most enlightening assembly language to start with (6502 is excellent, MIPS or for a really nice architecture, Alpha) but it'll run on your PC.
Books. Patterson and Hennesey, Computer Organization and Design, The Hardware/Software Interface is pretty good for a programmers intro, but Hennesey and Patterson, Computer Architecture, A Quantative Approach will teach you a lot more, as will most texts with Superscalar in the title
Learn a hardware description language. Verilog is better, but VHDL is OK. Compilers and simulators are freely available for both.
Get an FPGA development kit. Compile yourself some hardware. You can put full CPUs on a fairly cheap FPGA development board.
Design your own CPU. It's possible for an individual or a small group to design a CPU and have it fabricated as a tinychip. I've seen individuals design a full, if tiny, CPU at mask level in a couple of months, and a small group put together a fairly decent gate level design in a few more. Commonly done as part of a college course, but an individual can have a tinychip fabricated for around $1000. Not cheap, but cheaper than some hobbies.
You can do full circuit level design and simulate it using either gate level or spice transistor level simulators and see just why addition or multiplication takes as long as it does.
As a general rule I've found that some of the best software engineers have some hardware design background, and a good understanding of computer architecture, so even if you never plan to do any hardware design, understanding how it all works is a good idea.
Of course, I've also found that a large fraction of good software engineers have also spent time working as theatre technicians, so who knows what the correlations are...
I can't speak for other people, but I know that my decisions about what language to use haven't been based just on what I already know and what community I want to join. For instance, my first language was Fortran. After that I learned Basic and assembly language (Mix, just on paper, and the language of a Japanese laboratory minicomputer the model of which I no longer remember. The only documentation I had was in Japanese, which at the time I was just learning. And people complain about man pages!). When I first learned C, it was in a situation in which I could also have used Fortran. I learned C because it looked like it would be a better language and I was interested in trying something new.
For scripting languages, for many years I used either a shell (sh or csh) or awk. When Perl came along, I read the book and twice made stabs at writing something non-trivial in it, but just couldn't bring myself to do it. I attribute this to my innate sense of good taste. Both the language itself (through non-orthogonality, excessive overloading, and lots of little tricks) and the Perl community (through typical practices and valuing short, cryptic code) encourage unreadable code. At the same time, I knew that AWK was not ideal for some kinds of programs (and I"ve written 500 line AWK scripts, and AWK scripts that write and then execute other AWK scripts) so when Python came along, I was interested. I still use AWK for some things since I know it well and the automatic parsing is handy, but more and more I am using Python. I find that Python encourages good programming practice and provides everything that I would get from Perl. I've also tried Tcl, to the extent of writing a moderately complex (1500 line) program. For some things it is fine, but I don't think it scales up as well as Python.
So I think that my choices, and probably other people's, aren't just a matter of inertia and general type of programming.
For me, by the way, in a lot of cases, Unicode support is important. That's a nice feature of Python. Ruby looks interesting, but as far as I can tell doesn't support Unicode. Anybody know if Ruby does, or will soon, support Unicode?
In a similar vain, I wrote up a scripting language comparison document, but focused more on features rather than particular languages. Comparison Link. I describe the various feature options, and then weigh the pro's and con's of each.
After years of debating language features, I generally conclude that a lot of it is subjective. No language will ever satisfy everybody.
Table-ized A.I.
mono-debugger
.*? = snag all chars in non-greedy mode
nothing in the OS was ever really meant to be scriptable
That's not really true. Most OS functions are available through COM interfaces. VBScript and JScript interact with any COM interface through the Windows Scripting Host, either in a windowed enviornment (wscript) or a command line environment (cscript). You can manage users, files, ACLs, the registry, network configurations, IIS, application deployment (MSI), multimedia, services, etc. And's it's all done with a nice component paradigm of methods, collections, and properties. Those same COM interfaces are also available for application development to VB6 (native), C++ and .NET.
We've had this COM environment for 10 years with Windows. In my opinion it's more powerful than the "everything's a pipe" approach.
I thought the first P stood for "Personal" originally ("Personal Home Pages"). Now it's supposed to stand for "PHP" ("PHP: Hypertext Processor").
Bad Panda! No Bamboo for you! In matters of importance ACs will not be responded to. Want to say something critical,OK
You're assuming 'limit' is less than or equal to 256 without checking. You're assuming that x, y, and z are set to nulls. You're not handling regional text (i.e. accented alphabetics) or unicode. You also haven't accounted for the fact that the Perl code returns the three bracketed sections of the match in variables.
The BeanShell lets you use pure Java as a scripting language and it's almost trivial to include the BeanShell in your Java application.
See http://www.beanshell.org/.
You may not be aware of this, but the article you linked to is a copy of this one. In the interest of giving credit where it's due, you might want to give Wikipedia more exposure in the future.
I always mod up spelling trolls.
My friend Salvatore and I did a similar site, although we haven't added so many languages and tests, and are more focused on benchmarking. It's available at: scutigena.sf.net
http://www.welton.it/davidw/
If you bothered to read the article...
The lines of code needed to achieve a task are measured, as they serve as an indicator on how fast one can create a script.
If you need 20 lines of C# to check if a file exists, but only one in Perl, then according to the study, Perl should receive a better weighted score for ease of implementation.
Read the articles people! They are interesting (at least most of the time).
A prime example is the way that Perl has seperate numrical and string comparitors (==/!= and eq/ne) whereas PHP has only the one (==). This recently came up in the story about the Perl periodic table of elements and I even gave my own answer on this problem. Just to rehash: Perl and PHP are loosely-typed languages so the programmer really needs to tell the interpreter how to compare the mixed numerical/string "scalar" type that both Perl and PHP use. But PHP tries to simplify at the expense of introducing ambiguity.
PHP has == and != for simple comparison, and === and !== for enforcing that the comparants (is that a word?) are also of the same type.
See http://nl3.php.net/manual/en/language.operators.co mparison.php.
JP
okay. you are completely playing an apples and oranges game here comparing command-line piping to a heavy component architecture. (COM vs. CORBA would have been more appropriate.) But I'll bite.
COM as it compares to Common Unix CLI Utils:
- it's much slower
- requires a huge amount of effort and code bloat to create your own.
- requires a messy register/unregister process to distribute or use
- even with the huge amount of COM objects MS offers, they still can't match the functionality of common unix tools.
- generally COM objects are either undocumented, or suffer from poor documentation compared to unix command-line equivalents.
- as was pointed out by another...COM requires a full implementation/interface to be loaded and exposed even when the client needs very limited functionality 99% of the time.
- COM collections are awful. Particularly since most of MS's languages do not know how to box a primitive into an object. (IE, try putting a few ints into a collection and pulling them back out in a foreach. better hope you are in VB and can grab that 16byte(!!!) variant object.)
- 10 years. Wow. I can't think of one common unix tool that hasn't been around for at least ten years.
- COM sucks. Even MS knows it. Why do you think they ditched it?
I searched around a bit, and found that someone's already done it. It uses the PCRE library along with a camlp4 macro that provides an elegant "match ____ with" construct tailored specifically to regexps. I'm impressed.
sh doesn't have true RE handling builtin, it only has globs through 'case'
Note that this isn't true in bash - bash scripting has extended globs feature equivalent to POSIX REs except for lacking backreferences. And you don't have to use case, you can use the [[ builtin.
Before you cough on Ruby and said "2" + 2 in Ruby will equal 4, have you even tried it? Ruby (and Python) are _strongly-typed_ languages, unlike Perl (and PHP) which are weakly-typed. Ruby protects you from mixing string and numbers in operations like +. You'll have to say "2".to_i + 2.
And having used all four of those for projects large and small, I can say with confidence that I prefer strongly typed language. Weakly typed language is more dangerous and error-prone.
But they probably would want it at least in the language, so it would be:
:)
<? print "Hello World" ?>
or
<? echo "Hello World" ?>
They probably should have included it, but that would add quite a few other "web" scripting languages, as long as they have a way to run them locally. Off the top of my head, I'm thinking ColdFusion, I'm sure there are more.
I think a fun game would be to find the longest way to print "Hello World", without unnecessary filler functions or comments. My first attempt would be to have the Base64 encoded string as a variable, then decode it, then print it, and have all that in an encoded eval.
I found a script someone had that did their "protection" that way. Without the registration key, you couldn't run it, and they had this beautiful set of encoded strings in evals that did the checking. Took me a good 20 minutes to figure the whole thing out. Then I rewrote that part, so I could try the software without a working key.
The software was otherwise crap, except for all the work they had put into requiring the key. I tried it, and proceeded to delete it. It would have been nice if they had a shareware version to try first. I'm really glad I didn't spend the $200 they wanted for it.
Serious? Seriousness is well above my pay grade.
irb(main):001:0> 2 + "2" TypeError: String can't be coerced into Fixnum from (irb):1:in `+' from (irb):1
When a program says "shift;", I can't just look up "shift" in the perl manual somewhere,
You mean, "perldoc -f shift"? wow that was hard!
I have to already know about how @_ works in order to understand what the program is doing.
That's just fairly basic Perl.
Both are untrue. TCL will happily take command line arguments, and if you set the execute bit under unix, will happily act as programs. If by "programs can be passed over the command line" that he wants to bang out to the shell, there is the exec command. Of course in his hello world program he uses BOTH features.
TCL gives you a complete stack dump on every error that is stored in a global variable "lastError", and you can override the background error with the bgError command. That also covers the "FullInterpreter in Debugger". The language was designed AS a debugger to C programs for christ's sake.
All told that cost TCL 15 points.
Sure I'm quibbling, but if you aren't going to compentantly seek out features save in all your favorites, you look like an idiot putting these comparisons together.
(Disclosure: TCL Guru.)
"Learning is not compulsory... neither is survival."
--Dr.W.Edwards Deming
Heh. Not only did he do that, he returned the pointer into an int (which isn't guaranteed to work), and then failed to return any value at all if limit = 0 (which is always fun for the caller).
:)
Burn your keyboard. And your C manuals. Take up Visual Basic or something
Why doesn't the gene pool have a life guard?
True, except the latest versions of php 4.x have a 'CLI', non-web version.
As a matter of fact, the older versions had a CGI version which could be run from the console as well.
So, yes, it should have been included.
The function signature is 'int', whereas at this point it is returning a char *... Yeah, burn it!
Stupidity is an equal opportunity striker.
Fellow slashdotter Bill Dog
One of the down sides to the advancement of the free "as in everything" OSs is that people are learning lots of perl and python and such but not learning shell. Whether you are a developer, sysadmin, user or tinkerer you should learn shell first and always add it to the list of tools to evaluate for any situation that comes up.
--
If I actually could spell I'd have spelled it right in the first place.
You can do this in Haskell:
match-all $ case-insensitive $
do {
many (not '&');
char '&';
many whitespace;
char '(';
many (not ')');
char ')'
}
Not one-hundred lines, descriptive and do, IIUC, what your one-liner does. Functional programming languages (specially Haskell and Scheme) can be both concise and clear. BTW we can easily abstract common regexes away, for example the parenthesis thing above:
parenthesis pattern =
do {
char '(';
pattern;
char ')'
}
match-all $ case-insensitive $
do {
many (not '&');
char '&';
many whitespace;
parenthesis $ many (not ')')
}
Disclaimer: If I disagree with you I'm probably trolling...
$ sml ../compiler/TopLevel/interact/evalloop.sml:52.48-5 2.56
../compiler/TopLevel/interact/evalloop.sml:35.55
Standard ML of New Jersey v110.42 [FLINT v1.5], October 16, 2002
- 1 + 1; (* Add two ints *)
val it = 2 : int
- 1.0 + 1.0; (* Add two floats *)
val it = 2.0 : real
- 1 + 1.0; (* Error! *)
stdIn:5.1-5.8 Error: operator and operand don't agree [literal]
operator domain: int * int
operand: int * real
in expression:
1 + 1.0
uncaught exception Error
raised at:
- fun f x y = x + y; (* Define a function *)
val f = fn : int -> int -> int
- fun f x y = f (x-1) y; (* Define a recursive function *)
val f = fn : int -> 'a -> 'b
Are you adequate?
Beanshell is not Java, so your point is moot..
I would argue that this is not true. You can type in and execute Java code into the BeanShell prompt and it will execute interactively. BeanShell itself is written 100% in Java.
You may say its not Java because its not a part of the standard Java APIs, but there are plenty of other scripting extensions to Java that are: Java scriptlets in JSP pages; the Java Standard Tag Library in JSP pages.
I can complete most string manipulation tasks in Perl in 5 lines as compared to over 100 in Java.
Yes, Perl is a very consise language that is superb for scripting. For string manipulation and many other tasks it's unbeatable.
Java is simply not suitable in a scripting environment.
That was not the point that was being made. The article said 'Java was completely unusable in a scripting environment'. This not true. Perhaps the most widely used example is JSP, the java equivalent to PHP and ASP. You can open up a JSP page, type in Java code, and have that page run immediately as part of a live web application. As with PHP you can add and edit pages containing code without shutting anything down. As far as the developer is concerned there is no compile-edit-run cycle. If that is not scripting, what is?
How about Regexp::English in Perl 5 or Perl6::Rules in Perls 5 and 6?
how to invest, a novice's guide
The interesting conclusions are:
It's apparent by now you haven't used perl or CPAN. If you had you would know how much jakarta and CPAN differ.
You seem to confuse a build system like Maven and a package installer system like CPAN. CPAN is more like apt-get and maven is more like make on steroids.
evil is as evil does
I know it probably doesn't matter to most of you, but even lisp has something like CPAN. Its called ASDF, and there is a library called ASDF-Install. Of course common lisp lacks the huge number of libraries that more popular languages have, but (I have to admit) its getting better (getting better all the time).
ASDF on cliki
The answer is that perl came first. Building sophisticated infrastructure like CPAN takes time, and requires a certain critical mass of contributing developers to be effective and useful. As it happens, the Ruby folks are rapidly building a solution of their own devising, already quite usable.
You're right about docs and the fact that CPAN is more mature.
You're wrong about the large library: what do you really need and could not find in ruby or python? Ask for it and probably you'll find that it exists.
db access, pdf/xsl/OOo docs/svg creation, numerical stuff, GUI stuff, ssh/ssl/tsl stuff, smtp/imap/pop/nntp, web libs/templating, csv handling, xml/xsl/Schema/Relax-ng,YAML, SOAP,xmlrpc, Linda/tuplespace/remote objects access, TestUnit, optparse/getopt/GO::Declare.. I really don't have need for something else.
And ruby has a way to install stuff automatically, it's called rubygems, and it interacts with rubyforge.org. It's a young project, but it's fully functional.