What is functional programming?

Lately I hear a lot about Haskell and functional programming but, to be honest, I don't know anything about it. I know about Object oriented and Procedural but I don't really understand what is functional programming all about.

Matt Strom's photo

A very academic answer:

Functional programming is a branch of programming that expresses algorithms using lambda calculus.

Whereas object-oriented and imperative programming express algorithms as Turing machines.

The famous Church-Turing Thesis describes the duality that any function computable by a Turing machine is computable by a lambda calculus and vice versa.

Haskell Curry interestingly was one of the discoverers of the y-combinator, a important function in lambda calculus. For this reason he is the namesake of Haskell and currying.

j's photo

Functional programming is based on function not on objects.

key ideas.

everything can be describes as a function. (mathematical functions)

functional programming should not access global state from within the function body (no references or pointers)

functions are first class citizens so you can pass a function to another function as parameter

There are however pure and impure functional languages en.wikipedia.org/wiki/Purely_functional_pro..

These mutations of state are often referred as side-effects. like accessing the database or streaming a file. in haskell for example that's what the IO-monad is for.


maybe as a starting point.