Serving the Quantitative Finance Community

 
User avatar
audetto
Topic Author
Posts: 0
Joined: March 12th, 2002, 4:08 pm

performances of Java & C++

October 17th, 2003, 6:23 am

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
 
User avatar
onlysimon2
Posts: 0
Joined: April 9th, 2003, 2:20 pm

performances of Java & C++

October 17th, 2003, 7:39 am

 
User avatar
DrBen
Posts: 7
Joined: February 8th, 2003, 1:24 pm

performances of Java & C++

October 17th, 2003, 8:13 am

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.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

performances of Java & C++

October 17th, 2003, 8:39 am

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.
 
User avatar
kc11415
Posts: 72
Joined: March 16th, 2003, 10:02 pm
Location: Indiana, USA

performances of Java & C++

October 17th, 2003, 6:43 pm

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.
All standard disclaimers apply, and then some.
 
User avatar
samudra
Posts: 0
Joined: December 23rd, 2002, 2:48 pm

performances of Java & C++

October 17th, 2003, 7:30 pm

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.