by tilt on 10/20/22, 7:54 PM with 26 comments
by z9znz on 10/21/22, 2:54 PM
For some it means chaining collection operations so "one line of code" solves an entire problem. This is not unlike the regexp wizard who can perform miracles with a regular expression which is incomprehensible to most other developers.
The above is what turns many people off from FP. As another commenter said, "what's wrong with a loop"? Indeed, accessibility matters; and if your team and new arrivals are not in that mindset, it's like a new language; and they already know a "language" and believe they are getting work done. Why complicate things?
I don't believe real FP is about doing these super concise expressions which can take considerable time to comprehend. I think FP is really more about pushing effects and mutations to edges, purifying (and simplifying) intermediate steps/functions, and using simple data structures.
The huge selling point of this kind of FP is in testability. When 90% of your code is pure and operates on simple data structures, testing each function is a breeze. No more do you need layers of setup and mocking. You don't even need full objects. If you're testing for a valid phone number in a person "record", you need only pass in a person: { phone: '12343241' }. All the rest of the crap which you would normally have to deal with, just to test this one thing, evaporates.
It does mean you end up with a LOT more functions. Then code organization and naming becomes a more significant challenge. But the end result, I believe, is still very much worth it.
And from my two recent experiences bringing this approach to OOP teams, I have found that after a brief period of fear and uncertainty, they end up adopting it enthusiastically.
by bern4444 on 10/21/22, 2:55 AM
Similar to TDD or Domain Driven Design (DDD) we should aim to write code that is easy to debug. Store intermediate values in a pipeline in variables, store predicates in a variable with a human readable name, and avoid in lining complex function calls.
There are other techniques that serve this purpose and additional reasons than what this article explores of how or why this is helpful.
by stevenalowe on 10/21/22, 2:48 AM
by phibz on 10/21/22, 5:20 AM
Use your own time or projects foe exploring programming styles.
by acadapter on 10/21/22, 10:46 AM
This is valid criticism in many cases. Code has two interfaces - the compiler and humans.
by skelet on 10/21/22, 10:04 AM
by tabtab on 10/27/22, 6:50 PM
https://www.reddit.com/r/DilbertProgramming/comments/qg99f0/...
by fulafel on 10/21/22, 5:44 AM
by legerdemain on 10/21/22, 2:18 AM
by animitronix on 10/21/22, 1:01 PM
by Firfi on 10/22/22, 7:58 AM