Remix.run Logo
johnnyjeans 4 hours ago

You could just use a for-statement, you know. I feel like there's a reactionary avoidance to iteration to the point that it doesn't really make sense.

I feel like we've jumped out of the frying pan of the 90s' OOP craze, directly into the fire of doing the same cargo cult behavior with functional programming. Always avoid loops, always use higher-order functions. It just makes sense. If you are not provided with the shotgun spread of higher-order functions out of the box, be frustrated.

I vaguely recall reactions to Haskell in the late 90s where vitriol was spewed over the lack of inheritance and classes.

coin 4 hours ago | parent | next [-]

Loops are just clutter. I’d rather concentrate on the filter and transform and not be bothered with the raw mechanics of looping, creating an intermediate array and appending to it. Not to mention that some languages returns a lazy evaluated view of the original storage.

RadiozRadioz 4 hours ago | parent | prev [-]

In my particular example, these were of course deliberately simple snippets to illustrate the point. The power comes in chaining these things, .map.filter.reduce... . Using iteration, you end up writing a lot of boilerplate that is much harder to parallelise, and extremely difficult to lazily evaluate. Without these constructs, to express "the concept of filtering & reducing an array", the reader of your program needs to read how you implemented those things, in addition to what you're using them for. You can do that stuff yourself in goroutines, but there is no contest to having native support for these extremely common operations.