Accueil Le blog ebiznext
1. FP versus OOP versus PP

This is the first of a series of posts I intend to share and that address the benefits of FP over OOP.

I spent my WE trying to figure out how to convince IT specialists to shift from OOP to FP.
You can’t simply tell a OO developer that functional programming is about not modifying the state of any object but applying functions to functions.
First nobody sees the value, second, it does not make any sense.

A new paradigm succeed when it brings an added value. This added value is usually clearly in the way you are able to glue subsystems together.

PP took over AP - Ancient Programming :) - because it brought modules / procedures / functions and parameters to better assemble pieces of software

OO took over PP because inheritance and polymorphism significantly improved the way you could reuse and extend software

FP is taking over OO for the same reason. It is providing new glues and these are : Higher Order Functions (HOF) and lazy evaluation

HOF means that a function may be passed as a parameter to another function or can be the return value of any other function. It this new ? No definitely not, languages as old as C & C++ can emulate HOF through pointer to functions. But don’t be fooled they do it without the benefit of closure and that’s where it all starts.

Lazy evaluation, simply said, is nothing more than delaying evaluation of an argument until it is really accessed. Apart from bringing performance improvement (the expression is not evaluated if not accessed), it does allow us to express infinite syntax trees in a recursive form and that’s awesome.

My next posts will explain :

  • How FP opens the door to state free programming and massively parallel programming
  • What kind of glue HOF brings with it
  • Which application of lazy evaluation we find in daily programming

P.S. Since examples will be best described through a real FP language, I’ll use Scala and sometimes refer to the Java 8 equivalent constructs where applicable