Michael wants his CPU cycles back! Anyhow, using some benchmarking, we can make comparisons between languages (or rather, some implementations). Here are some possible conclusions (using an AMD CPU which is what I own):
- Python is faster than Perl.
- Python is faster than Ruby by a wide margin.
- Python is much faster than PHP .
- C++ is faster than Lisp and uses much less memory and Lisp is much faster than Python but Lisp uses more memory.
- C++ is generally slightly faster than Java, but not always though Java uses a lot more memory.
- PHP and Ruby are pretty much on par but Ruby uses less memory.
- Lisp and Java are on par.
- Lisp is slightly faster than Haskell, but not always.
- C++ is faster than Haskell, but not always.
- Haskell and Java are pretty much on par, but Java uses much more memory.
- the famous Intel C/C++ compiler is on par with GCC (Parand points out the benchmarking involves AMD processors!).
- Ocaml is on par with C++.
- Ocaml is much faster than Haskell.
- Ocaml is better than Java.
- Ocaml is better than Lisp.
The lessons here are:
- Java is fast, as fast as C++ but its memory usage is worse than a language like Python.
- Python is one of the fastest high level languages out there, but Perl is close behind.
- PHP and Ruby are slow.
- Languages like Lisp, Ocaml and Haskell can sometimes be used as replacement for C++ even when performance is a concern.
- GCC is a good enough compiler.
Yes, I’m aware of the limitations of this analysis!!!