This post originated from an RSS feed registered with Java Buzz
by James Gosling.
Original Post: Java Urban Performance Legends
Feed Title: James Gosling: on the Java road...
Feed URL: /jag/feed/entries/rss?cat=%2FJava
Feed Description: I've been inescapably tagged as "the Java guy", despite the fact that I havn't worked in the Java product organization for a couple of years (I do still kibbitz). These days I work at Sun's research lab about two thirds of the time, and do customer visits and talks the other third. For more detail...
There's a great thread on Slashdot titled Java
Urban Performance Legends. It's mostly thrashing out urban performance
legends in garbage collection, but you can find them all over the place.
Modern Java VMs really are quite fast, often beating C and C++ in all
sorts of benchmarks. Another common urban performance legend is that "Java
must be slow because there's no way to turn off subscript checking": this
one is completely false because all modern JVMs have optimizers that do a
great job of eliminating subscript checking.
There was a funny incident at a recent developer event where some folks
had a booth where they where demo-ing a high end industrial strength C
compiler and had a benchmark that they had transliterated into Java.
They were comparing their compiler to GCC and Java. GCC was running at
about 2/3 the performance of this high end compiler; the Java version
was running at about 2/3 the performance of the GCC version. Folks were
gathered around the booth and someone noticed that the script they were
using to run the Java version didn't have optimisation turned on. A few
seconds with vi to add the "-server" switch and Java's performance
jumped up to match the fancy C compiler. This got the pro-GCC crowd all
excited, so a bunch of them started fiddling with its command line
switches. They got a bit of improvement, but not much (the original
selection had been pretty good).
The one place where Java does have a legitimate remaining performance
issue is startup time. But these days it's down small enough to where
anything that runs more than a few seconds has a hard time noticing it.
Most startup time in modern Java apps goes to the app itself, not the VM.