Why are we seeing a rise in interest for functional programming?

I see more and more talk about people using functional languages, and of course there are all of the Haskell trails here on Upcase so I thought this would be a good place to ask.

I’m curious if anyone has opinions on this, and also maybe if someone could give a thought on what problems would be better solved in a functional language as opposed to traditional means?

Thanks!

I’m only just beginning to explore this area, but from what I understand so far:

  • The rate of increase in CPU clock speeds has slowed, but the number of CPU cores in a machine is on the increase. To make use of this, there’s a need to efficiently distribute work over multiple cores. Functional languages tend to make this easier, with less need to think about threads, etc.
  • Many bugs in OO code are related to state. FP encourages the use of immutable data structures instead.
  • Even thought OO has been around for decades, many people still struggle with the concepts, even professional developers. FP seems easier to grasp for new programmers (but perhaps harder for those who already know OO).
3 Likes

After hearing the podcast with Ben Orenstein and Carin Meier, I was asking myself the same question. May I should dive this summer in Carin Meier’s book Living Clojure

Functional programming has been around for a long time, but has frequently been dismissed as academic or impractical. I think that modern improvements in hardware, compilers, and virtual machines has made it more practical to run functional-oriented software.

I also think the fact that object-oriented developers are generally exposed to some basic functional concepts in their own language has made it easier to try out functional programming. For example, Ruby uses higher order functions like map and each to implement collection operations which would traditionally involve classes like Java’s Iterator interface. The idea of currying has started to get popular, particularly in OOP/FP hybrid languages like Scala and Swift.

Functional programming has a number of compelling aspects when compared to object-oriented programming. Restricting mutation and shared state eliminates a large number of bugs. It also makes it easier to achieve parallelization and concurrency. Composing at the function unit rather than the object unit is generally easier to achieve.

At the end of the day, I think functions are simpler than objects. If you can find a useful metaphor for programming within a few functional rules (immutable data, referential transparency, curried functions, laziness), it creates an endless world of functions which are all simple and composable.

2 Likes