A Comparison of Programming Languages in Economics [pdf]
economics.sas.upenn.edu
economics.sas.upenn.edu
The importance of raw computing speed of a programming language pales in comparison with the importance of the applied methods, as well as the time saved in development. For example, while a speed-up by a factor of two sounds good on paper, the choice of search strategy in a constrained optimization problem can change the running time by several orders of magnitude. I am currently working on a model where the seemingly unimportant choice of price normalization (i.e. which price in the model is set to 1.0 to determine the price level) can make a difference between 2 seconds or 200 seconds of computation time.
For this kind of algorithm, basically working with arrays of doubles, java should be within 20% of c++ and normally it is just as fast.
Java starts to seriously lags behind C++ when you need good control over the memory layout of your data. In java you can't have an array of objects, you get an array with references to objects. There are no elegant ways to solve that problem, the language just lacks the proper tools to do it elegantly. Memory layout is of course vital for cache efficiency, so that can give C & C++ a big advantage over java. Since this benchmarks uses arrays of doubles, this isn't an issue.
Please show that it takes 1 whole second (measured after the Java program starts and before it terminates) for the JVM to profile and compile the 100 lines of code.
That would suggest the JVM was pure junk.
Here are 10 cold-run times reported by their program:
Elapsed time is 3.122233018 seconds.
Elapsed time is 2.970587912 seconds.
Elapsed time is 3.110304658 seconds.
Elapsed time is 2.886701204 seconds.
Elapsed time is 2.966404493 seconds.
Elapsed time is 2.905329605 seconds.
Elapsed time is 2.968715703 seconds.
Elapsed time is 2.922929706 seconds.
Elapsed time is 2.906730019 seconds.
Elapsed time is 2.919119506 seconds.
Here are the stats reported by JMH after 200 samples: Result : 2.950 ±(99.9%) 0.015 s/op
Statistics: (min, avg, max) = (2.932, 2.950, 2.984), stdev = 0.017
Confidence interval (99.9%): [2.935, 2.965]The problem is that their Java program is just a single static method.
Their Java program is not written as Java.
Lots of discussion from a year ago.
I'm often surprised though; a naive implementation of wavelets in J was quite comparable in runtime performance to a naive implementation of wavelets in C.
Can someone explain this?
I am not sure if they meant that thought, in my opinion this is an advantage of Java.