Stream: ideas

Topic: Lazy evaluation


view this post on Zulip J.Teeuwissen (Dec 06 2022 at 12:09):

(perhaps this has already been discussed, but I failed to find any answers)

Lazy evaluation is a common occurrence in Haskell. It allows for thunks to only be evaluated when necessary, and not when e.g. passed as parameter. This allows for structures like infinite lists, trees, or parsers (which afaik uses a custom lazyness function). And it could save on computations when only the WHNF of a function result is required.
I could see how it could be confusing to programmers from a non Haskell background, but it would mostly be a behind the scenes optimization, and in the most intrusive case could prevent things like stack overflows.

view this post on Zulip Folkert de Vries (Dec 06 2022 at 12:13):

I think in practice these benefits of haskell... don't work out. Richard can say more about NRI's experience with haskell in production

view this post on Zulip Folkert de Vries (Dec 06 2022 at 12:14):

for most programs, I don't think lazy evaluation has benefits, and it has many pitfalls

view this post on Zulip Folkert de Vries (Dec 06 2022 at 12:14):

not least of which for our case: you cannot do reference counting in a language with lazy evaluation

view this post on Zulip Folkert de Vries (Dec 06 2022 at 12:16):

and consider, after haskell and some others in the mid 90s, lazy evaluation just hasn't been picked up by subsequent (research) languages: Idris, Elm, Lean, Koka are all explicitly strict, even though their authors are very familiar with haskell and lazy evaluation

view this post on Zulip Folkert de Vries (Dec 06 2022 at 12:16):

all too familiar, I'd say

view this post on Zulip Richard Feldman (Dec 06 2022 at 12:24):

yeah I think that short version is that Miranda and especially Haskell explored the space and revealed that it didn't live up to expectations in practice.

e.g. SPJ has said (maybe it was in "Escape from the Ivory Tower?") that:

view this post on Zulip J.Teeuwissen (Dec 06 2022 at 12:32):

Good to know, one less thing to remember.
It's funny how Roc does away with concepts (like laziness) that in my mind are an intrinsic part of FP. (and rightfully so)

view this post on Zulip Kevin Gillette (Dec 06 2022 at 15:31):

iirc, Idris has opt-in lazy semantics available, but is eagerly evaluated by default?

There were certainly notorious cases in Haskell in which the overhead of thunks dominated processing time.

It seems like, with more modern compiler technology, if anyone were to try making a lazy language again, much of it should be optimized into eager evaluation anyways, using something like flow analysis and cost estimation.


Last updated: Jun 16 2026 at 16:19 UTC