Functional programming

Published:

Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data (not to be confused with procedure programming). It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements. In functional code, the output value of a function depends only on the arguments that are input to the function, so calling a function f twice with the same value for an argument x will produce the same result f(x) each time.

Functional programming has its roots in lambda calculus, a formal system developed in the 1930s to investigate computability, the Entscheidungsproblem, function definition, function application, and recursion. Many functional programming languages can be viewed as elaborations on the lambda calculus. Another well-known declarative programming paradigm, logic programming, is based on relations.

In contrast, imperative programming changes state with commands in the source language, the most simple example being assignment. Imperative programming does have functions but in the sense of subroutines. They can have side effects that may change the value of program state. Functions without return values therefore make sense.

Functional programming languages, especially purely functional ones such as Hope, have largely been emphasized in academia rather than in commercial software development.

The most known functional programming languages are:

  • Common Lisp
  • Scheme
  • Clojure
  • Wolfram Language (also known as Mathematica)
  • Racket
  • Erlang
  • OCaml
  • Haskell
  • F#

Other ones support functional analysis like:

  • R
  • J, K and Q from Kx Systems (financial analysis)
  • XQuery/XSLT (XML)
  • Opal
  • Julia language also offers functional programming abilities
  • Scala (which is placed sometimes in the fuzzy border of imperative and functional languages.

See also

Programming paradigm

Books