Functional programming: Difference between revisions
Content added Content deleted
(New page: Category:Programming Paradigms'''Functional programming''' is a programming paradigm that abstracts away the computational state. The program is written in a stateless, and thus immuta...) |
(Created) |
||
Line 1: | Line 1: | ||
[[Category:Programming Paradigms]]'''Functional programming''' is a programming paradigm that abstracts away the |
[[Category:Programming Paradigms]]'''Functional programming''' is a programming paradigm that abstracts away the computation state. The program is designed in a stateless, and thus immutable, manner. In this sense functional programming opposes [[imperative programming]], which focuses on state transitions. Functional programming uses procedural decomposition (see [[procedural programming]]) and [[closure]]s. Subprograms there are pure functions, with the only side effect allowed on the function result. [[Iteration]] is typically replaced by [[recursion]], as the former exposes the state either in the form of the loop variable or as the exit condition. |
||
Stateless abstraction ease program semantics definition. In particular it removes the problems with: |
|||
* the order of subexpression evaluation, |
|||
* aliasing, |
|||
* the evaluation time (see [[lazy evaluation]]). |
|||
At the same time it makes programming considerably more difficult, especially when the notion of state is natural to the domain space. Functional languages like [[Haskell]] provide some support for stateful programming, see [http://en.wikipedia.org/wiki/Monads_in_functional_programming monads]. |