loading...

re: Why is functional programming gaining popularity? VIEW POST

FULL DISCUSSION
 

I'm a functional programming convert because I've seen the benefits first-hand.

Professionally I've gone from C, to C++, to Java, to Scala and most recently to JavaScript. Typically over the lifetime of a project an ever increasing share of the engineering effort will be spent on maintaining the codebase and paying down technical debt, until adding new functionality grinds to a halt. However, one of the most complex projects I've worked on was in Scala, and it was virtually bug-free. As in, I could count the number of known bugs on one hand. In my experience, almost all bugs come from either 1) unintended side-effects, or 2) inconsistencies caused by duplication of state and data at runtime. By adopting side-effect free code and data immutability, you trade a bit of discipline and a new way of thinking for massively reduced complexity and increased reliability and testability.

I've come to realize you can apply functional programming principles in almost any language, even C, and modern JS is in fact a great language to do so in. As with all things, moderation is best and you don't have to buy into FP 100% to see the benefits of it. If you've done frontend JS before, just applying for example the principles of something like React+Redux (single source of truth, state is read only, state changes are through pure functions) you can easily see benefits in any moderately sized codebase.

code of conduct - report abuse