And yet the current crop of benchmarks consistently place Java runtime
speed in the same ballpark as C++ programs.
Jake2 achieves pretty high frame rates, and that's with Java graphics
which always are going to be slower, just not by nearly as much as
people suppose.
When it comes to CPU computations and other operations typical of many
application mixes we find Java systems equaling or exceeding the
performance of statically-compiled languages. This is in part because
of garbage collection - C++ programs have been measured as spending
25-30% of their execution profile in allocation and deallocation.
Java's techniques are much faster than most C++ allocation strategies.
<
http://www.ibm.com/developerworks/java/library/j-jtp09275.html?S_TACT=105AGX02&S_CMP=EDU>
<
http://www-128.ibm.com/developerworks/library/j-jtp01274.html>
<
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html>
The age of these articles points to how long the urban legend of Java's
supposed slowness has been debunked.
JVMs for Java 5 and 6 are far ahead of earlier versions for performance.
<
http://java.sun.com/performance/reference/whitepapers/6_performance.html>
Here's a recent link that favors C++:
<
http://bruscy.multicon.pl/pages/przemek/java_not_really_faster_than_cpp.html>
Notice that here the performance gap is much lower than people suppose -
about 2.5:1 overall. And that included JVM load time!
This is a bit of an unfair advantage to C++. No one denies that Java
takes a while to load, and its optimization profile is run-time tuned,
not static. That means you don't get optimal performance from a Java
program until it's been running for a while. We have to make sure that
we aren't saying a sprinter is a better runner than a marathoner because
our test race is 100 meters long.
We can say it's better to put the sprinter in the dash and the
marathoner in the long-distance race.
When benchmarks compare longer-running processes like server systems, we
find that Java actually outperforms C++.
Even so, there's a need to consider results like:
<
http://blogs.sun.com/dagastine/entry/sun_java_is_faster_than>
(linked via
<
http://blogs.sun.com/teera/entry/java_performance_benchmark_roundup>
)
Remember, too, that we're talking about large-scale systems, for many
Java shops. There is an awful lot of multi-processing, multi-threading,
inter-process communication (IPC), XML, security and certificates and
stuff like that going on. Such systems typically measure performance as
throughput and uptime.