Archives

Creative Commons License
This blog is licensed under a Creative Commons License.

Run times for Hello, World in 2009

| 8 Comments | No TrackBacks

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.

No TrackBacks

TrackBack URL: http://www.newartisans.com/mt/mt-tb.cgi/2543

8 Comments

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

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.

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.

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

Leave a comment

About this Entry

This page contains a single entry by John Wiegley published on March 15, 2009 9:50 AM.

Hello Haskell, Goodbye Lisp was the previous entry in this blog.

The JVM, and costs vs. benefits is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Recent Comments

  • yoman: “Barfin”? “Slurping”? “Slime” “Hunchentoot” ??? What in the T.F. world read more
  • Bjorn Tipling: Why would you add instructions for installing an editor when read more
  • Mark Aufflick: sudo port install sbcl +threads If you previously installed sbcl read more
  • Alexander Lehmann: Thank. You. So. Much. – Clisp caused a lot of read more
  • Vetle: Btw, to get support for threading in SBCL, you have read more
  • ifade: I tried the same and get the same answer, but read more
  • Martial Boniou: Hi, I tried to install slime with MacPorts and I read more
OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.261