Why There is no FP Language Fast As C++

I think Haskell and OCaml are pretty much up there on the faster languages pool. Given the same amount of time to work on a same problem with C++, Haskell, and OCaml, the performance would be roughly the same, since they all compile down to native code (no VM, runtime, etc.). Of course, given more time, the C++ code would be able to be optimized through low-level constructs, while Haskell and OCaml would suffer from garbage collection (whether it’s significant I don’t really know).

Also, I think the procedural nature of computers also gives the benefit of easier mapping from C and C++ instructions to machine code, while Haskell and OCaml’s compiler need to do the extra work of mapping the two different world of representation.

Having said that, I can argue that OCaml’s compilation time is blazingly fast, while I have heard (and in case of Haskell, experienced) scary stories about C++ and Haskell compilation times.

I also don’t think recursion have anything to do with it; tail calls are reduced to loops so there’s no overhead there.

(This was all from my understanding and I may very well be mistaken at some points.)

3 Likes