Re: java versus C or C++ for number crunching
johnmortal.forums@gmail.com wrote:
This is the sort of question that I hope won't start an unhappy
discussion, but I wanted to know whether there are any well accepted
tests comparing java to C++ (or C) for doing extensive number
crunching (e.g. multiplying 100,000 vectors in three space by various
matrics, and maybe even a lot of trig used to generate those matrices,
so lots of addition and multiplication). I am using C++ for a number
crunching intensive project because I have been so insistently
informed that Java is slow at number crunching and because a discrete
fast fourier procedure I wrote really did seem surprisely slow in Java
(but hey, maybe thats my fault, though I did use the fast version of
the transform). But if Java is not really lagging on number crunching
I would love to switch as I like Java so much. I could write my own
little test program easily enough, but everytime someone posts that
they have done so it seems like there are a lot of explanations posted
about why whatever they wrote is a bad test. Are there any accepted
"good tests" on number crunching that have been run recently?
I am not aware of any general accepted tests.
In fact I doubt that it is possible to create such a test, because
what is a good test depends on the problem that needs to be solved.
Forget all the crap from mid-90's about Java being interpreted
and slow etc..
The JIT compiler used in modern JVM's are quite good.
That said, then I would still expect C/C++ to be slightly faster than
Java for your usage. Java checks array indexes - C/C++ does not. And
in general I doubt that sufficient time has been spent optimizing
floating point i JVM's. Floating point is not a big usage area
for Java. Fortran and C still dominates that area.
Whether you will be willing to spend time to track down various
memory overwrites and memory leaks in C/C++ to gain let us guess 10-20%
in performance is something you will have to decide on.
Arne