• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

C++ vs. Java

 
Trailboss
Posts: 23377
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody have some hot web pages comparing the speed of Java and C++?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic