Hard academic analysis of Java vs. C++, providing actual benchmarks. What's the answer? Depends on what you are doing, sometimes a HotSpot Java compiler is faster than heavily optimized C++, sometimes it's not. Usually, it's close enough it doesn't matter really.
Comments
mezmo replied ago:
Why?
I know we all feel the need to beat the drum, but this report was issued in 2003, updated in 2004 and addresses JRE1.4.
I don't think anyone disputes that given some time java code will rip along with the best of just about anything. That isn't the issue. The issue is that when I start up an applet, or Eclipse, or whatever, I feel as though I've time to go get a cup of coffee whilst waiting for it to get to the point where I can do useful work. I know that JRE1.5 & 1.6 has supposedly made this all better, but I haven't noticed it yet, and I use java almost exclusively every day.
JMHO (for those that can't remember that far back it means Just My Honest Opinion, some say it should be Humble...but I'm not ;)
shemnon replied ago:
You'd be surprised how deeply ingrained the Java is Slow FUD is ingrained in some shops. Even if the data is 3-4 years old showing parity 3-4 years ago will help combat the FUD.
cossins replied ago:
Well, the thing is that Java *IS* slow in many cases. Especially startup time is unacceptable. Memory usage is also a very serious issue.
It appears these things have improved dramatically in 1.6, but I'm not too optimistic about it just yet. In my opinion, it's too late. Object-Oriented Programming is important, and Java does that very well, but it does just about every other development model extremely poorly (static members are just... awkward), and it seems people are moving towards more mixed modes (with Ruby, Python, C++ and D).
Java isn't dead, but it is dying. And it should be, it has been superseded by superior languages/frameworks.
- Simon
MattGiuca replied ago:
A very good article. Even if a lot of it is just "in theory Java should be faster" - it's good to know we'll get there - maybe not even with Java - but that it's possible for high-level memory-safe languages to be fast.
vvs replied ago:
C'mon, guys, this isn't even funny. The article is FOUR years long! There were two MAJOR updates to Java VM since then. The latest Java VM is much faster, more optimized, provides some ways to combat footprint and startup issues (shared class data), etc, etc.
evarlast replied ago:
Now do the same comparison in 8MB of memory. 4MB. 2MB. 1MB. 512K
These are still VERY real memory environments.
Lowell Heddings replied ago:
"faster than heavily optimized C++"
Java has come a long way, and is very fast, especially on the server side. It might sometimes be faster than normal C++ code. But there is no way it's faster than "heavily optimized" C++ code.
abhibeckert replied ago:
Which fanboy voted the parent down? I've seen heavily optimized C++ do stuff in 0.002 seconds that took at least 10 seconds in every other language we tried.
A Java program will never be able to compete with that kind of performance.
dmh2000 replied ago:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=gpp&lang2=java
g++ blows java -server away
jdh30 replied ago:
One of the main conclusions that can be drawn from my ray tracer language comparison:
http://www.ffconsultancy.com/languages/ray_tracer/index.html
is that Java is one of the slowest compiled languages out there, as slow as Lisp.
Moreover, I just finished repeating that benchmark on my new dual core AMD64 and Java is doing relatively worse than it was before. C++ and OCaml are now leading the pack.
Voters For This Link (20)
Voters Against This Link (0)