[Haskell-cafe] Re: does the compiler optimize repeated calls?
ndmitchell at gmail.com
Wed Sep 6 10:43:38 EDT 2006
> All the optimizations that are supposedly made possible by having
> a pure functional language tend to be either not quite doable (because of
> non-termination making the language a bit less pure) or simply too hard: the
> difficulty being to decide when/where the optimization is indeed going to
> improve performance rather than worsen it.
There are an absolute ton of optimisations that aren't possible in a
non-pure language. In a strict language for example, inlining is not
allowed, while in a lazy language its always valid. I suggest you take
a look at GRIN.
> It's much too difficult for a compiler to figure out which functions might
> benefit from memoization (and with which specific form of memoization).
> Especially compared with how easy it is for the programmer to do the
> memoization explicitly.
The reason is probably more that the number of functions which benefit
from memoization is probably pretty low. And the number where it
harms the performance is probably pretty high.
More information about the Haskell-Cafe