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.


If startup time for scripts is really an issue for you then Nailgun might help.
I will definitely look into this, thanks!
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.scalaThose 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.
Long-running Java is very fast, this analysis was only looking at startup times for doing simple tasks at the command-line.
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.
The benchmarks game, startup
http://shootout.alioth.debian.org/gp4/benchmark.php?test=hello&lang=all
Have a go with compiled java. It’s quite well supported by the GNU compiler suite (gcj).