Searching for the Best Scripting Language 673
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."
Nobody ever looks at Io or REXX... (Score:5, Informative)
Io [iolanguage.com], 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 [sf.net] (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 [sf.net], 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.)
Scripting with Java (Score:3, Informative)
From an ocaml convert: (Score:5, Informative)
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.
Re:Biased (Score:5, Informative)
Re:Scripting with Java (Score:3, Informative)
If you'd like to try scripting with Java, then I suggest looking into Mozilla Rhino, which allows one to script Java via JavaScript.
Rhino is a JavaScript interpreter written in Java, it's not a Java interpreter.
I used to think Python was great for _everything_ (Score:3, Informative)
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.
pulling a Tcl boner (Score:4, Informative)
No PHP? (Score:3, Informative)
Read essays by Paul Graham (Score:5, Informative)
I put Ruby in my resume (Score:2, Informative)
Re:it depends upon the application (Score:5, Informative)
Most copies of PHP use the equivalent of mod_perl [apache.org] -- i.e. they cache the compilation. Use mod_perl [apache.org], cache your compilations, and you will find performance is as good if not better than PHP.
Re:What about readability? (Score:4, Informative)
I heard someone is looking for Ruby? :-) (Score:5, Informative)
(the gotcha is it's mostly in Portuguese. So jump to the "Exemplos Meus" (My Examples) section. Or use babelfish: http://babelfish.altavista.com [altavista.com])
http://geocities.com/canalruby [geocities.com]
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 [enigo.com]
Further enlightening at:
http://www.ruby-doc.com [ruby-doc.com]
http://www.rubyforge.org [rubyforge.org]
http://raa.ruby-lang.org [ruby-lang.org]
You know, once you get addicted, there is no going back!
Re:vbscript (Score:5, Informative)
It never was an acronym. See an explanation of Perl's name [wordiq.com] for an explanation of the backronym.
Just hired a Ruby programmer (Score:5, Informative)
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.
Learning how CPUs work (Score:5, Informative)
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 [hkrmicro.com], 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 [verilog.net] is better, but VHDL is OK. Compilers and simulators are freely available [faqs.org] for both.
Get an FPGA development kit. Compile yourself some hardware. You can put full CPUs [optushome.com.au] 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 [openip.org] 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...
Re:From an ocaml convert: (Score:4, Informative)
Yes, lazy evaluation can be done in OCaml too, but the syntax is uglier. You use the lazy module.
I have used OCaml a bit, and one of the things that most irritated me about it was its complete lack of operator overloading; having to use "+" for integer addition, and ".+" for floating point addition, just seems so wrong to me. Haskell uses type classes to allow ad-hoc polymorphism in a controlled manner.
Haskell's solution to the problem is ingenius, but unfortunately very often requires tagging of those classes, which is slow.
One advantage that OCaml has over Haskell is speed; current Haskell implementations produce code somewhere between imperitive compiled languages and interpreted languages. However, there is another language, called Clean, that is nearly identical to Haskell in many ways, but claims to have speed comparable to C.
Looks like Clean has a more powerful set generator than Haskell (it's basically SQL queries), a different class system, and rather different syntax. But it could be useful, I'll check it out.
Re:Duh (Score:3, Informative)
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?
By features instead of by language (Score:5, Informative)
After years of debating language features, I generally conclude that a lot of it is subjective. No language will ever satisfy everybody.
Re:Biased (Score:1, Informative)
Re:Isn't that an ill-formed regexp? (Score:2, Informative)
Re:VBscript seems great... (Score:4, Informative)
nothing in the OS was ever really meant to be scriptable
That's not really true. Most OS functions are available through COM interfaces [microsoft.com]. 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.
Re:What about readability? (Score:1, Informative)
Re:What about readability? (Score:4, Informative)
Re:What about readability? (Score:5, Informative)
Java as a scripting language (Score:2, Informative)
See http://www.beanshell.org/ [beanshell.org].
Re:vbscript (Score:3, Informative)
Re:The eternal quest... (Score:5, Informative)
Re:You're missing the point. (not again) (Score:4, Informative)
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).
Re:PHP (Score:3, Informative)
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 [php.net].
JP
Re:VBscript seems great... (Score:1, Informative)
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?
someone's already done it (Score:3, Informative)
Re:Biased (Score:2, Informative)
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.
Re:Why I like perl (Score:4, Informative)
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.
Re:flamewar volley 1 (Score:5, Informative)
<? 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.
Re:Why I like perl (Score:3, Informative)
Re:What about readability? (Score:3, Informative)
Re:What about readability? (Score:3, Informative)
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.
Re:From an ocaml convert: (Score:3, Informative)
type t =
A of a |
B of t Set
won't work...
That's because Set is a module, not a type. Sets are done with functors, you need to instantiate Set.Make with a module whose signature matches Set.OrderedType.
It's possible to do exactly what you want using recursive modules - in fact, this is the example the OCaml Reference Manual gives for recursive modules: As for the lack of overloading, in the few cases where it's actually useful you can normally achieve the same effect by wrapping your types in objects, since OCaml conveniently separates object typing from inheritance.
Re:Nobody ever looks at Io or REXX... (Score:3, Informative)
Lisp.
Scheme [scheme.org].
Actually just pick [dmoz.org] one [google.com]
TCL Got shortchanged (Score:4, Informative)
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.)
Re:What about readability? (Score:3, Informative)
Burn your keyboard. And your C manuals. Take up Visual Basic or something
Re:Nobody ever looks at Io or REXX... (Score:3, Informative)
We've considered redoing that script in php so we could run it on one of the linux boxes there, but haven't managed to find a round "tuit" yet
Thats the only machine in the place thats still stuck with a bnc type 10BaseT card. Its an elderly 2k, with an FF40 card for brains, a picasso-II video and 32 megs of ram. For all the hoorah about the FF40 card being made without some of the system bus signals, with the version 3.4 Plug-n-go roms for use with os3.1, its been very very bulletproof, for a "migi".
Usually, when we have to reboot it to get thigs back among the living, we have to reboot the NT server its getting its data from because something in the NT networking has a tummy ache too. The news room clients can access it, but the migi can't until the NT box has been rebooted too.
Re:flamewar volley 1 (Score:2, Informative)
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.
Re:What about readability? (Score:2, Informative)
Re:From an ocaml convert: (Score:4, Informative)
About six months ago, I decided I needed to re-learn functional programming, so I did a project in Haskell and learned that. More or less. I still find Modads awkward, and IO is a total pain in the ass, but all in all, I really like Haskell. However, at some point, I noticed the performance issues; Haskell is pretty slow -- slower than some scripting languages, like Ruby, for a lot of tasks.
So then I looked at OCaml, because OCaml has a reputation for being fast, and it is also a functional programming language that compiles to native executables.
I have to say, my first (and lasting) impression was: WTF? Look at this:
Why do I have to *tell* the compiler that the function is recursive? The compiler is able to do inferrence type checking; why can't it tell that a function is going to recurse? In fact, why is there "let" anyway? Seriously, the compiler should be able to figure these things out. Haskell's compilers do. And did they decide to end lines with two semi-colons just to add keystrokes? Why? Why? Why?
The simple fact is that Ocaml requires the programmer to do a lot of the compiler's work for it. I find this to be the most annoying feature of any programming language. Ocaml gets rid of some stupidities, like variable type declarations, but it adds all of this other stupid syntactic cruft that shouldn't be necessary.
OCaml is popular. It is efficient (lines of code), and it creates fast executables (second only to C). There are a lot of reasons to love it, and I feel obligated to learn it, but I'm having a hard time getting over what superficially appear to be poor language design decisions. So, is there a good reason for the extra syntactic oddness in OCaml, or is it just there because it always has been?
Scripting is good (Score:3, Informative)
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.
Re:From an ocaml convert: (Score:3, Informative)
As to the double semicolon, it's because the single semicolon is a statement separator (like in other languages, except you don't use it often in ocaml), while the double semicolon is a function terminator. You don't need the double semicolon all that much: using the interactive toploop, you may need it once in a large block (basically to let the toploop know you're done), and when compiling from a file, often even that can be omitted (for example, if the next statement is a "let"). So you could write rather large programs without any double semicolons.
Re:What about readability? (Score:2, Informative)
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 ')')
}
Standard ML is nicer there (Score:2, Informative)
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
Re:Java's string manipulation is horrible (Score:3, Informative)
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?
Re:What about readability? (Score:3, Informative)
How about Regexp::English [cpan.org] in Perl 5 or Perl6::Rules [cpan.org] in Perls 5 and 6?
Re:The eternal quest... (Score:4, Informative)
The interesting conclusions are:
Re:From an ocaml convert: (Score:2, Informative)
As for the use of let versus let rec, this is necessary as the two scope differently. With let the scope in the function or binding is that before it, whereas with let rec the scope in the function or binding includes the new function or binding. You imply above that let should always have let rec semantics, but this would have the problem that functions could not use previous functions of the same name, and bindings could not refer to previous bindings of the same name, as they would already have themselves in their own scope, which would mask any previous functions or bindings of the same name.
Re:It's not the language it's the library. (Score:3, Informative)
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.
Re:It's not the language it's the library. (Score:3, Informative)
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 [cliki.net]
Re:It's not the language it's the library. (Score:3, Informative)
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. [rubyforge.org]
Re:Scripting with Java (Score:2, Informative)
Rhino is a JavaScript interpretter written in Java, but it is also a JavaScript-Java bridge. So it de facto does indeed allow you to script Java via JavaScript. I do it all the time. The Rhino site even suggests using Rhino for exactly this purpose.
Beanshell lets you script Java, as well. Those scripts just like Java, with some additional console-friendly global commands thrown in the mix.
Re:It's not the language it's the library. (Score:2, Informative)
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.