[Haskell-cafe] Optmiization of recursion
jcast at ou.edu
Mon Oct 4 10:33:56 EDT 2004
Fergus Henderson <fjh-mailbox-18 at galois.com> held forth:
> On 28-Sep-2004, John Goerzen <jgoerzen at complete.org> wrote:
> > As I'm investigating Haskell, it's occured to me that most of the
> > Haskell tutorials out there have omitted something that was quite
> > prominent in the OCaml material I had read: making functions properly
> > tail-recursive.
> > The OCaml compiler was able to optimize tail-recursive functions such
> > that they could be compiled using a loop. This would achieve two main
> > benefits: performance due to not needing to allocate/deallocate stack
> > frames, and the ability to work on very large lists since each recursive
> > call did not consume extra stack space.
> If analyzing the performance and space usage of your programs is
> important, then Haskell may not be the best choice of language.
I disagree. If performance and space usage are sufficiently important,
Haskell may not be best. But it's really not that much easier to
analyze performance or space usage under strict languages. In either
case, the golden rule is: profile. Reading the source code will tell
you very little.
p.s. Of course, I know that reading the source code tells you very
little about strict languages and nothing about lazy ones. But in both
cases it is overwhelmingly dominated by profiling.
More information about the Haskell-Cafe