Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> that would just be so much simpler and easier to read if it was a classic for-loop.

Only if that's how you were taught. For devs brought up in the FP manner, the for loop is as hard to grok as you find the chained stuff.

The Blub Paradox in action.



I have never, ever seen this. And I’ve worked next to some very FP-forward types and academic CS/abstract math background types who have vastly deeper knowledge of their fields than I ever will of mine.

Plenty of them don’t like imperative loops, sure. But I’ve never seen someone assert that a simple loop is not intelligible to them while chaining functions are.


If you're replacing a chain of filters and maps with a nested loop, you're far past "a simple loop" and well into the realm of an unintelligible for loop. The chain of maps and filters tends to make that far easier to read by decomposing it into separately-comprehensible pieces.


Oh totally agreed; for complex transformations, being able to compose and tap the intermediate states is really nice (though I quite like generator/yielding functions with captured stack state as a happy medium).

But that’s not the claim I was pushing back on. That claim was that, given a loop and some equivalent chained list-processing functions, primarily FP-taught people could not understand the loop due to their background. That’s bogus.

That complex loops are hard to understand for anyone is inarguable. But there’s not some magical “functional mindset” in which imperative/mutative code is unintelligible to the point of total obscurity and functional code is not. If there were, how would anything ever get rewritten in a functional style?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: