3 ms·
map/filter and sum types are not about "fun", they're about correctness and expressiveness. map/filter and their equivalent loops are both perfectly readable,
by kevinmgranger 6y ago
map/filter and sum types are not about "fun", they're about correctness and expressiveness.
map/filter and their equivalent loops are both perfectly readable, but the latter involves more boilerplate.
- hrez 6y agoI'd settle for comprehensions. It already has generic for/range so why not. That would cover a lot of boilerplate annoyances.
- somethingwitty1 6y agoAnd I'd disagree. Numerous engineers of differing skill levels (what I deal with day to day), struggle significantly when map/filter are added into the mix. And we may say "get better engineers", but we don't have that ability. We have to write code that is maintainable for the engineers we have and can get (and the ones coming in the future).
- Guthur 6y agoCome on, map and filter difficult? That's hyperbole of the highest order.
- ecnahc515 6y agoNot really. They require a basic understanding of higher order functions and often heavily use closures. Those moderately advanced concepts. It’s also sometimes harder to write efficiently to avoid multiple iterations over the same collection. I think many many people are way more comfortable with loops than people are with map/filter.