In the realm of computing, the term functional tends to take on two very distinct meanings:
Functional = contains lots of functionality, and
Functional = involves evaluation of expressions that do not have side effects rather than execution of commands. The typical comparison is that "functional" languages are thought of as distinct from "imperative" languages.
From the comp.lang.functional FAQ comes the following: "Functional programming is a style of programming that emphasizes the evaluation of expressions, rather than execution of commands. The expressions in these language are formed by using functions to combine basic values. A functional language is a language that supports and encourages programming in a functional style. "
In an imperative language, one might describe an algorithm for adding values together to get a sum thus:
The functional equivalent would be expressed without any variable updates (e.g. operations upon whose side-effects the process depends), perhaps as:Haskell /Miranda) or
(define (iota size) (if (<= size 0) '() (cons size (iota (- size 1))))) (define (sum size) (apply + (iota size)) (sum 10)
It is commonly possible to write code in a relatively functional style even in "imperative" languages, and vice-versa. For instance, Scheme programs commonly do have the side-effect of modifying data.
Major benefits of functional programming include that:
By trying to eliminate side-effects, it makes more explicit the relationship between input and output. Code is more readily understood.
Since it describes inputs and outputs rather than the detail of algorithms, more code optimizing can be readily done. This is of particular value when trying to build programs to run on parallel computing architectures.
Since side-effects are discouraged, FP encourages re-use and composition of functions together.
The most important concepts from functional programming may be captured with six design patterns:
Black-box behavior parameterisation; this indicates what are called functors in ML
Abandoning null references
Combining internal & external iteration
Homomorphic mapping with multi-dispatch functions
ML (which stands for "meta language") is a family of programming languages characterized by functional control structures, strict semantics, a strict polymorphic type system, and parametrized modules. There are a number of implementations, and it is fairly widely used as a teaching language in computer science programs.
This release of ML has the following features:
full, robust implementation of the Standard ML language
many performance improvements since version 0.93
support for the SML'97 revised definition of SML
support for the SML'97 Basis Library, with standardized access to operating system features, floating point, library support, etc.
CM compilation manager to support development of large systems
support for many machines (Sparc, Pentium, Alpha, SGI/Mips, RS/6000, HPPA)
support for Unix (many flavors) and Windows ('95, NT)
Standard ML of New Jersey Library (see source signatures for documentation)
CML (Concurrent ML)
eXene (interface to X Window system)
programming tool set: ML-Lex, ML-Yacc, ML-Burg, execution profiler
facility for interface to C programs
web-based documentation available for download
Once a Xanalys/Harlequin product, this ML environment has been released freely as Ravenbrook/mlworks @ GitHub
Perhaps one of the most practical of the functional languages, the useful OCAML application list includes:
The CAML shell. It is essentially an OCAML implementation of an API similar to that of SCSH .
Lots of bits of ML code licensed under the GPL .
MLTon is a whole-program optimizing compiler for Standard ML.
It has a native IA-32 code generator rather than generating C code, and then using GCC. It may generate better machine code, as a result, but obviously isn't portable to other architectures...
"To Be Or Not To Be Standard ML" ;-); an implementation of Standard ML written in ML. A byproduct of its implementation is that its documentation has a pretty comprehensive list of bugs and grey areas in the SML language definition.
A Perl 6 compiler has been written in Haskell in order to help to quickly shake out bugs in the language specification.
Cayenne is a simple(?) functional language with a powerful type system. The basic types are functions, products, and sums. Functions and products use dependent types to gain additional power. The design of Cayenne has been heavily influenced by Haskell and constructive type theory and with some things borrowed from Java.
One of the important characteristics of Haskell is the ability to readily use lazy evaluation.
Lazy evaluation is an evaluation strategy combining normal order evaluation with updating. Under this strategy, an expression is evaluated only when its value is needed in order for the program to return (perhaps just the next part of) its result.
The "wars" on comp.lang.apl have typically been over whether the apl in comp.lang.apl ought to be considered to stand for A Programming Language, thus ruling out discussion of similar languages that are not, strictly speaking, APL implementation, or whether it ought to be considered to stand for Array Processing Languages, which, of course opens up discussion to J, K, and perhaps NIAL.
It's not as if there's so much traffic concerning either variety of language as to cause the problems they have on the comp.lang.c hierarchy...
Real Soon Now, J will be made available under the GPL.
TANGRAM a general-purpose product for hypercube management.
Written entirely in APL; perhaps intended to become "open source."
Nial = Nested Interactive Array Language; syntax seems to be something of a combination of Pascal control structures with APL- or J-style functions.
Complete with a SOAP implementation
An APL variation available under the GPL that uses either ASCII or APL character sets, and includes, as interesting "extras:"
A persistent array storage scheme more reminiscent of DBM than anything else I can think of;
Their own RPC scheme called adap.
An interpreted vector-oriented language paralleling J and K
IBM 5100 Portable Computer - a very early portable computer that ran APL
An APL interpreter with a built-in compiler to C. Available "gratis" for Windows
This honours APL's 50th anniversary (in 2016) with demonstrations of 50 of its capabilities through 50 APL functions.
Sisal was designed by Lawrence Livermore Labs as an alternative to FORTRAN for high performance computing tasks, by providing support for optimizing parallel processing in the compile phase.
A purely functional language based on the composition of functions.
Unlike Forth, Joy uses quotation, where programs are enclosed by some form of quotes, as well as combinators, which are operators that manipulate programs.
J, if programmed in the "tacit" programming style, provides quite a "pure" functional programming system.
Mercury is a logic-functional programming language. The Mercury compiler is GPL-ed software, the library and runtime are LGPL.
Mercury has the clean semantics and clarity of modern functional programming languages, and the expressiveness of logic languages. It has a strong type system, a module system (allowing separate compilation), a mode system (which prevents data-flow errors), algebraic data types, parametric polymorphism, support for higher-order programming, and a determinism system -- all of which are aimed at both reducing programming errors and providing useful compiler information.
A programming course based on the language OZ
A high-performance reflective functional language involving algebra rewriting. Based on OBJ3.
OBJ3 is based on order sorted equational logic, and has been successfully used for research and teaching in software design and specification, rapid prototyping, theorem proving, user interface design, and hardware verification, among other things. It was the first language to implement parameterized programming and its module system influenced the designs of the Ada , C++ and ML module systems.
SET Language, a language intended for working with sets.