DEV Community

Jess Lee
Jess Lee Subscriber

Posted on

Why is functional programming gaining popularity?

Latest comments (37)

Collapse
 
tomjoro profile image
Thomas

I wrote an article about this topic 6 months ago. It's not so much about what has changed with languages, but rather what has changed with the world that is driving adoption of functional programming. Functional programming uses immutable constructs, which are easier to reason about (for humans), and safer in terms of concurrency, and in general. Lots of other reasons - you can read about them in my article.

"Elixir - Erlang didn't change, the world did"

So what happened? The world changed, and continues to change:

Mooreโ€™s law ends,
I am sitting in front of a 16 core SMP computer,
It has more memory than I could ever use,
It is fast,
I am writing simple networked services,
Reliable code, not just features, differentiates,
Scalability is standard, and not special.

tomjoro.github.io/2017-01-31-world...

Collapse
 
bgadrian profile image
Adrian B.G.

Mainly because it's now very underrepresented and underused,and slowly rises where it should be,on the same parity as OOP.

Collapse
 
12eh profile image
Josh Warfield

Others are doing great covering the actual practical reasons, which inevitably apply to some situations and not others. What applies universally is the psychology part of it, e.g.:

  • it's a shiny new toy (many of us fell in love with programming because of the joy of learning new concepts)
  • popularity is a positive feedback loop (gee, I'd better try to do something with FP because everyone seems to be talking about it)
  • egotistical programmers love explaining arcane concepts to all the plebs who've never heard of them (do you have a few minutes to talk about our Lord and Savior the Maybe Monad?)
  • those same egotistical programmers have convinced a fair number of people that it's a magical solution to all bugs (there's no side effects! sometimes side effects are accidental and cause bugs! remove all the side effects and there won't be any more bugs!)
Collapse
 
johnpaulada profile image
John Paul Ada

Because of Javascript, I think.

And people like the advantages like being able to avoid doing things that you aren't supposed to happen because of function purity and immutability.

And lastly, because it's cool! :tada:

Collapse
 
johnpaulada profile image
John Paul Ada

Also, it's data-driven. It's focused on the flow of the data. And you know all the craze about data science these days.

Collapse
 
zeropaper profile image
Valentin Vago

Because a lot of us miss PHP3.

Collapse
 
niharmore33 profile image
nihar

Many people have mentioned about the multi-cores being a catalyst in encouraging the use of functional programming in the industry today. This is definitely one of the big motivating factors. But I think a more basic reason why FP is becoming more popular is the fact that we are developing more and more complex software these days and FP gives us the right tools to reason about our programs.

You can also learn a whole variety of programming languages here: hackr.io/

Using pure functional programming and decoupling the side-effecting parts of your program from the "pure" ones, you get the power to prove the correctness of your programs just like in mathematics. Richard Bird has written a great book Pearls of Functional Algorithm Design: Richard Bird: 9780521513388: Amazon.com: Books on this subject, where he mentions the following:

My aim in writing these particular pearls is to see to what extent algorithm design can be cast in a familiar mathematical tradition of calculating a result by using well established mathematical principles, theorems and laws.

This is the power of equational reasoning through composition of the powerful patterns of computation.

Collapse
 
praisethemoon profile image
praisethemoon

A lot of people think that object oriented programming is dead and the future is functional programming. I would understand that. Functional programming does have some very nice features such as pure functions. This allows developers to write safer code and works very well with concurrency. Many OOP language recently adopted various aspects for functional programming such as C++ and Java's Lambdas for they make writing certain parts of applications much easier. So it seems that functional programming can co-exist with other paradigm, which is good. This gives programmers more flexibility and design choices.

So why is functional programming gaining popularity? Because it allows developers to model their application in a different manner and write safer code thanks to their persistent data types.

Collapse
 
robertmjohnson profile image
Robert Johnson

So much of modern development boils down to receiving data from one system, transforming the data in some fashion and then passing it on to another system. FP is better suited to this than OOP because FP embraces data rather than trying to abstract it away all the time. Big ironclad static OOP languages like C++, C# and Java work well if you are writing a thick client in which you are in control of all the external interfaces, but in this world of microservices and REST APIs this kind of application is becoming increasingly rare.

In short, FP is not a silver bullet, it is just better than OOP for the kinds of problems we are trying to solve today.

Collapse
 
saurabhgiv profile image
saurabh.v

I have started writing a series of blogs which describes advantages of functional programming. If you are interested you can visit the link here.

Collapse
 
jess profile image
Jess Lee

Would you like to cross-post your articles on dev.to?

Collapse
 
saurabhgiv profile image
saurabh.v

Sure. I have posted my article on dev.to as well. You can visit it here

Collapse
 
ericschillerdev profile image
Unfrozen Caveman Dev

Everything else in computing from the 70s is coming back in style with a new wrapper, so why not? ;)