Which programming language is best?
A brief tour in well-known languages from the point of view of scientists and engineers
Thirty years ago, when I thought I was smarter than I really was, I used to laugh at Fortran. I thought it was a stupid language used by old people simply because they were incapable of learning new things. Guess what: Today, when I’m contemplating which language is best for a scientist or engineer, I wonder whether I should be recommending Fortran.
Here’s the problems some other languages have:
R. It’s slow.
Python. It’s slow.
Python + numpy (+ pandas). It’s fast provided you don’t use loops. If you write your program correctly you will rarely need a loop. But eventually you will need a loop. It’s going to be slow.
MATLAB. Same as Python + numpy (+ pandas).
Python + numpy (+ pandas) + Cython. Cython is a fast, compiled language that looks largely like Python. It’s the language in which numpy and pandas are written. You can program in Python + numpy (+ pandas), and in those rare cases where you need a loop you can write it in Cython. That’s a good idea, however I consider Cython to be a bit difficult.
C. It’s too low-level. It has too much emphasis on pointers. This is good for systems programming. A scientist/engineer shouldn’t need to deal with this stuff. It also lacks exceptions.
C++. I’m not certain, but I think it carries too much C with it.
Object Pascal (Delphi). It’s quite good, and I used it a lot in the 1990s, but its popularity waned and it’s slowly becoming obsolete.
Fortran has been here for more than 60 years, it is maintained with new versions coming out, and its strong legacy guarantees you will probably not need to learn another language after 20 years.
To be fair, I don’t speak Fortran, so I don’t know its shortcomings, and therefore I cannot recommend it responsibly. In addition, it’s not good for everything. The expressiveness of R probably makes it better if you want to write a few equations and see some graphs—it’s when you want to make a simulation that you need something faster.