Functional programming (FP) has been a somewhat hot topic in recent years in my surroundings. Although in my close surroundings people are usually not zealous or overly excited, I do notice sometimes talks, discussions and vocally expressed opinions where tremendous benefits of FP over other paradigms are claimed, through presenting FP as a fundamentally new approach to writing code, opposite to, say, OOP. Some go as far as saying, that one must fully ditch OOP and all related experience because it’s all just a mistake.
Such extreme claims are rarely challenged. When a person with an OOP background gets involved in any FP-related discussion, it quickly gets overwhelmed with new unfamiliar vocabulary: algebras, monads, semigroups, functors, type classes… And I start questioning intents of those claims — are they made to make people shift to FP, or to prove, that some definition of FP is better than some definition of OOP?
With this post, I hope to show that FP can be seen as an evolutionary step, a generalization over practices we already consider the best in OOP paradigm. And if viewed like this, it can be useful even when adopted gradually. I hope this point of view will persuade programmers to look into FP and to borrow new techniques from it to improve non-FP code.