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

28 of 673 comments (clear)

  1. 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...
  2. From an ocaml convert: by rsidd · · Score: 4, Informative
    It's an incredible language. I'm writing programs now that are more concise than the Python equivalent and about as fast as C. It's really the holy grail I was looking for. (According to a more thorough shootout, ocaml is competitive in speed with C and often faster than C++, and well ahead of all other competition in speed.)

    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.

    1. Re:From an ocaml convert: by wirelessbuzzers · · Score: 4, Informative

      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.

      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.

      --
      I hereby place the above post in the public domain.
    2. Re:From an ocaml convert: by srussell · · Score: 3, Informative
      This is not flaimbait: I'm honestly curious.

      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:

      1 + 1 (* Add two ints *)
      1. +. 1. (* Add two floats. WTF? Why?
      Is the compiler so stupid that it
      can't recognise floats? *)
      1 + 1.0 (* Error! *)
      1 +. 1.0 (* Error! *)
      let f x y = x + y (* Define a function *)
      let rec f x y = f (x-1) y (* Define a recursive
      function. Again, why? *)

      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?

  3. 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.
  4. pulling a Tcl boner by Anonymous Coward · · Score: 4, Informative
    His Tcl example is not written fairly. The dude should know that that Tcl supports getopts:

    package require GetOpts 1.1

  5. No PHP? by Anonymous Coward · · Score: 3, Informative

    I don't see PHP listed. It's possition on the list is arguable, but it certainly belongs there.

  6. Read essays by Paul Graham by linuxbaby · · Score: 4, Informative
    Anyone interested in the benefits of different programming languages should read some of the great well-thought-out essays by Paul Graham:
  7. Re:it depends upon the application by KingOfBLASH · · Score: 4, Informative
    php for real-time multiuser applications on the high level, C for real performance

    perl for non-real-time application (unless you're slashdot and have oodles of resources at your disposal, even then, it's still inefficient)

    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.

  8. Re:What about readability? by shimpei · · Score: 4, Informative
    Bah.. Perl doesn't even have an interactive interpreter..
    perl -de 0
  9. 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! :-)

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

  11. Just hired a Ruby programmer by CatGrep · · Score: 4, Informative

    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.

  12. Learning how CPUs work by SSpade · · Score: 4, 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, 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...

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

  14. Re:VBscript seems great... by davegust · · Score: 3, 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. 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.

  15. Re:What about readability? by Hungus · · Score: 4, Informative
    I don't know where you got your info on the origin of PHP but the official history found at PHP.net states this:
    PHP succeeds an older product, named PHP/FI. PHP/FI was created by Rasmus Lerdorf in 1995, initially as a simple set of Perl scripts for tracking accesses to his online resume. He named this set of scripts 'Personal Home Page Tools'. As more functionality was required, Rasmus wrote a much larger C implementation, which was able to communicate with databases, and enabled users to develop simple dynamic Web applications. Rasmus chose to release the source code for PHP/FI for everybody to see, so that anybody can use it, as well as fix bugs in it and improve the code.

    PHP/FI, which stood for Personal Home Page / Forms Interpreter, included some of the basic functionality of PHP as we know it today. It had Perl-like variables, automatic interpretation of form variables and HTML embedded syntax. The syntax itself was similar to that of Perl, albeit much more limited, simple, and somewhat inconsistent.
    So while its origins lie directly in PERL it was not names Perl Header Pages. So 5 points for effort, -27 points for accuracy
    --
    Bad Panda! No Bamboo for you! In matters of importance ACs will not be responded to. Want to say something critical,OK
  16. Re:What about readability? by RedWizzard · · Score: 4, Informative

    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.

  17. Re:vbscript by Yath · · Score: 3, Informative

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

  19. Re:You're missing the point. (not again) by MoonChildCY · · Score: 4, Informative

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

  20. Re:Why I like perl by davegaramond · · Score: 4, Informative

    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.

  21. Re:flamewar volley 1 by JWSmythe · · Score: 4, Informative

    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.
  22. Re:What about readability? by brewt · · Score: 3, Informative

    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.

  23. TCL Got shortchanged by EvilTwinSkippy · · Score: 3, Informative
    I was reading through the criteria, and TCL was docked points for not being able to pass commands through the command line and not having a debugger.

    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
  24. Re:What about readability? by chromatic · · Score: 3, Informative
    I personally would much rather somebody came up with a longhand way to do real regexps.

    How about Regexp::English in Perl 5 or Perl6::Rules in Perls 5 and 6?

  25. Re:The eternal quest... by mtsv01 · · Score: 4, Informative
    Another interesting comparison of programming languages is "An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl"
    The interesting conclusions are:
    • Designing and writing the program in Perl, Python, Rexx, or Tcl takes no more than half as much time as writing it in C, C++, or Java and the resulting program is only half as long.
    • No unambiguous differences in program reliability between the language groups were observed.
    • The typical memory consumption of a script program is about twice that of a C or C++ program. For Java it is another factor of two higher.
    • For the initialization phase of the phonecode program (reading the 1 MB dictionary file and creating the 70k- entry internal data structure), the C and C++ programs have a strong run time advantage of about factor 3 to 4 compared to Java and about 5 to 10 compared to the script languages.
    • For the main phase of the phonecode program (search through the internal data structure), the advantage in run time of C or C++ versus Java is only about factor 2 and the script programs even tend to be faster than the Java programs.
    • Within the script languages, Python and in particular Perl are faster than Tcl for both phases.
    • For all program aspects investigated, the performance variability due to different programmers (as described by the bad/good ratios) is on average about as large or even larger than the variability due to different languages.
  26. Re:It's not the language it's the library. by drgnvale · · Score: 3, Informative
    Until another language offers what CPAN does I don't care that much about it

    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