Functional Programming Paradigm

The paradigm where we try to bind everything in pure mathematical functions style.

What is Functional Programming Paradigm?

Functional programming languages are specially designed to handle symbolic computation and list processing applications. Functional programming is based on mathematical functions. Some of the popular functional programming languages include: Lisp, Python, Erlang, Haskell, Clojure, etc.

Concepts of functional programming

  • Pure Functions
  • Recursion
  • Referential transperancy
  • Functions are first class and can be higher order
  • Variables are immutable

Advantages

  • Pure functions are easier to reason about
  • Testing is easier, and pure functions lend themselves well to techniques like property-based testing
  • Debugging is easier
  • Programs are more bulletproof
  • Programs are written at a higher level, and are therefore easier to comprehend
  • Function signatures are more meaningful
  • Parallel/concurrent programming is easier

Disadvantages

  • Writing pure functions is easy, but combining them into a complete application is where things get hard.
  • The advanced math terminology (monad, monoid, functor, etc.) makes FP intimidating.
  • For many people, recursion doesn’t feel natural.
  • Because you can’t mutate existing data, you instead use a pattern that I call, “Update as you copy.”
  • Pure functions and I/O don’t really mix.
  • Using only immutable values and recursion can potentially lead to performance problems, including RAM use and speed.