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.
The Common Lisp SERIES package provides a data structure called a "series" that may be composed functionally where the set of macros involved create optimized programs to perform manipulations.
Since side-effects are discouraged, FP encourages re-use and composition of functions together.
FPS - Functional Pattern System for Object-Oriented Design
The most important concepts from functional programming may be captured with six design patterns:
Function Object
Black-box behavior parameterisation; this indicates what are called functors in ML
Lazy Object
Evaluation-by-need semantics
Value Object
Immutable values
Void Value
Abandoning null references
Transfold
Combining internal & external iteration
Translator
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.
Standard ML (Bell Labs SML/NJ)
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
Notable documentation links:
FoxNet Web Server written in Standard ML
Programming in Standard ML '97: An On-line Tutorial, by Stephen Gilmore
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 .
Camlp4 syntax preprocessor system
Developing Applications with Objective CAML
This is a translation of the principal book on OCAML, written in French, into English. I translated chapter 17.
A collection of links to Caml-related tools, libraries, code samples, tips, etc.
Dynamic Caml is a high-level run-time code generation library for Objective Caml.
Some Lisp/ML translated into Lazy C
ML Kit with Regions is a compiler for the programming language Standard ML .
Lots of bits of ML code licensed under the GPL .
The Mustang Project uses higher-order, typed programming langauges that provide special support the construction, manipulation, and execution of code.
This amounts to establishing an ML-oriented "equivalent" to macro expansion.
Mustang - a project exploring metaprogramming schemes particularly for ML
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...
Based on Standard ML, Alice adds extensions and builds on the experience of developing the Oz/Mozart system.
Type Preserving Garbage Collectors
Describes a GC implemented in ML.
JoCaml - OCAML augmented with support for the Join-Calculus distributed programming model.
A language from Microsoft Research based on OCAML that runs atop the .Net system (see MONO).
"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.
CDuce is a programming language based on ML adapted to the manipulation of XML documents. It seems to be a fair bit quicker than XSLT...
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.
Modelling Office Processes with Functional Parsers
A Haskell project...
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.
It holds parallels to the OR notion of Dynamic Programming as well as to spreadsheets where values are only computed as required.
Lazy evaluation schemes may be constructed in Scheme using the (delay) and
(force) functions.
Stream schemes available in OCAML, Scheme and Common Lisp as well as the CL SERIES package may be used to construct lazy evaluation mechanisms.
Free Versions Of Poplog Including POP-11, Lisp , Prolog and ML
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...
Snake Island Research Inc - Robert Bernecky - Has built an APL compiler that generates Sisal code.
Using J with OLE2 to Build Configuration Software for SAP AG.
The developers built software in J to help manage the configuration of SAP R/3 systems.
A project to try to encourage the construction of extensions to J. Particularly directed to Unix-oriented extensions.
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
David Ness' Experiments with J and K
He has some very interesting examples of the use of J and K for file processing. Quite useful if you are a beginner with these languages and are puzzling through how to use them to do things other than purely mathematical calculations.
An APL interpreter with a built-in compiler to C. Available "gratis" for Windows
FP was one of the earliest functional programming languages, created by John Backus.
Sisal - High performance Functional Language
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.
In that it uses an explicit stack as the repository for arguments, it is quite reminiscent of Forth and Postscript .
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 now Open Source system produced by Eriksson for building telecommunication systems. This language is unique in the functional community in that it is in use in industry for large scale software projects.
University of Montreal project that turns Erlang source into Gambit Scheme code that is supposedly rather efficient...
Unlambda: Your Functional Programming Language Nightmares Come True
Computer Science: Publication: Higher-order + Polymorphic = Reusable
Concepts, Techniques, and Models of Computer Programming
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.
More or less like a sort-of-APL implemented with ML syntax
SET Language, a language intended for working with sets.
A group of French scientists have put together a functional language called Anubis, strongly based on Category Theory, much like much of the recent work on languages like ML.
Compilers are available in binary form for Linux on IA-32 and recent versions of Windows. It's decidedly not free software, as source code is unavailable, and "non-personal" use is subject to licensing fees.