Hasty benchmarking of various programming languages

Michael wants his CPU cycles back! Anyhow, using some benchmarking, we can make comparisons between languages (or rather, some implementations). Here are some possible conclusions (using an AMD CPU which is what I own):

The lessons here are:

  • Java is fast, as fast as C++ but its memory usage is worse than a language like Python.
  • Python is one of the fastest high level languages out there, but Perl is close behind.
  • PHP and Ruby are slow.
  • Languages like Lisp, Ocaml and Haskell can sometimes be used as replacement for C++ even when performance is a concern.
  • GCC is a good enough compiler.

Yes, I’m aware of the limitations of this analysis!!!

8 Comments

  1. Daniel, cheers for putting this together! I was planning on doing this sometime soon, but you’ve taken all the work out of it.

    Comment by Kunal — 10/1/2006 @ 0:03

  2. Merci, that’s easy enough to read. Of course, there is always the The Computer Language Shootout (nsieve example) if you’re looking for more numbers.

    Comment by Robin — 11/1/2006 @ 7:02

  3. If I’m reading this right the benchmark’s on the AMD Sempron, so the Intel compiler vs. GCC comparison may not apply. I doubt Intel has optimized their compiler for AMD.

    Comment by Parand Tony Darugar — 11/1/2006 @ 10:23

  4. Another lesson is that the managed, JIT-compiled languages produce programs that take a long time to start up. I would say that this argues against using them for small, interactive applications in which startup time is more of an issue. Of course, if you can precompile the program ahead of time to native code…

    Comment by Michael Stiber — 12/1/2006 @ 2:38

  5. Also, whether a language A is truly faster than a language B depends on the developer. In Python, for instance, there are several constructs for creating loops, such as list comprehension, the map function, the for loops, and I suppose a recursive function is also an alternative.

    But which of these provide the best performance (in the given situation)? The answer might not always be intuitive to the developer and hence, in reality, the result of benchmarking depends a great deal on the developer’s ability to avoid common pitfalls of the language.

    Comment by Ronnie — 14/1/2006 @ 20:17

  6. Daniel, you seem not to have noticed the Intel Pentium 4 measurements – we’re continually re-working the website and benchmarks, so take another look, Java might look faster to you now.
    http://shootout.alioth.debian.org/

    “the famous Intel C/C++ compiler is on par with GCC”
    The link seems to compare GNU C with Intel C++ wouldn’t it be more reasonable to compare GNU C with Intel C – or GNU C++ with Intel C++ ?

    “PHP and Ruby are slow”
    Slow at what? :-)
    http://shootout.alioth.debian.org/gp4/benchmark.php?test=regexdna&lang=all

    Do you recognise any of the authors of the Haskell programs?
    Now, do you recognise any of the authors of the Java programs?

    “Python is one of the fastest high level languages out there”
    Compare with Lua. Compare with Chicken Scheme. Compare with VisualWorks Smalltalk.
    Look at Psyco.

    Comment by Isaac Gouy — 23/1/2006 @ 18:43

  7. Daniel, you seem not to have noticed the Intel Pentium 4 measurements – we’re continually re-working the website and benchmarks, so take another look, Java might look faster to you now.
    ;
    http://shootout.alioth.debian.org/

    Thanks. Java looked fast, and it still looks fast. My problem is memory usage.

    “the famous Intel C/C++ compiler is on par with GCC”

    The link seems to compare GNU C with Intel C++ wouldn’t it be more reasonable to compare GNU C with Intel C – or GNU C++ with Intel C++ ?

    Fixed. It doesn’t change the analysis.

    “PHP and Ruby are slow”

    Slow at what? :-)

    http://shootout.alioth.debian.org/gp4/benchmark.php?test=regexdna&lang=all

    These benchmarks show Python doing very well compared to Ruby and PHP.

    Do you recognise any of the authors of the Haskell programs?

    Now, do you recognise any of the authors of the Java programs?

    Hmmm….

    “Python is one of the fastest high level languages out there”

    Compare with Lua. Compare with Chicken Scheme. Compare with VisualWorks Smalltalk.

    Yes. There are all interesting all level languages faster than Python.

    Look at Psyco.

    Psyco looks more like an experiment at this point.

    -Daniel

    Comment by Daniel Lemire — 23/1/2006 @ 20:54

  8. i like the analysis with the exception of highly unintelligable relative terms used in certain cases to distinguish this heirarchy of importance between languages. keep it science. performance is the topic in comparison, not relativistic personal bias.

    thanks again for the analysis, i got something out of it. :)

    Comment by anthony g — 23/5/2006 @ 8:54

Sorry, the comment form is closed at this time.

« Blog's main page

24 queries. 0.387 seconds. Valid XHTML

Powered by WordPress

Subscribe to this blog in a reader or by Email.