It seems like there are plenty of examples of clever things being done in a lazily-evaluated language that can't be done in an environment with strict evaluation. For example infinite lists in Haskell or replacing every element in a tree with the tree's minimum value in one pass.
Are there any examples of clever things being done in a strictly-evaluated language that can't easily be done in a lazily-evaluated language?
The main things you can do easily in an eager (strict) language and not in a lazy language:
Predict from the source code the time and space costs of your programs
Permit side effects, including constant-time update of mutable arrays, which makes it easier to implement some algorithms fast
In my opinion, the major benefit of an eager language is that it's much easier to get your code to perform the way you want, and there are very few performance traps in which a small change in the code leads to a huge change in performance.
Having said that, on the whole I prefer to write complicated things in Haskell.
No; there are some things you can do* with lazy evaluation (AKA normal-order reduction, or left-outermost reduction) that you can't do with strict evaluation, but not the other way around.
The reason for this is that lazy evaluation is in some way the ‘most general’ way to evaluate, which is known as:
The Computational Adequacy Theorem: If some order of evaluation terminates and produces a particular result, then lazy evaluation will also terminate and produce the same result.
* (please note that we are not talking about Turing-equivalence here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With