A functional or applicative language is one in which the computational model is that of expression evaluation. This is not like a procedural language (such as C, Basic, Cobol or Ada) where the computational principle is changing the contents of stored values (called ``variables''). Functional languages have no storage, no statements. In functional languages no value can ever be changed, new values can only be built from existing ones without changing them, this is what happens when expressions are evaluated.
If a procedural language like Modula-2 or Ada was stripped of all its statements, its variables, its arrays it would be close to a functional language, but a very weak one. Useful functional languages must have much richer expressions and data constructors to allow them to describe non-trivial computations.
So a functional program only consists of declarations, definitions of functions, data types, constants and just one expression to be evaluated calling the defined functions with actual arguments (known as applying functions to arguments), its result is the result of the program5.1. This might appear very limiting but complicated tasks can be programmed, just as:
a = 3
b = 4
a * a + b * b
is a functional program, so is:
codegen(typecheck(parse(scan sourcecode)))
a functional program given suitable definitions of the
functions codegen etc. and a value for sourcecode.
The example language used in these notes is Haskell. It was designed by a group of people from Europe and America. It was intended to contain the best features of functional languages, to be a vehicle for language and programming research and to have high quality compilers. It is also publicly and freely available. Haskell owes a lot to Miranda which was designed by D. Turner.
© University of Hertfordshire Higher Education Corporation (1998)