4 ms·
Wasn't the selling point of laziness performance? "It only does what is needed!" I didn't use Haskell but Nix and at least there it seemed reasonable to "not
by k__ 9y ago
Wasn't the selling point of laziness performance?
"It only does what is needed!"
I didn't use Haskell but Nix and at least there it seemed reasonable to "not do" everything.
- snovv_crash 9y agoIn other languages when the compiler misses an optimization you get a constant order penalty on a small piece of code. In Haskell when the compiler misses an optimization the performance hit is potentially unbounded, as it could think anything is a dependency. (You want the first N digits of pi? Just wait while I calculate all of them for you...)
- codygman 9y ago> You want the first N digits of pi? Just wait while I calculate all of them for you... I don't think that example cold actually happen, or at least I can't see how it would happen in Haskell.
- Tuna-Fish 9y agoHaskell can be made very fast. The problem is that at least for me, performance is often quite non-intuitive. As in, make tiny change to program, it is now a hundred times slower. Then you get to hunt down the reason why it's now doing too much work/ why stream fusion isn't working anymore/why it's leaking so much space/etc for hours. I enjoy writing Haskell for small hobby projects, but I doubt I would choose it for real work now that F# and Rust exist.
- tome 9y agoI 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.
- 9y ago