What is Functional Programming?

I call it my billion-dollar mistake … My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. — Tony Hoare

 Functional programming is sometimes considered to be a set of techniques that supplement or replace techniques found in other programming paradigms, such as

 First-class functions
 Anonymous functions
 Closures
 Currying
 Lazy evaluation
 Parametric polymorphism
 Algebraic data types

we can consider the imperative approach of programming as the opposite of functional programming. An imperative style is composed of lots of elements that actually do something which depends on the initial state, transition state, and the end state, this mechanism is sometimes called a state mechanism. But functional programs are composed of elements that “are” something — they don’t “do” something

One major difference between imperative programming and FP is that in FP there are no side effects. This means, among other things,
 No mutation of variables
 No printing to the console or to any device
 No writing to files, databases, networks, or whatever
 No exception throwing


Popular posts from this blog

Functional Programming in Java - Part 1

Akka Actors in Java - Part 1

sealed keyword in Scala