3 ms·
This article is describing something that is very true but in the end it doesn't teach you how to do FP in an otherwise imperative language. This is surprising
by crimsonalucard 9y ago
This article is describing something that is very true but in the end it doesn't teach you how to do FP in an otherwise imperative language. This is surprising as it's just one single devastatingly simple rule you need to follow in order to do functional programming:
After you declare and assign a value to a variable NEVER change it again. That's it. Immutability. Almost every other functional programming pattern flows naturally from this restriction.
People already know the definition of functional programming and that is a functional program is a program that consists of a single expression and that the complexity of this single expression arises from the fact that this expression is the composition of other smaller functions...
What they don't know is that if you take an imperative program and make every variable immutable and construct your program following this restriction the final result will be identical to a functional program! The two concepts are isomorphic!
Try it if you don't believe me.
- kwhitefoot 9y agoI do this for my own code but 20 years of persuasion has failed to convince any of my colleagues.