4 ms·
I don't think anything is the unique selling point of laziness. Wikipedia[1] says "The benefits of lazy evaluation include: * The ability to define control fl
by tome 9y ago
I don't think anything is the unique selling point of laziness. Wikipedia[1] says "The benefits of lazy evaluation include:
* The ability to define control flow (structures) as abstractions instead of primitives.
* The ability to define potentially infinite data structures. This allows for more straightforward implementation of some algorithms.
* Performance increases by avoiding needless calculations, and error conditions in evaluating compound expressions."
In my several-year experience as a professional Haskell developer the first and second points are at least an order of magnitude more important than the third.
[1] https://en.wikipedia.org/wiki/Lazy_evaluation https://en.wikipedia.org/wiki/Lazy_evaluation
- k__ 9y ago"the first and second points are at least an order of magnitude more important than the third." No offense, but 'performance is not as important as...' is what basically all pro-FP devs say for years, still it seems that the rest of the world thinks exactly the opposite.
- dllthomas 9y agoOn the contrary, the rest of the world seems to think "the performance gains given by laziness" aren't worthwhile at all. It's true that there are also performance costs associated with laziness, but those weren't under discussion.
- tome 9y agoYou've completely missed the point. I make no claim about the importance of performance. My claim is that the performance gains brought by lazy evaluation are far less important than the other gains it brings (because the performance gains it brings are rather small).
- tikhonj 9y agoIt's hard to believe that a world where Ruby, Python and Node are massively popular cares about performance above expressiveness. Even Java became popular first and fast afterwards—not even talking about memory efficiency! I'd agree that a lot of developers still over-index on performance though, probably because it's sexy and easy to measure.
- falcolas 9y ago> I'd agree that a lot of developers still over-index on performance though, probably because it's sexy and easy to measure. To keep producing responsive compute programs as the complexity of those programs continues to rise while the single-core CPU performance remains steady, program performance must become more and more important.
- Symmetry 9y agoAlso in some cases laziness creates loop fusion between chained functions for much better cache locality.