Preventing/handling space leaks
Sven.Panne at aedion.de
Sat Dec 6 16:21:00 EST 2003
> [...] it looks to me, that the problem of space leaks is a very good reason
> to not use Haskell for commercial applications. Java, for example, does not
> have this problem.
I just can't resist when I read PR statements like this (SUN's marketing department
has *really* done a good job): Granted, Haskell has problems with space leaks
from time to time, and it is especially easy for beginners to stumble over them,
see e.g. the recurring "foldl (+) 0 [1..1000000]"-discussions popping up regularly.
But for large realistic programs most programming languages converge and you basically
have the choice of what kind of space leak you want:
* C: Missing calls to free(), etc.
* C++: All of C's leaks + lots of hard to find space leaks due to incorrectly
handled exceptions + ...
* Haskell: Functions which are not strict enough, thunks which are never evaluated
but hold large data structures, etc.
* Java: Listeners which are not de-registered, containers which are not "nulled"
after removal of an element, badly written cache-like data structures, etc.
Note that I earn my living with JVMs and Java programs (some >1mio LOC), but every
project I worked for had problems with space leaks at some point. The advantage of
Haskell IMHO is that you normally get them very early... :-]
More information about the Haskell-Cafe