DEV Community

Discussion on: Does functional programming have any advantage in real environments?

716green profile image
Bob Bass

I'm usually writing typescript and I opt to take inspiration from FP and opportunistically use pure functions or recursion when it makes sense but overall my style is very procedural.

I believe that procedural code with a functional influence is usually the most readable and self documenting, as well as easy to maintain code.

If I'm writing elixir or elm, I feel like my hands are tied and I need to do things in very unnatural and unintuitive ways, and I have trouble making sense of purely functional code after I spend a week away from the codebase.

Similarly, I share the same criticisms of OOP. It's okay to take influence from OOP like encapsulation or polymorphism, but a purely OO codebase is a nightmare to debug and figure out because everything becomes so fragmented and abstracted for the sake of abstraction instead of practicality. There no reason to nounify all of our verbs. OOP is only good if you know exactly what you're building and exactly how to get there but usually the things we build have constantly changing scopes.

If you're building something like Zapier, you probably want your code to be as functional as possible because you're forcing the end user through functional workflows and the paradigm is probably best represented in a functional style, but for the 99% of us building web, desktop, mobile, bor business CRUD applications, procedural with a functional influence is the most natural and intuitive way to write and manage our code.

Elixir is less frustrating than elm, but people would argue that elixir isn't a functional language on the pure sense of the word. Meanwhile, we all hate elm and Redux. Redux was modeled after Elm and elm is dead now. Redux is a nightmare to use compared to Vuex which is state management done correctly.

Languages become higher and higher level, well probably write more functional code in the future, but with the languages we have right now, it rarely makes sense as a developer to build out a purely functional codebase.