Sascha posted the distribution of programming languages in UnRisk yesterday. Use the language that fits best for purpose. The objective leads to hybrid programming - inevitably. Performance is one criterion.
A paper of the National Bureau of Economic Research
A paper of the National Bureau of Economic Research
We solve the stochastic neoclassical growth model, the workhorse of modern macroeconomics, using C++11, Fortran 2008, Java, Julia, Python, Matlab, Mathematica, and R. We implement the same algorithm, value function iteration with grid search, in each of the languages. We report the execution times of the codes in a Mac and in a Windows computer and comment on the strength and weakness of each language.This are their summarized results
C++ and Fortran are still considerably faster than any other alternative, although one needs to be careful with the choice of compiler
C++ compilers have advanced enough that, contrary to the situation in the 1990s and some folk wisdom, C++ code runs slightly faster (5-7 percent) than Fortran code.
Julia, with its just-in-time compiler, delivers outstanding performance. Execution speed is only between 2.64 and 2.70 times the execution speed of the best C++ compiler
Baseline Python was slow. Using the Pypy implementation, it runs around 44 times slower than in C++. Using the default CPython interpreter, the code runs between 155 and 269 times slower than in C++.
However, a relatively small rewriting of the code and the use of Numba (a just-in-time compiler for Python that uses decorators) dramatically improves Pythonís performance: the decorated code runs only between 1.57 and 1.62 times slower than the best C++ executable.
Matlab is between 9 to 11 times slower than the best C++ executable. When combined with Mex Öles, though, the di§erence is only 1.24 to 1.64 times.
R runs between 500 to 700 times slower than C++. If the code is compiled, the code is between 240 to 340 times slower.
Mathematica can deliver excellent speed, about four times slower than C++, but only after a considerable rewriting of the code to take advantage of the peculiarities of the language. The baseline version our algorithm in Mathematica is much slower, even after taking advantage of Mathematica compilation.This is the paper (I found googling).
Mathematica (Wolfram Language)? Based on a presentation of Sascha, I wrote this post about Idealism vs Realism in Programming.
Deciding for hybrid programming was a great choice. We were able to make blazingly fast engines, platform agnostic and widely accessible - with unbelievable low efforts.