Search code examples
c++programming-languagesperformance

Languages faster than C++


It is said that Blitz++ provides near-Fortran performance.

Does Fortran actually tend to be faster than regular C++ for equivalent tasks?

What about other HL languages of exceptional runtime performance? I've heard of a few languages suprassing C++ for certain tasks... Objective Caml, Java, D...

I guess GC can make much code faster, because it removes the need for excessive copying around the stack? (assuming the code is not written for performance)

I am asking out of curiosity -- I always assumed C++ is pretty much unbeatable barring expert ASM coding.


Solution

  • Fortran is faster and almost always better than C++ for purely numerical code. There are many reasons why Fortran is faster. It is the oldest compiled language (a lot of knowledge in optimizing compilers). It is still THE language for numerical computations, so many compiler vendors make a living of selling optimized compilers. There are also other, more technical reasons. Fortran (well, at least Fortran77) does not have pointers, and thus, does not have the aliasing problems, which plague the C/C++ languages in that domain. Many high performance libraries are still coded in Fortran, with a long (> 30 years) history. Neither C or C++ have any good array constructs (C is too low level, C++ has as many array libraries as compilers on the planet, which are all incompatible with each other, thus preventing a pool of well tested, fast code).