«« Next » « Previous
«« Next » « Previous

Link Details

Link 93396 thumbnail
User 264741 avatar

By dnene
via blog.dhananjaynene.com
Published: Jul 08 2008 / 11:53

Performance comparison for a small piece of logic across a number of languages. Some of the interesting findings (I emphasise - in this context) are : Java faster than C++, Java about a 100 times faster than Python / Ruby, JRuby faster than Ruby 1.9, Ruby 1.9 twice as fast as Python, Python / Ruby faster than Groovy, and PHP and Jython bringing up the rear.
  • 31
  • 8
  • 5260
  • 2624

Comments

Add your comment
User 107114 avatar

daniel replied ago:

2 votes Vote down Vote up Reply

Very interesting benchmark. One of the more interesting conclusions: Java is faster than C++...by a wide margin. Ruby, Groovy, Python and friends all get a showing as well. Worth the read.

User 276353 avatar

Umberto Zappia replied ago:

2 votes Vote down Vote up Reply

Would be nice to explain why some voted this down.

User 226498 avatar

alphadog replied ago:

0 votes Vote down Vote up Reply

Two reasons I voted down:

1. A "one-algorithm test" is hardly a way to compare language/compiler performance.
2. The end results don't jibe with my (semi-objective) reality that :

C++ > Java > (Python 2.5.1 ~ Groovy 1.6 ~ Ruby 1.9)

Meaning C++ is generally faster than Java, which is generally faster than the set of popular, dynamic languages.

Check out http://shootout.alioth.debian.org/gp4/index.php for a broader set of performance metrics than one piece of specific code.

User 264741 avatar

Dhananjay Nene replied ago:

1 votes Vote down Vote up Reply

alphadog,

I am just a little surprised - both your views are actually quite explicitly stated in the blog post (they are not even tucked into the fine print).

I believe there is indeed a case for one-algorithm tests to be blogged about.. something I am starting to suspect (though have no way to offer any additional supporting evidence or to reach a definitive conclusion)
a. In this case Java is faster than C++ because its garbage collector is outperforming the manual memory allocation in C++. Given that the code itself runs very fast in the two languages, the gc is suddenly important.
b. In this case Python is a little slower than ruby because its attribute access could be slower

Given the fact that I couldn't attach a high supporting evidence to these hypothesis, I chose to not very explicitly state it. But a post like this can still help people understand a little bit more within a specific context.

It is quite helpful when someone explains their votes. Thank you for your vote and comment.
Dhananjay

User 226498 avatar

alphadog replied ago:

0 votes Vote down Vote up Reply

You may be surprised, because often what one intends and what another perceives out of a blog post are not exactly the same.

I realize you may have intended to ensure that the above two observations of mine are in your blog, but the result is different. Those two important observations are in a "note" as an "aside".

You then go on, armed with bullet-points and bold letters which strikes the reader as "important" :), to say some over-generalizations that can easily be misconstrued, especially since they are based on a very focused, and probably unoptimized, set of code.

I totally realize I'm being picky, but that's why I voted down.

User 264741 avatar

Dhananjay Nene replied ago:

0 votes Vote down Vote up Reply

Understand you much more clearly now. I'll take that as a useful learning.

User 211643 avatar

zynasis replied ago:

0 votes Vote down Vote up Reply

nice work

User 95751 avatar

pt93903 replied ago:

0 votes Vote down Vote up Reply

Really appreciate the effort put into this.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.