Functional programming

Hand-drawn hatched terracotta band of jigsaw pieces fitted end to end in a gentle curve across flowing sand, umber and moss wood-grain lines.

Functional programming builds programs by defining functions, combining them, and evaluating expressions to get results; functions can themselves be values that a program passes around (Bird & Wadler, 1988; Hudak, 1989; Hughes, 1990). Its ideas developed in languages such as Lisp, ML, Haskell and Erlang, and later reached mainstream languages such as Java (McCarthy, 1960; MacQueen et al., 2020; Hudak et al., 2007; Armstrong, 2007; Buckley, n.d.). One dispute concerns the limits of building programs by composing functions (Steimann, 2025). Another concerns what it does in practice: effects on bugs and on reading code vary by feature and task, and the evidence is thin and does not show causes (Zampetti et al., 2022; Hudak & Jones, 1994; Zid et al., 2024).

Pure functions and immutable data

A pure function has no observable effect beyond producing its result, which depends only on its arguments. A function that doubles a number always gives 6 when called with 3. If it also prints 6, the call has an effect a caller can observe (Cunningham, 2019; OCaml, n.d.b). The property called referential transparency lets a programmer replace an expression with an equal one, such as a call to the doubling function with its result (Hudak, 1989).

Immutable data stays the same after it is created. Adding an item to the front of an immutable linked list can create one new node that points to the existing list, so both versions remain available. Reusing the unchanged nodes this way is called structural sharing (Okasaki, 1998).

Purity concerns what the caller can observe. A function can change a temporary data structure internally and still be pure if those changes stay private. Haskell’s runST has a type that keeps mutable state local to a computation (Cunningham, 2019; Launchbury & Peyton Jones, 1994).

Combining functions and repeating work

A higher-order function takes another function as an argument or returns one. One list operation can accept either a doubling or a squaring function. Function composition feeds one function’s result into the next. Doubling followed by adding one turns 3 into 6 and then 7 (Bird & Wadler, 1988; Hughes, 1990).

Recursion repeats a computation by having a function call itself. To count a list, return zero for an empty list; otherwise count the list after its first item and add one (OCaml, n.d.c; Bird & Wadler, 1988).

The case for composing programs Contested: studies disagree on this

Whether whole programs should be built by composition is disputed. Backus proposed a set of ways to combine programs, with algebraic rules for transforming them, and Hughes argued for reuse through higher-order functions and lazy evaluation. Steimann argues that the functional style imposes its own bottleneck when a computation’s results must be encoded as a single value (Backus, 1978a; Hughes, 1990; Steimann, 2025).

When expressions are evaluated

Evaluation order decides whether a function does work on an argument it never uses. Under ML’s strict evaluation, an argument is evaluated before the function is applied. Under Haskell’s lazy evaluation, an argument waits until it is needed and repeated uses share one evaluation, so a function that always returns 7 can leave its argument unevaluated (Rémy, 2001; MacQueen et al., 2020).

Laziness lets a consumer request only part of a result. In Turner’s KRC language, a list defined as a 1 followed by that same list is infinite, yet asking for its first three entries needs only three 1s. Hughes uses the same idea to search part of a potentially infinite tree (Turner, 1981; Hughes, 1990). The cost in memory is covered under memory, energy and reliability below.

Representing alternatives

An algebraic data type lists the forms a value may take and the fields each form carries. A Git revision, for example, can be a branch name or a commit hash. A pattern match chooses what to do for each form and names its fields: the OCaml pattern Hash sha selects the hash case and calls the stored text sha (Cunningham, 2019; OCaml, n.d.a).

Handling effects

Languages differ in how a computation may print text, update state or raise an exception besides producing a result. OCaml lets functions perform effects directly, such as printing their input before returning it (Moggi, 1991; OCaml, n.d.b). Haskell represents input and output as actions sequenced by a monad, a structure for chaining computations that carry effects; the implementation preserves the order the program specifies (Wadler, 1995; Marlow, 2010a).

Other designs track effects in types. In Koka, code requests an effect through an operation, a handler supplies what it does, and the function’s type records which effects may occur. Clean’s uniqueness typing tracks when data can be updated in place because the old value is no longer accessible (Leijen, 2016; Leijen, 2014; Plasmeijer & van Eekelen, n.d.).

Language lineages

From Church to Lisp and Scheme

The lambda calculus describes computation with variables, function definitions and function applications; in 1936 Alonzo Church proposed defining effective calculation on positive integers in its terms. John McCarthy borrowed Church’s notation to mark a Lisp function’s arguments, and recalled that work on symbolic differentiation led him to combine recursive definitions with conditional expressions (Turner, 2012; Church, 1936; McCarthy, 1960; McCarthy, 1979).

Early Lisp supported assignments and jumps as well as composition and conditional expressions. Its FUNARG mechanism let a function passed as an argument carry the name bindings from where it was defined (McCarthy, 1979). Scheme explicitly took the lambda calculus as the basis for a Lisp-like language, extended with effects and concurrent computations (Sussman & Steele, 1975).

ISWIM, ML, Miranda and Haskell

Peter Landin’s ISWIM set out a common framework for a family of languages. ML drew on it and began as the language for writing proof procedures for the Edinburgh LCF theorem prover, which programmers composed with higher-order functions (Landin, 1966; MacQueen et al., 2020).

Turner’s line of languages carried lazy evaluation forward. SASL took its notation from ISWIM, and his 1985 Miranda added types that work across kinds of data and checks on separately compiled parts. Miranda’s foldr, which combines list items into a result, was explicitly linked to Backus’s reduction operator (Hudak et al., 2007; Turner, 1985).

Haskell’s founders wanted a shared lazy language in which researchers could exchange ideas and build applications on a stable base. The first report appeared in 1990, and the committee intended the language for teaching, research and large applications (Hudak et al., 2007; Rémy, 2001; Marlow, 2010b).

Erlang and hosted languages

Erlang started at Ericsson in 1986 for telephone software, growing out of an experiment that added concurrent processes to Prolog (Armstrong, 2007; Armstrong, 2003). Programs are made of concurrent processes that keep their memory separate and exchange messages the recipient can handle later (Armstrong, 2007).

Other languages brought functional ideas to an existing runtime, the software environment that runs a program. F# began from OCaml with two-way interoperability with .NET as a goal. Clojure, a Lisp released in 2007, runs on another language’s runtime and combines pure functions over immutable data with ways to manage shared state across concurrent computations (Syme, 2020; Hickey, 2020).

Defects

Studies of code history link functional constructs to bugs without showing a cause. The study covered 200 popular open-source Python projects and constructs such as lambdas (functions defined inline) and comprehensions (collections built from existing values). A change to such a construct had 1.15 times the odds of inducing a later fix, a 15% increase. Odds are the chance of a fix divided by the chance of no fix; the authors call the result a correlation (Zampetti et al., 2022).

A JavaScript study measured a different event. Across 91 repositories, the odds that a bug-fix commit removed recursion were about 62% of those for other commits (Alves et al., 2022).

Tracing a fix back to the change that introduced the bug is imprecise. SZZ algorithms make that link. Without filtering by issue date, one SZZ tool found 72% of the developer-identified commits in each of two benchmark sets. Only 9% and 6% of the commits it flagged matched them (Rosa et al., 2021).

Writing, reading and debugging code Weak evidence: few or small studies support this

Evidence on developers comes from a few small studies, and effects depend on the feature and the task. In one comparison, a Haskell prototype of a geometric region server took 10 hours and 85 lines, against 23 hours and 767 lines in Ada. Different programmers wrote the two, so language and programmer differences are mixed (Hudak & Jones, 1994).

In a randomized experiment with 20 participants, people answered questions faster and with fewer errors about Java streams than about loops. In 610 Java projects that used streams, the common operations were transforming elements (map), keeping matches (filter) and collecting results (Mehlhorn & Hanenberg, 2022; Nostas et al., 2021).

How readable code seems and how easily people change it can diverge. In an experiment with 209 developers, participants judged procedural Python snippets more readable. On modification tasks they did better with lambdas than with procedural equivalents, but worse with comprehensions (Zid et al., 2024).

Debugging relies on familiar strategies. Four expert Haskell programmers described strategies similar to those in other languages, alongside challenges specific to Haskell. In a Python exercise with 29 participants, mostly students, people reported less confidence on functional code, but the study detected no difference in debugging ability (Huang et al., 2023a; Flint et al., 2025).

Teaching

Functional programming has been taught from the first year of a computer science degree. At the University of Twente, a course run four times with 30 to 40 students became part of the curriculum for all first-year students in 1991/92 (Joosten et al., 1993). In another first-year course, students first worked with supplied code. Scores were 9% higher on average the next year, an effect the author described as small (Chapman, 2025).

Memory, energy and reliability at run time

Delaying computations can make memory use grow unexpectedly. In a Haskell example that computes an average, delayed arithmetic builds a chain of pending calculations that grows with the input (Vasconcelos, 2020). Haskell’s designers name this one source of space leaks and added seq, which forces evaluation of an otherwise unused argument (Hudak et al., 2007). In one lazy program, heap profiling, which tracks how a running program uses memory, guided changes that cut peak memory from 1.3 megabytes to about 10 kilobytes (Runciman & Wakeling, 1993; Hudak et al., 2007).

The energy cost of sharing data between concurrent tasks changes with the workload. In one Haskell benchmark, one sharing mechanism used 60% less energy than another; in a different benchmark the second saved up to 30%. In one concurrent benchmark, the fastest variants also used the most energy (Lima et al., 2016).

Erlang’s fault tolerance, keeping a system working through faults, comes from language features combined with library code. Its designer Joe Armstrong says the long-term reliability figure he had for Ericsson’s AXD301 system lacked a documented derivation (Armstrong, 2003).

Adoption

Mainstream languages added ways to pass functions around. Version 3.0 of C# added lambda expressions, which define functions inside expressions. The same version added query expressions and expression trees (Microsoft, 2026h). Java SE 8 added lambda expressions, method references and functional interfaces to support both functional and object-oriented styles (Buckley, n.d.).

Adoption figures depend on what gets counted. In 241 open-source Java projects, lambda use rose in aggregate, while a separate sample of engineered Java repositories found lambdas in 11% of them (Mazinanian et al., 2017; Alqaimi et al., 2019). Developers sometimes replaced loops and conditionals with streams, but parallel streams were uncommon in studies of 34 and of 610 projects (Mazinanian et al., 2017; Khatchadourian et al., 2020; Nostas et al., 2021).

Developer surveys count people rather than code. Stack Overflow’s 2026 survey let respondents name every language they had used extensively in the past year. JetBrains reported that 2% of respondents in 2025 used Scala as their primary language (Stack Overflow, 2026; Bedrina, 2025).

Further reading

  • Bird and Wadler’s textbook introduces function definitions, composition and recursive operations on lists (Bird & Wadler, 1988).
  • Hughes develops the case for reusable parts with higher-order functions and lazy search (Hughes, 1990).
  • The Haskell designers’ history describes the shared language they aimed to build and the control they later added over evaluation (Hudak et al., 2007).
  • Armstrong’s account explains Erlang’s telephony origins and its use of processes and messages (Armstrong, 2007).
  • Zampetti et al. (2022) trace changes to functional constructs and later fixes in Python projects.
  • Zid et al. (2024) separate how readable Python snippets seem from how easily people modify them.

Known gaps

What this article cannot tell you yet.

  1. The history of Haskell 1.0 draws on the designers’ retrospective and a later language report. The original 1.0 report could not be checked directly.
  2. The account of Steimann’s objection rests on his keynote abstract.
  3. The follow-up history of effect-handler implementations is outside the coverage of this article.
  4. The geometric server comparison leaves open whether its time and code differences recur with other teams and tasks.
  5. The classroom reports leave open how a functional-first curriculum affects learning compared with other curricula.
  6. Independent measurements of industrial reliability and follow-ups to the Haskell concurrency benchmarks are missing here.
  7. The debugging interviews and profiling example leave open how often the same problems and remedies occur in other Haskell programs.

References

Solid source
Rated highly trustworthy by the research, and every passage taken from it was found in it.
Weak source
Rated low, or a passage taken from it was not found in it.
Medium trust
Rated medium by the research.
Not checked
Rated high, but its passages could not all be checked against it.
Show all 54 references