3 ms·
Personally I've found that although this argument sounds good in theory, in practice I don't find loops harder to read than chains of combinators.
by edflsafoiewq 7y ago
Personally I've found that although this argument sounds good in theory, in practice I don't find loops harder to read than chains of combinators.
- eru 7y agoWhich languages are you reading them in? For me the argument holds in practice as well. I'm mostly reading my combinators in Haskell, and the loops in Python or some curly brace language. If you use a general purpose combinator like mapAccumL that has almost as much power as a loop, you don't get that much extra readability compared to the loop. It's still a bit better, because that combinator still has to process one element of your list for each run through it's "body"; and it clearly warns you by it's very name that it's not just a filter or map, so there's less possibility of confusing it for something simpler. And, of course, not all loops are created equal. When applicable, for-each loops are much cleaner than classic C-style for-loops for example.