Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Functional programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Programming paradigm based on applying and composing functions}} {{For|subroutine-oriented programming|Procedural programming}} In [[computer science]], '''functional programming''' is a [[programming paradigm]] where programs are constructed by [[Function application|applying]] and [[Function composition (computer science)|composing]] [[Function (computer science)|functions]]. It is a [[declarative programming]] paradigm in which function definitions are [[Tree (data structure)|trees]] of [[Expression (computer science)|expressions]] that map [[Value (computer science)|value]]s to other values, rather than a sequence of [[Imperative programming|imperative]] [[Statement (computer science)|statements]] which update the [[State (computer science)|running state]] of the program. In functional programming, functions are treated as [[first-class citizen]]s, meaning that they can be bound to names (including local [[Identifier (computer languages)|identifiers]]), passed as [[Parameter (computer programming)|arguments]], and [[Return value|returned]] from other functions, just as any other [[data type]] can. This allows programs to be written in a [[Declarative programming|declarative]] and [[Composability|composable]] style, where small functions are combined in a [[Modular programming|modular]] manner. Functional programming is sometimes treated as synonymous with [[purely functional programming]], a subset of functional programming that treats all functions as [[Deterministic system|deterministic]] mathematical [[Function (mathematics)|functions]], or [[pure function]]s. When a pure function is called with some given arguments, it will always return the same result, and cannot be affected by any mutable [[State (computer science)|state]] or other [[Side effect (computer science)|side effects]]. This is in contrast with impure [[Procedure (computer science)|procedures]], common in [[imperative programming]], which can have side effects (such as modifying the program's state or taking input from a user). Proponents of purely functional programming claim that by restricting side effects, programs can have fewer [[Software bug|bugs]], be easier to [[Debugging|debug]] and [[Software testing|test]], and be more suited to [[formal verification]].<ref name="hudak1989">{{cite journal |last=Hudak |first=Paul |author-link=Paul Hudak |title=Conception, evolution, and application of functional programming languages |journal=ACM Computing Surveys |volume=21 |issue=3 |pages=359β411 |date=September 1989 |url=http://www.dbnet.ece.ntua.gr/~adamo/languages/books/p359-hudak.pdf |doi=10.1145/72551.72554 |s2cid=207637854 |accessdate=2013-08-10 |archivedate=2016-01-31 |archiveurl=https://web.archive.org/web/20160131083528/http://www.dbnet.ece.ntua.gr/~adamo/languages/books/p359-hudak.pdf |url-status=deviated }}</ref><ref name="hughesWhyFPMatters"/> Functional programming has its roots in [[academia]], evolving from the [[lambda calculus]], a formal system of computation based only on functions. Functional programming has historically been less popular than imperative programming, but many functional languages are seeing use today in industry and education, including [[Common Lisp]], [[Scheme (programming language)|Scheme]],<ref name="clinger1987"/><ref name="hartheimer1987"/><ref name="kidd2007"/><ref name="cleis2006"/> [[Clojure]], [[Wolfram Language]],<ref name="reference.wolfram.com">{{cite web |title=Wolfram Language Guide: Functional Programming |url=http://reference.wolfram.com/language/guide/FunctionalProgramming.html |year=2015 |access-date=2015-08-24}}</ref><ref name="Amath-CO"/> [[Racket (programming language)|Racket]],<ref name="racket-video-games"/> [[Erlang (programming language)|Erlang]],<ref name="erlang-faq"/><ref name="armstrong2007"/><ref name="larson2009"/> [[Elixir (programming language)|Elixir]],<ref>{{Cite web|title=The Elixir Programming Language|url=https://elixir-lang.org/|access-date=2021-02-14}}</ref> [[OCaml]],<ref name="minksy2008"/><ref name="leroy2007"/> [[Haskell]],<ref name="haskell-industry"/><ref name="hudak2007"/> and [[F Sharp (programming language)|F#]].<ref name="quantFSharp">{{cite conference |last=Mansell |first=Howard |title=Quantitative Finance in F# |url=http://cufp.galois.com/2008/abstracts.html#MansellHoward |year=2008 |conference=CUFP 2008 |access-date=2009-08-29 |archivedate=2015-07-08 |archiveurl=https://web.archive.org/web/20150708125937/http://cufp.galois.com/2008/abstracts.html#MansellHoward |url-status=dead }}</ref><ref name="businessAppsFSharp">{{cite conference |last=Peake |first=Alex |title=The First Substantial Line of Business Application in F# |url=http://cufp.galois.com/2009/abstracts.html#AlexPeakeAdamGranicz |year=2009 |conference=CUFP 2009 |access-date=2009-08-29 |archive-url=https://web.archive.org/web/20091017070140/http://cufp.galois.com/2009/abstracts.html#AlexPeakeAdamGranicz |archive-date=2009-10-17 |url-status=dead }}</ref> [[Lean (proof assistant)|Lean]] is a functional programming language commonly used for verifying mathematical theorems.<ref>{{cite conference |conference=Conference on Automated Deduction |title=The Lean 4 Theorem Prover and Programming Language |last1=de Moura |first1=Leonardo |last2=Ullrich |first2=Sebastian |date=July 2021 |book-title=Lecture Notes in Artificial Intelligence |volume=12699 |pages=625β635 |issn=1611-3349 |doi=10.1007/978-3-030-79876-5_37 |doi-access=free}}</ref> Functional programming is also key to some languages that have found success in specific domains, like [[JavaScript]] in the Web,<ref>{{Cite web|last=Banz|first=Matt|date=2017-06-27|title=An introduction to functional programming in JavaScript|url=https://opensource.com/article/17/6/functional-javascript|access-date=2021-01-09|website=Opensource.com|language=en}}</ref> [[R (programming language)|R]] in statistics,<ref name="useR"/><ref name="Chambers"/> [[J (programming language)|J]], [[K (programming language)|K]] and [[Q (programming language from Kx Systems)|Q]] in financial analysis, and [[XQuery]]/[[XSLT]] for [[XML]].<ref name="Novatchev"/><ref name="Mertz"/> Domain-specific declarative languages like [[SQL]] and [[Lex (software)|Lex]]/[[Yacc]] use some elements of functional programming, such as not allowing [[mutable object|mutable values]].<ref name="Chamberlin_Boyce"/> In addition, many other programming languages support programming in a functional style or have implemented features from functional programming, such as [[C++11]], [[C Sharp (programming language)|C#]],<ref>{{Citation|title=Functional Programming with C# - Simon Painter - NDC Oslo 2020| date=8 August 2021 |url=https://www.youtube.com/watch?v=gvyTB4aMI4o| archive-url=https://ghostarchive.org/varchive/youtube/20211030/gvyTB4aMI4o| archive-date=2021-10-30|language=en|access-date=2021-10-23}}{{cbignore}}</ref> [[Kotlin (programming language)|Kotlin]],<ref name=":0">{{Cite web|url=https://kotlinlang.org/docs/tutorials/kotlin-for-py/functional-programming.html|title=Functional programming - Kotlin Programming Language|website=Kotlin|access-date=2019-05-01}}</ref> [[Perl]],<ref>{{cite book |last=Dominus |first=Mark J. |author-link=Mark Jason Dominus |title=Higher-Order Perl |publisher=[[Morgan Kaufmann]] |year=2005 |isbn=978-1-55860-701-9 |title-link=Higher-Order Perl}}</ref> [[PHP]],<ref>{{cite book |last=Holywell |first=Simon |title=Functional Programming in PHP |publisher=php[architect] |year=2014 |isbn=9781940111056}}</ref> [[Python (programming language)|Python]],<ref name="AutoNT-13">{{cite web |url=https://www.python.org/community/pycon/dc2004/papers/24/metaclasses-pycon.pdf |archive-url=https://web.archive.org/web/20090530030205/http://www.python.org/community/pycon/dc2004/papers/24/metaclasses-pycon.pdf |archive-date=30 May 2009 |title=Python Metaclasses: Who? Why? When? |last=The Cain Gang Ltd. |access-date=27 June 2009 |url-status=dead |df=dmy-all }}</ref> [[Go (programming language)|Go]],<ref>{{Cite web|last=|first=|date=22 December 2020|title=GopherCon 2020: Dylan Meeus - Functional Programming with Go|url=https://www.youtube.com/watch?v=wqs8n5Uk5OM|access-date=|website=YouTube}}</ref> [[Rust (programming language)|Rust]],<ref>{{Cite web|title=Functional Language Features: Iterators and Closures - The Rust Programming Language|url=https://doc.rust-lang.org/book/ch13-00-functional-features.html|access-date=2021-01-09|website=doc.rust-lang.org}}</ref> [[Raku (programming language)|Raku]],<ref>{{cite web|last=Vanderbauwhede |first=Wim |url=https://wimvanderbauwhede.github.io/articles/decluttering-with-functional-programming/|archive-url=https://web.archive.org/web/20200728013926/https://wimvanderbauwhede.github.io/articles/decluttering-with-functional-programming/|archive-date=28 July 2020|title=Cleaner code with functional programming |date=18 July 2020 |access-date=6 October 2020}}</ref> [[Scala (programming language)|Scala]],<ref name="effective-scala"/> and [[Java (programming language)|Java (since Java 8)]].<ref name="java-8-javadoc"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)