Tue 29 Aug 2006
Oh I did laugh when I read Uncle Bob’s post on the speed comparisions between Java, C++ and Ruby. I still hear the mutterings from C++ guys saying that Java is soooo slooowww. I also hear it from Windows programmers on the VB.NET platform. Sigh! I put it down to ignorance the wilful neglect to open ones eyes and smell the coffee…
Although Ruby brought up the rear, by some way, that’s the way things start. Walk before you can run and all that. It will get better but just looking at the code snippets, there was only one clear winner there. Well done Ruby…
August 29th, 2006 at 3:39 pm
I think it’s not completely unjustified. I’ve done some job in Java and my conclusion was similar, but I think I can justify it to a degree.
People blame Java for Swing.
And although the code speed generally relies heavily on the used algorithms and structures (and I have to admit the java code is usually well written in those terms), one cannot deny that Java is a byte-code running in a virtual environment which inevitably applies speed penalty. Garbage collector although making it simpler to manage memory adds to the penalty as well.
While .Net is not all that much better since it has a great number of similar concepts, although I like to think MS has taken the lesson from Swing’s inability to not annoy users and the .Net MSIL is pre-compiled on every execution ans it uses a lot of hardware support in terms of internal P-invokes and using native API’s for many tasks. Although the compilation may be causing a delay on the application startup, it however is resulting in a faster execution and apps generally appearing peppier than their Java counterparts.
Saying that Java is slow is a mistake, it has its appliances, I just don’t find it a best language for Desktop applications, probably not because of its speed as a languabe but mostly because of the framework’s way of doing the GUI and its strong separation from the host OS.
August 31st, 2006 at 1:16 pm
I have always assumed that Java is slower than C++. I got an insight into how much slower a year or so ago. I had an AI assignment to complete which required 5 million iterations of an activitation propergation algorithm. My lab mate laughed when I suggested writing it in Java. He wrote it in C. I timed his code, dropped it into Java with only syntactic modification, ran it and compared the results.
Turns out Java was only 2% slower.
My experience with Ruby (which I *love*) is that it’s significantly slower than Java. I’ve got no figures to support this though.
September 1st, 2006 at 1:03 pm
Java will still compile the byte code to machine language after a few thousands of iteration, which may be the case in many situation like the one you encountered.
I don’t find synthetic tests like that to be too reliable, it’s why we no longer use much of Dhrystones and Whetstones or MIPS to measure the speed of a computer.
My experience is just that java belongs to server just fine, servers don’t tend to use the parts of the framework which I was refering to they run their process for an extended period of time.
Desktop apps however tend to be restarted after much shorter periods of time which does not allow java to benefit from the after-number-of-iterations-compilation all that much.