It's less about imperative vs. functional languages and more about the restrictions of a language and how a compiler can use these to further optimize the code.
If you're looking at an optimization like fusion in Haskell, which can get rid of intermediate data structures, then this optimization is only possible because of the immutability and pureness guarantees.
GHC is still a quite amazing piece of compiler technology and shows where language restrictions might have an advantage in the case of opimizations.
I don't quite know how much of the instability of the fusion optimizations is about changes of GHC internals and how much they're a prinicipal and hard to solve problem.
4
u/dan00 Dec 27 '17
It's less about imperative vs. functional languages and more about the restrictions of a language and how a compiler can use these to further optimize the code.
If you're looking at an optimization like fusion in Haskell, which can get rid of intermediate data structures, then this optimization is only possible because of the immutability and pureness guarantees.