3 ms·
Everyone is smart enough to write Haskell. Almost no one is smart enough to read Haskell. There is a reason loops are easier to read and maintain compared t
by fooker 7y ago
Everyone is smart enough to write Haskell.
Almost no one is smart enough to read Haskell.
There is a reason loops are easier to read and maintain compared to a fold(map(filter(zip(...)))).
- graphpapa 7y agoI dunno. I like that style, makes more sense to me.
- IceDane 7y agoOkay - so what is that reason?
- deleted 7y ago[deleted]
- tome 7y ago> There is a reason loops are easier to read and maintain compared to a fold(map(filter(zip(...)))). Absolutely not, and I read and maintain loops in both Python and Haskell!
- mjn 7y agoEven in Python I find the vaguely more functional style of list comprehensions easier to read than explicit loops. I've taught enough classes to know that many students who've had only a CS-101 type class do prefer explicit for loops that accumulate a result rather than list comprehensions, though. Seems like any statements about clarity (in either direction) have to include a fairly big caveat about who the audience is.
- fooker 7y agoNice that you mention Python. The creater of Python echoes my points: http://lambda-the-ultimate.org/node/587 http://lambda-the-ultimate.org/node/587
- tome 7y agoOh, I know. I use Python more by necessity than choice and it's only made bearable by features that Guido doesn't want to be there! If only it had tail call optimisation, multi-line lambdas and other features that Guido doesn't want. Then it might be even more than bearable.
- kccqzy 7y agoThat's your opinion. And one that's not terribly well-informed. I find complicated loops difficult to read. Multiple things (besides the loop induction variable) are being mutated. I had to manually pattern-match whatever is in the loop back into well-known operations like fold and map and filter. And I can easily cut and paste portions of that expression into a REPL to see what it's doing. Long before Haskell became as mainstream as it is now, C++ people have discovered the benefits of STL algorithms over raw loops.
- pwm 7y agoTo give you a counter example: when i write code in an imperative language i always first write the logic out as fold/map/filter and then translate that into an imperative loop.
- fooker 7y agoThat's not a counter example. I stated map/fold/filter is difficult to read. You said they are easier to write. These are not opposite, and I happen to agree with you.
- pwm 7y agoFair comment. I do find reading it much easier as well, which I guess boils down to familiarity, but when reading i don’t need to translate it hence my comment re writing.
- sullyj3 7y agowell, it'd be more like (fold op . map f . filter p . zip) l1 l2 Which I think is very understandable as long as you're familiar with what all of them do. Which you become, very quickly.