File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes C++ vs. Java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "C++ vs. Java" Watch "C++ vs. Java" New topic
Author

C++ vs. Java

paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 18130

anybody have some hot web pages comparing the speed of Java and C++?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'll post the link before I verify it has what you want, but the Language Shoot-out http://www.bagley.org/~doug/shootout/ has comparisons on multiple criteria (speed, memory usage etc) for many common alrorithms running comparable code written in different languages.
Dave


[ JavaRanch FAQ ][ Book Promotions ][ DbTamer ][ BumperStickers ][ JavaRanch Badges ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The Scorecard displays a score per language based on custom weightings. The default, which measures only the CPU section of the tests, rates C++ (via the g++ compiler) as 4th with a score of 743. Java was 9th with a score of 703.
I'll have to look into where these numbers come from.
It looks like a particularly good score for Java.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Java's performance isn't that bad compared to C++. Remember, the modern Hotspot Engine will compile critical parts of your code to native, too. The runtime optimizations might be even more effective than the static optimizations of a C++ compiler.
The biggest problem for *small* programs simply is the heavy startup time of the JVM...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ran Pleasant
Ranch Hand

Joined: Jan 16, 2003
Posts: 75
I've just completed a contract in which I built a prototype of a Java application that displays customer stock trading orders in real-time, data is received through a socket connection to a server. When compared to prototypes written in C++ and Delphi the Java application held up very good even though it had the slowest absolute speed (I do not have the numbers). For all three applications the bottle-neck was the network.
In another speed test, the Java prototype is fully completed - the C++ programmer still has plumbing to build. :roll:
[ January 17, 2003: Message edited by: Randall Pleasant ]

Ran
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Originally posted by Paul Wheaton:
anybody have some hot web pages comparing the speed of Java and C++?

It depends on what you are doing. Need to process huge byte arrays over and over again. C will kick butt over Java because C has no boundary checking (among other things). Of course, the C program is more likely to contain boundary errors. (A friend of mine had to do this for an image manipulation project he was working on. The Java program took about 4 weeks to run and the C program took about 4 days.)
You can write an extremely efficient program in C if you know what you are doing. But that kind of requirement isn't found in a typical business application.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Thomas Paul:
It depends on what you are doing. Need to process huge byte arrays over and over again. C will kick butt over Java because C has no boundary checking (among other things). Of course, the C program is more likely to contain boundary errors. (A friend of mine had to do this for an image manipulation project he was working on. The Java program took about 4 weeks to run and the C program took about 4 days.)

That's correct - most people still think that Java is slower because it is interpreted. In fact, when it's slower it's most often because of inbuild security checks other languages are missing.
Notice, though, that the modern Hotspot Engine is able to remove some of those checks (as array boundary checks), if its analysis shows that it can't happen.
 
 
subject: C++ vs. Java
 
Threads others viewed
CSharp and Java
Apply your Lateral Thinking
whts the out put
final & private together
why is 'unsigned' not supported in java
IntelliJ Java IDE