Functional programming

Edit · View history

Functional programming

Functional programming is a programming paradigm where programs are constructed by applying and composing functions. It treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. Functional programming emphasizes the use of pure functions, which always produce the same output for the same input and have no side effects. This paradigm is rooted in lambda calculus, developed by Alonzo Church in the 1930s, and has influenced many modern languages.

One of the core principles of functional programming is referential transparency, meaning that an expression can be replaced with its value without changing the program's behavior. This property simplifies reasoning about code and enables techniques such as lazy evaluation and memoization. Another key concept is higher-order functions, which can take other functions as arguments or return them as results. This allows for powerful abstractions like map, filter, and reduce.

Functional programming languages often support immutable data structures, recursion, and pattern matching. While early functional languages like Lisp and ML were primarily academic, later languages such as Haskell, Scala, Erlang, and F# brought functional concepts to mainstream use. Many multi-paradigm languages, including JavaScript, Python, and Java, have also adopted features from functional programming.

Features

History

The roots of functional programming lie in lambda calculus, a formal system developed by Alonzo Church in the 1930s. The first functional programming language, Lisp, was created by John McCarthy in 1958. Lisp introduced many ideas such as garbage collection and first-class functions, but was not purely functional.

In the 1970s, Robin Milner and others developed ML, which added a strong static type system and type inference. David Turner's SASL and KRC languages furthered the use of lazy evaluation. In 1985, Haskell was conceived as a standard lazy pure functional language; its first version was released in 1990.

During the 2000s, functional programming gained wider adoption in industry. Scala (2003) blended object-oriented and functional styles. F# (2005) brought functional capabilities to the .NET ecosystem. Languages like Erlang (1986) popularized functional programming in concurrent and distributed systems. In the 2010s, major languages such as JavaScript and Java introduced lambda expressions and streams, reflecting a broader trend toward incorporating functional principles.