Wednesday, 30 December 2009

Java for Quants?

There was an lively debate on LinkedIn with respect of using Java for Quantitative work.
As usual, some people were quick at pointing out Java's “slowness” compared to C++.
Obviously, yours truly, tried to demystify that point.

Java is as fast and sometimes faster than C++. Do not believe me, try it out for yourself. Try Java 6, in server side mode with asynchronous garbage collection, the performance will be mind-blowing, or at least, if you were sceptical, will be unbelievable.
Try java -server +XX:UseConcMarkSweepGC with a program, develop the same one in C++ and compare the performance between the two.
Make sure you read this entry first.

My answer to Java for quants is not about the language but about the architecture and design.
It does make sense to write a quant lib in C/C++, why? Because of speed, no – because if speed is your concern, you'd go C/ASM or a hardware solution; because of ease of use with other systems: writing a .dll or .so allows your lib to be called from .NET, Java (via JNI), Excel, etc.

People are very sensitive about C++ vs. Java – what about trying it yourself and be objective?

Also, let's not talk about Java only, it is also and mainly about the VM, which supports many other languages, in particular Scala, OCAML, Jruby, ...

2 comments:

oogifu said...

BTW, just found http://www.gnu.org/software/gsl/ if you are interested

diprey said...

Here's a great post on Java vs C performance from an expert: http://blogs.azulsystems.com/cliff/2009/09/java-vs-c-performance-again.html

All being said, C/C++ may be faster than Java for some types of applications that are common in the quant world (such as numerics), e.g., thanks to the cache locality issue mentioned at the bottom.

Now let me turn the argument around... As an experienced user of both languages, I see few advantages in using Java over C++ for coding calculations/models.

Happy New Year!

Blog Archive