functional programming

(redirected from Functional languages)

functional programming

[′fəŋk·shən·əl ′prō‚gram·iŋ]
(computer science)
A type of computer programming in which functions are used to control the processing of logic.

functional programming

(FP) A program in a functional language consists of a set of (possibly recursive) function definitions and an expression whose value is output as the program's result. Functional languages are one kind of declarative language. They are mostly based on the typed lambda-calculus with constants. There are no side-effects to expression evaluation so an expression, e.g. a function applied to certain arguments, will always evaluate to the same value (if its evaluation terminates). Furthermore, an expression can always be replaced by its value without changing the overall result (referential transparency).

The order of evaluation of subexpressions is determined by the language's evaluation strategy. In a strict (call-by-value) language this will specify that arguments are evaluated before applying a function whereas in a non-strict (call-by-name) language arguments are passed unevaluated.

Programs written in a functional language are generally compact and elegant, but have tended, until recently, to run slowly and require a lot of memory.

Examples of purely functional languages are Clean, FP, Haskell, Hope, Joy, LML, Miranda, and SML. Many other languages such as Lisp have a subset which is purely functional but also contain non-functional constructs.

See also lazy evaluation, reduction.

Lecture notes. or the same in dvi-format.


SEL-HPC Article Archive.

functional programming

A programming language that is based primarily on writing algorithms (functions). The syntax of functional programming (FP) is mathematical, and the languages are used for applications such as artificial intelligence and distributed networks, not typically for business data processing.

Experienced FP programmers generally have strong opinions about what constitutes essential FP features, as well as which languages are more FP-like than others. However, ask any of the IT professionals you know for a definition of FP, and you will likely get a range of responses, including "huh?" The reason is that traditional programming, known as "imperative programming," also uses functions (subroutines). In fact, every C program ever written is wrapped in a "main" function that encapsulates all the other functions the programmer writes. However, FP adheres to certain principles, including the following. See function.

Referential Transparency and No Side Effects
Referential transparency means that the function will always return the same value given the same set of inputs. Also called "no side effects," pure functions do not use data defined outside of the function, although a few functions in most programs deal with external events such as reading and writing a disk. Pure functions help to avoid errors in parallel operations. For example, in multithreading, data being changed in one executing thread can cause problems in another.

Higher-Order Functions
Functions can be treated like data, and higher-order functions can take other functions as parameters, enabling the called function to perform the algorithm in the function being passed to it.

Pattern Matching and Recursion
Instead of a series of if-then-else statements, a pattern matching statement compares an argument with a list to find a match. Recursion is a function that can call itself to repeat the processing on the next set of data. These capabilities as well as others attributed to FP can also be found in both imperative and object-oriented languages. See recursion.

FP Languages
LISP was the first functional programming language, followed by Erlang, Scheme, Haskell, OCaml, Scala, Clojure, F# and others.
References in periodicals archive ?
The difficulty of contract checking in functional languages lies in the presence of advanced features such as high-order functions and laziness.
In Scheme, ML and other functional languages functions are "first-class" objects and can be passed as parameters, constructed in other functions and returned as values.
The second part, Advanced Topics, which includes the compilation of object-oriented and functional languages, garbage collection, loop optimization, SSA form, instruction scheduling, and optimization for cache-memory hierarchies, can be used for a second-semester or graduate course.
1995] -- PROSET-Linda [Hasselbring 1998] [check] Concurrent Functional Languages Crystal [Chen et al.
One of the most studied issues concerning functional languages is their implementation.
Functional languages, on the other hand, meet all the requirements listed above and do not require analysis for the discovery of parallelism [1, 15, 17, 18].
In functional languages such as Scheme or SML functions can be passed as parameters, can be constructed in other functions and returned as values.
The actual technique used in higher-order functional languages for computing function values is called graph reduction [Peyton-Jones and Lester 1992].
Higher-order functional languages provide rich and expressive programming platforms.
In strictly functional languages, an operation is defined by a single, monolithic piece of code.
Whereas some declarative programmers only pay lip service to equational reasoning, users of functional languages exploit them every time they run a compiler, whether they notice it or not.
These examples include languages based on message passing, rendezvous, remote procedure call, objects, and atomic transactions, as well as functional languages, logic languages, and distributed data structure languages.

Full browser ?