Mar 152009
 

Someone recently asked what my issue was regarding the JVM, since at the moment it prevents me from falling too much in love with Clojure — a language with the double-benefits of functional programming, and Lisp syntax and macros.

Well, below is my reason. These may not seem like much time in the scheme of things, but psychologically it builds up on me when I have to run a particular script over and over and over again. I’ve already noticed the pain with Groovy.

Language Running time
C 0.00415675640106
C++ 0.0043337225914
Haskell (compiled) 0.00494946241379
Perl 0.00773874521255
Ruby (1.8.7) 0.00913717746735
Ruby (1.9.1-p0) 0.0196997523308
Python 0.0269904136658
ECL (Common Lisp) 0.126332080364
Java (JDK6) 0.146584188938
Haskell (interpreted) 0.20009740591
Groovy (JDK6) 1.07791568041

If you’d like to generate some of these timings for your own system, I have created a Hello, world project on GitHub.

 Posted by at 9:50 am

  10 Responses to “Run times for Hello, World in 2009”

  1. If startup time for scripts is really an issue for you then [Nailgun](http://martiansoftware.com/nailgun/index.html) might help.

  2. I will definitely look into this, thanks!

  3. 1) ECL test refers to ~/Library directory. I figured out how to create .fas or .o but can’t guess from ecl manpage how to build executable. Maybe it could be improved?

    2) Here are suggestions for scala (another sexy jvm-based lang)

    Compiled HelloScala.scala:

    object HelloScala {
    def main(args: Array[String]) {
    println(“Hello, world!”)
    }
    }

    Interpreted hello.scala:

    println(“Hello, world!”)

    Makefile:

    all : (…) HelloScala.class
    (…)
    @echo “Scala (compiled)”; ./average -n 20 scala -cp . HelloScala > /dev/null
    @echo “Scala (interpreted)”; ./average -n 20 scala hello.scala > /dev/null

    (on my system compiled scala is ~ 2.5x slower than compiled java, interpreted scala is ~ 3x slower than groovy)

    3) I’d suggest adding sth like “make test” to check whether everything outputs what it should, for example:

    test:
    @echo “C”; ./hello-c
    @echo “C++”; ./hello-cc
    @echo “Haskell (compiled)”; ./hello-hs
    @echo “Perl”; perl ./hello.pl
    @echo “Ruby (1.8.7)”; ruby ./hello.rb
    @echo “Ruby (1.9.1-p0)”; ruby1.9 ./hello.rb
    @echo “Python”; python ./hello.py
    @echo “Python3″; python3 ./hello3.py
    @echo “Java (JDK6)”; java -cp . HelloWorld
    @echo “Haskell (interpreted)”; runhaskell ./hello-hs.hs
    @echo “Groovy (JDK6)”; ./hello.groovy
    @echo “Scala (compiled)”; scala -cp . HelloScala
    @echo “Scala (interpreted)”; scala hello.scala

  4. Those numbers for Java surprise me. Does that include jvm startup times? Also, don’t you think that hotspot compilation would ultimately reduce that runtime, if it were something more complicated than hello world?

    I ask because I’ve seen a lot of studies which indicate, for example, that grails is about twice as fast as rails, which I had attributed ultimately to Java.

  5. Long-running Java is very fast, this analysis was only looking at startup times for doing simple tasks at the command-line.

  6. Using nailgun with interpreted Groovy, I’m seeing times on average of 0.0236s. That puts it in the same ballpark as Python! Very nice.

  7. Have a go with compiled java. It’s quite well supported by the GNU compiler suite (gcj).

  8. is compiled java the same thing as using javac?

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>