Slashdot Mirror


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."

20 of 673 comments (clear)

  1. Slashdot Code Auto Answer by Anonymous Coward · · Score: 5, Funny

    Hello, I am the Slashdot Source Code. The answer is Perl. This question is now answered.

    Thank you for visiting Slashdot.

  2. The eternal quest... by Anonymous Coward · · Score: 5, Insightful

    ... for a difinitive answer to a subjective question.

    1. Re:The eternal quest... by DavidNWelton · · Score: 5, Informative

      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

  3. Nobody ever looks at Io or REXX... by Dimwit · · Score: 5, Informative

    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...
  4. What about readability? by BlueCup · · Score: 5, Insightful

    Perl can do a lot, but nothing is more painful than having to look at a perl source code. While a program can be written semi readable, when compared to some others, like PHP or python, they typically make me want to stick very large needles in my eyes.

    --
    WANNAWIKI Wannawiki WannaWiki WANNAWIKI!
    1. Re:What about readability? by DAldredge · · Score: 5, Insightful

      I have seen php code that makes me cry it was so badly written, I have also seen perl code that bad but don't blame the language, blame the idiot who is writing the unreadable code.

    2. Re:What about readability? by Camel+Pilot · · Score: 5, Insightful

      When you press people on perl and readability they usually quote some exacerbating regular expression. Reg exp are often used in perl since they are are handy and built in. And yes, reg exp tend to be a little cryptic. However taking a little time to figure out something like

      $str =~ /(.*?)\&(\w+)\((.*?)\)/gis

      is a lot easier than understand the 100 lines of code that would be required to accomplish the same task if you where not using a reg exp.

      I would be very interested in hearing what you think PHP provides that enhances readablity over perl.

  5. Duh by Beek · · Score: 5, Insightful

    How about the best language for the task you are trying to accomplish?

    I've been using AppleScript for a bunch of stuff lately, but when I hit something that wasn't really intuitive in AppleScript that could easily be done in Perl, then I did it in Perl. Obvious, yesno?

  6. My dear lord, by dotz · · Score: 5, Insightful
    If you want to choose your scripting language by measures like "Program Lengths by Language", "the smallest running program", "access environment variable", "grep with -F -i -h handling, usage, grep'ing many files", then yes, go for it, that report was done for you.

    Me? I'd rather choose my scripting *and* programming language by some other measures, which mainly involve:

    • portability
    • object model
    • ease of writing C/asm extensions (for speed!)
    • extension modules available in default installation
    I have my own choice (not the winner, it's my *choice* - I haven't compared and/or used other ones mentioned too extensivley). I have as portable interpreter, as Java (except it does work, not only claims that), with much smaller footprint; I can code extensions in C using simple syntax (it's very easy); I have already thousands of available modules in the base installation.

    I am pretty sure, that other tools, mentioned in the report, also allow pretty much the same, some of them do that better, some of them are worse, some are not worth using (as we seen, network stack can be written in PHP) - that's not the point. In my opinion, that report seems like comparing pneumatic hammers, ordinary hammers, sledgehammers and hamsters (mainly because "hammer" sounds similar to "hamster", so what the heck, let's compare them) - by something like color or shape, not by the things they can do.

    You shouldn't compare tools like this (well, except for purely academical purposes), it's not useful at all for me. And, if you want to choose your tools basing on such reports, well then, good luck.

  7. Re:Biased by jelle · · Score: 5, Informative

    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.
  8. Why I like perl by Anonymous Coward · · Score: 5, Insightful

    I'm going to stick my neck out and say I like Perl -- so I think this is good news. However, I've always thought of Perl as a text-processing language, and In My Limited Experience, mobile phones can only fit about ten words on the screen. {on the other hand, this could simply lead to phones with bigger screens.}

    There's no denying that you can write really ugly code in Perl, but you can also write beautiul code in Perl. I think some of the people who knock Perl are confusing "undisciplined" with "not anal retentive". Perl was always based around the idea of serving the end rather than the means -- it's about where you're at, rather than how you got there. It does not impose a particular style on the programmer. Thus, for any given task, there could be many, many ways to accomplish it in Perl.

    They're all right.

    Some will be faster than others, some will use fewer resources than others, some will look prettier then others when viewed as source. But if you don't care enough about those things to mention them in the design spec, then they don't matter.

    Now, you can have your fancy object-oriented stuff, but in many ways it's overkill. For instance, if you needed to write a programme involving geometry, you could create an Angle object which would have a value assumed to be in radians and properties for its sine, cosine, tangent and representation in degrees; a Distance object which would have properties for its representation in different measuring units; and assigning a value to any property would affect the object and therefore its other properties. It might be beautiful if you like the OO concept, but it's a bit overkill if you just want to find the missing side of a triangle.

    And does a "disposable" programme -- one that you will run only a few times before forgetting it forever -- really need to look pretty anyway?

    As for PHP, well, it really isn't much different from Perl -- apart from always needing to put brackets around function parameters, the fact that all variables start with a $ sign whether scalar, array or hash and there is no $_. {I happen to love $_. It goes nicely with the concept of an accumulator. If you never did any assembly language, you probably won't know what I'm talking about, though}. That is hardly surprising, because the original PHP was actually written in Perl to be like a kind of subset of Perl.

    Also, one of my little niggles -- and I freely admit that this is just my own opinion -- is the inability to get on with any language that uses the plus sign as the string concatenation operator while letting you freely mix string and numberic variables. {*cough* ruby *cough*} I expect "2" + 2 to equal 4, not 22. Hell, if I have to do something to my variables before I can add them, that just nullified the advantage of having freely-mixable scalar types! It might as well be a strict-typed language and barf on an expression such as "2" + 2!

    As for Python - well, it's not my cup of tea {I guess you like either Perl or Python} but other people seem to have written some pretty good stuff in it, so I shan't knock it.

  9. Re:From an ocaml convert: by gauchopuro · · Score: 5, Interesting
    I suggest you also take a look at Haskell, if you have not done so already. Haskell completely does away with side effects, performing IO operations in a controlled manner through the use of a mathematical concept known as monads. It also adds lazy evaluation. This has some nice capabilities, such as being able to express concepts as infinite lists, which are then only evaluated as far as necessary.

    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.

    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.

    Back to the topic of the discussion, Haskell is probably not the best choice for quick and dirty one time scripting uses. The use of monads for doing IO adds a constant cost that is burdensome for very small programs, and gets payed back only with larger programs where the controlled approach to IO increases robustness.

  10. Re:good but recognized? by archen · · Score: 5, Interesting

    That depends. I've heard that Ruby is already more popular in Japan than Python. Much of the ports system in FreeBSD (like portupgrade) is written in Ruby. The fact that Ruby is a pretty young language and has already gained so much support tells much of how good it is. While it might not be quite so useful for a resume, it is good for getting results. I know where I work they don't care about the details, they just want results. Right now I write things in perl, but I have the feeling that once perl 6 comes into the mainstream, I'll be moving to Ruby. You don't have to get very far into the language to realize it's very powerful for writing quick scripts, and can scale VERY well. Aside from that it has taint checking which is also a plus - it's certainly worth it just for doing your own tasks if nothing else.

  11. Re:Biased by notsoclever · · Score: 5, Insightful
    There's lots of other subtle biases. For example, in the "grep" example, the sh code simply called grep. If he wanted to be pure about the scripting he'd not have had any way of doing a RE in sh (since it doesn't have true RE handling builtin, it only has globs through 'case') and if he was going to use external calls then why didn't he just do 'exec grep "$@"' or otherwise afford the use of external command execution to the other languages too?

    Also, in a lot of the Tcl scripts he added in a bunch of "good practice" verbosity which he didn't afford to, say, Perl (similar to the C# vs Java disparities you noticed). For example, in tclsh you don't have to explicitly call 'exec' to call an external function since tclsh provides that as an unknown function handler, and he also used the longhand form of checking for a successful execution (namely 'catch') rather than just doing an if on its result.

    Personally, I just use the right tool for the job. I mostly use sh, PHP, and Tcl, depending on which sorts of things I'm scripting, though sometimes I'll also use perl and awk as appropriate (of course, I do often use awk as an external tool from sh).

    --
    There are 10 kinds of people: ones who understand ternary, ones who don't, and ones who think this joke is about binary
  12. I heard someone is looking for Ruby? :-) by rolling_bits · · Score: 5, Informative

    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! :-)

  13. Re:vbscript by chromatic · · Score: 5, Informative
    PERLScript (why do people not spell it like an acronym any more?)

    It never was an acronym. See an explanation of Perl's name for an explanation of the backronym.

  14. Not really a fair test. by Temporal · · Score: 5, Insightful

    First of all, a pure character-based size count seems unfair. I do not believe that the number of characters in a chunk of source code is directly correlated to the amount of time it takes to write. Most of a programmer's time is usually spent thinking, not typing, and you can thinking just as fast with verbose naming conventions as you can with terse ones, as long as the constructs are the same. And then, if the constructs are different, it's even harder to judge, because if the constructs in one language are more natural, corresponding closely to human thought patterns, then coding in that language will tend to be much faster than coding in more cryptic languages, even if the cryptic language requires fewer keypresses.

    For example, I tend to find that writing in functional languages is easier for me. My functional-language just tends to come out faster and contain far fewer bugs. I'm not entirely sure why, but I suspect it has something to do with the thought-pattern-correspondence idea I mentioned above.

    Second thought... some of these comparisons are clearly unfair. For example, one of the test cases is implementing "grep". The sh version of this case simply calls grep (after validating the arguments, I guess), which seems like a really big cop-out. Any language could just as easily run grep in a separate process. Meanwhile, the OCaml version seems to implement the main loop of grep manually in terms of library functions that are not identical to grep. That is to say, the main thing the OCaml code is doing is translating grep-specific options and semantics to the options and semantics used by its own library functions. To make this comparison fair, one would have to write a library function in OCaml which is identical to grep, then allow that function to be called without counting the library as part of its code.

    I think the only fair and useful way to make comparisons like this would be to hold a contest of some sort. Get an expect Perl programmer, an expert Python programmer, etc., together, then give them a program of some sort to implement. Avoid defining the program to be too similar to one language's library calls. In the end, judge the languages both on how fast the contestant completed the code and on how useful and robust the resulting code turns out to be.

    Probably not going to happen, of course.

  15. Rapid Development != Scripting by Vector7 · · Score: 5, Insightful

    > Interesting that ICFP contests lately pronounced OCaml as the winner for rapid development.

    Certainly that is interesting, but it has absolutely nothing to do with the subject of the article. "Rapid Development" (or development in general) is not comparable to scripting, and the ICFP contest tasks (which this year was to develop AI code governing ants in a colony) contrast sharply with the sort of scriping tasks in this shootout (compile a file if .o absent, invoke grep on some files, etc).

    [aside]

    This is not intended to rag on scripting or scripting languages, just to note that scripting embodies a largely distinct set of tasks from development in general (and a comparison involving OCaml or the ICFP contest is inappropriate). These sort of tasks that historically have been the domain of shell scripting, although perl seems to have taken over a lot of these things.

    As a lot of what perl is best at is simplifying things that you could almost do from the unix shell (or might be able to do with a script, but would be a pain in the ass..), it always struck me as logical that perl should evolve toward becoming a viable replacement for the unix shell.

    Sadly this doesn't seem to be on the agenda of the perl gods. Instead of evolving to better fill this niche, they seem to be gravitating toward becoming a sort of second-rate Java/Python immitator. I suspect that the underlying technologies they build with Parrot and the Perl 6 redesign will largely fail to convince many folks who aren't already perl users that perl is a useful substrate for developing real systems on top of. At the same time they will have neglected to improve in their original niche of quick and dirty sysadmin hacklets, while other languages will have continued to improve and build momentum.

    Then again, I'm quite possibly wrong. We'll see what happens. Should be interesting..

  16. By features instead of by language by Tablizer · · Score: 5, Informative

    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.

  17. Silly Java mistakes by Decaff · · Score: 5, Interesting

    There are some silly mistakes in this article, suggesting that the author does not really understand the languages he is comparing.

    Here are some examples:

    for 'return exit code error (non zero) if a file does not exist' and 'return exit code error (non zero) if a file is not readable. There is no Java or C# code supplied. Java can easily test this: for example

    new File(filePath).canRead();

    and

    new File(filePath).exists();

    and I'm sure C# can as well.

    There are other omissions:
    Under Java 1.5, the System.getenv() method allows access to environment variables.

    Also, saying Java is completely unusable in a scripting environment is nonsense. The BeanShell system has been around for years, and allows java to be run as if it were a scripting language, both from a command prompt or from script files. Java 'scriptlets' on JSP web pages are very common. Finally, there is a PHP/Java interface.

    I don't know C# well, but I'm sure there are similar facilities for that language.