Friday, March 14, 2014

Functional Programming: A Brief Introduction

Functional Programming Languages provide 2 main features:
  1. First class functions 
    • which means functions are first-class citizens.
      • functions can be assigned to variables
      • functions can be stored in data structures
      • functions can be passed to other functions as arguments
      • functions can be returned from other functions
  2. Pure functions without any side-effect
    • Functions take values as parameters and return values.
    • No global or mutable state.

What do these two features lead to

  • Localized thinking space 
  • Localized testing 
  • Control abstraction with higher order functions
  • More readable & shorter code
    • Higher order Functions leads to less branches and assignments, which in turn leads to readable, shorter code. 
  • Data abstraction with closures
  • Concurrency - immutable data structures
  • Simplifies programming. No need for complicated Object Oriented Design Patterns, which are required to solve problems that Object Orientation introduces.

No comments:

Post a Comment