News for hackers. Stuff that matters.
Re:What If the Team Hates My Functional Code? by skelet on Friday October 21, 2022 @06:04AM (#33286386)
I'll never understand the fear some developers have of the for loop.
Re:What If the Team Hates My Functional Code? by pipingdog on Friday October 21, 2022 @10:23AM (#33288272)
That there's nothing to stop another developer from coming along and putting another for loop inside it.
Re:What If the Team Hates My Functional Code? by WorldMaker on Friday October 21, 2022 @03:07PM (#33291873)
I don't think Functional Programmers have a fear of for-loops, I think they love for-loops, they just prefer to define them "steps first".

A silly cross-paradigm way to look at it is that a lot of functional programming is about "dependency injecting the for-loop" and "inversion of control of the for-loop". For similar reasons to dependency injection in OOP, functional programming wants to focus on the more interesting to the program abstractions up front and leave the final "for-loop wiring" to libraries or the language itself.

The for-loops don't go away, they are still there as necessary wiring. The functional programmer just wants to "dependency inject" all the interesting piece-at-a-time steps inside that for-loop rather than worry about the entire final wired loop body. Just like dependency injection in OO is supposed to make it possible to deal with a class at a time without needing as much of the entire class diagram in your head all once. Also, just like dependency injection: it's designed so that you have a lot smaller, easier to test pieces that make up the whole.

Re:What If the Team Hates My Functional Code? by Firfi on Saturday October 22, 2022 @06:12AM (#33296948)
"Fear" could be a wrong word here. I think there's contempt involved instead. Which isn't justified either though. Everything is a tool, and should be used in a right context. I.e. for loops can be better justified sometimes (I find them useful around 1% of cases, but when they are they do their job well)