4 ms·
> This is moving the goalposts a bit. I don't think so. My original comment was focusing on stack overflow errors, but my wider thesis is this: By and large,
by dwohnitmok 6y ago
> This is moving the goalposts a bit.
I don't think so. My original comment was focusing on stack overflow errors, but my wider thesis is this:
By and large, strict languages trade off some level of syntactic convenience for easier, local reasoning about performance. And I am willing to accept that hit. So for example, yeah sure maybe you have to do a mechanical transformation of a recursive function to either use a trampoline or an explicit stack or rewrite with an iterative loop, but that's an acceptable trade-off for me.
Stated another way:
The cases where a lazy language can cause weird performance issues are harder to debug than the cases where a strict language can cause weird performance issues.
Indeed the fact that a library is all that is needed to patch up a lack of language primitives makes me more willing to accept the trade off of syntactic convenience.
index = zip [1..]
vs
index = Stream.zip (Stream.from 1)
or even conversions to and from lists if you really don't want streams elsewhere such as
index xs = Stream.toList . Stream.zip startIndex $ streamedXs
where
startIndex = Stream.from 1
streamedXs = Stream.fromList xs
is a sufficiently small price for me to pay to gain back local performance reasoning (I mean in this case I'd just write index with a fold to begin with in a strict language).
> interleaving effects with your streaming
But the issue that effects are supposed to be values in and of themselves (i.e. if I really take effects as a value seriously, why must my machinery change when I have a list of IO actions vs a list of integers?). This is really a symptom of the deeper issue is that there are a lot of things that should be strict for other reasons that can interfere with purely lazy lists or other structures because they basically represent this sort of weird interleaving of strict and lazy needs (this is why e.g. foldl' fails without strict data fields).