Page 1 of 1
performances of Java & C++
Posted: October 17th, 2003, 6:23 am
by audetto
I would like to start a quantitative project in Java and I'm wondering if it is worth to.The problem is that I've often heard about a dramatic difference in performances between Java and C++ but I've never tested it.As I'm going to write some MonteCarlo code and PDE schemes, I think that speed will be a very important issue.Does anybody have a raught idea about that problem? is C++ twice as apeed as java? maybe it depends on the compiler and the JIT compiler. I will start with standard Sun javac compiler.thanksciao
performances of Java & C++
Posted: October 17th, 2003, 7:39 am
by onlysimon2
performances of Java & C++
Posted: October 17th, 2003, 8:13 am
by DrBen
Since J2EE and .NET scale and boxes are cheaper than programmers. You could code inJava or C#, and just buy more boxes if you want more performance.The reason people use Java/C# over C++. is the same reason people started using C (then C++)over assembler,. Though C++ will never match optimized assembler for performance it isalot more user friendly.
performances of Java & C++
Posted: October 17th, 2003, 8:39 am
by DominicConnor
DrBen is right. You only get more than a factor of two by good choice of programming language. That sounds a lot, but it is rarely enough to turn a frog into a prince.His point about productivity is just as valid for performance.Optimisation is a time consuming process, thus the speed of the code turns out to be a function of the productivity of the programming system more than the generated code.Most optimisation is to pinpoint bottlenecks and fiddle with them until performance is acceptable, or you buy a bigger box, or get fired.
performances of Java & C++
Posted: October 17th, 2003, 6:43 pm
by kc11415
Brian Kernighan, the K in "K&R", did a language comparison in 1998, including C, Java 1.1, Perl, VB, and others:Timing Trials, or, the Trials of Timing: Experiments with Scripting and User-Interface Languages
http://cm.bell-labs.com/cm/cs/who/bwk/i ... ap.htmlThe results are a bit dated, but take it for what it's worth.
performances of Java & C++
Posted: October 17th, 2003, 7:30 pm
by samudra
Java has matured to a big extent. If you are purely concerned withspeed the best approach is to use C. The overhead of polymorhismin C++ ( virtual function table ) can be significant.C++ is faster than java in certain areas. But if you can effectively use J2EEyou can spawn mutliple threads thereby speeding up significantly. You can also writemultithreaded C++ code but that will be much difficult to write and maintain.The areas where it is better to use Java over C++ is1. Network related, middleware code.2. Multithreaded code.3. Distributed or internet computing.You can also write or use C/C++ or library for components where speed maybe critical and call it from java using JNI.As Dr Ben says speed is no more an issue given the boxes are so cheap. My code for a real time system is used everday by atleast half to 1 million userswith nearly zero downtime and very high throughput. The full thing is written in java.Whenever the number of subscriber increases (and it increases everyday) we augmentit by buying boxes. Now a days we have very good load balancing switches so highthroughput is no more an issue. The bigger issue now a day is ease of maintainence and cost reduction by reducingnumber of programmers. J2EE and .NET helps here.