A ProgrammingLanguage is called functional if it supports and/or encourages FunctionalProgramming. ''Dysfunctional otherwise. *Arr arr arr*'' A list of FunctionalProgrammingLanguage descriptions and links: * Haskell [HaskellLanguage] - the archetypal FPL in the 1990s, it is lazily evaluated (as opposed to strictly or eagerly evaluated, see LazyEvaluation), StaticallyTyped and supports input/output, GUIs, animation, databases, COM and ActiveX, etc. I.e. all the usual "side effects" that are not usually considered to be practical in functional programming are practical in Haskell with ReferentialTransparency (See OnMonads). There are several open source systems. See also TemplateHaskell. * Erlang [ErlangLanguage] - the champion FPL in the 1990s, it is DynamicallyTyped, mostly functional (i.e. supports some imperative side effects that break ReferentialTransparency). Erlang applications are composed from CommunicatingSequentialProcesses (shared nothing message passing). This is the champion FPL for the 1990s because was developed by Ericsson and is used in several released products (switches, etc.) for soft real time distributed telecommunications. There is one open source system that includes a CORBA ORB, Naming service, Event service, a distributed soft real time database with nested transactions, replication, and a query language, among other goodies like SNMP, HTTP, etc. * ML [MlLanguage] e.g., SML [Standard ML, SmlLanguage], SML/NJ, CAML, CAML-light, ObjectiveCaml, AliceLanguage, FsharpLanguage, etc. Statically typed, eagerly evaluated, etc. Interesting ways of combining source code based on "functors" (basically, mappings from collections of functions to collections of functions). * CommonLisp (and others)-- though impurely, and as only one of the many paradigms supported * Scheme [SchemeLanguage] (and variants)-- though impurely, and as only one of the many paradigms supported * m4 (the macro processor), which is available in almost any UnixLike environment, is largely functional even though it supports imperative features. It has an exotic LevelOfQuoting concept, and allows all kinds of quirks by being ultimately text-based. Implementations often have undocumented limitations which causes your macro expansion to fail in spectacularly bamboozling ways. * FP - an interesting twist on functional languages -- no variables! You write programs by composing functions into new functions. Mostly a proof-of-concept language, little real use, but interesting to play with. It is described in JohnBackus' ACM TuringAwardLecture "CanProgrammingBeLiberatedFromTheVonNeumannStyle" (1977). This is the functional language that made functional programming an (academically) household name. Succeeded by FL. * FL - As with FP in nearly every respect, it remained a research vehicle at IBM, ultimately providing a foundation on which Iverson's AplLanguage and JayLanguage builds on. * CindyScript the functional scripting language of Cinderella * Clean [CleanLanguage] * Clojure [ClojureLanguage] A lisp variant that emphasizes functional programming more than other dialects (and more than other paradigms). * Gofer [GoferLanguage] * Miranda [MirandaLanguage] - a language designed during the 80's that was a precursor to Haskell, using a very similar syntax. (A short introduction is at http://blackcat.brynmawr.edu/~kimberly/Miranda.html). * J [JayLanguage] * Joy [JoyLanguage] - a purely functional language based on the composition of functions * Pizza [PizzaLanguage] - Extension of Java with ParametricPolymorphism, HigherOrderFunction''''''s and AlgebraicType''''''s. * Nemerle [NemerleLanguage] - an OO/functional language for the CommonLanguageInfrastructure with hygienic code generating macros, algebraic datatypes and matching, higher order functions, lexical closures, and partial type inference (types are only inferred within methods, in order to avoid accidental changes to class interfaces). Syntax is superficially similar to C#, but the language is semantically more similar to MlLanguage and descendants. * Mercury - The MercuryLanguage is a new logic/functional programming language, which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features. Its highly optimized execution algorithm delivers efficiency far in excess of existing logic programming systems, and close to conventional programming systems. Mercury addresses the problems of large-scale program development, allowing modularity, separate compilation, and numerous optimization/time trade-offs. * Pure [PureLanguage] - Term-rewriting language. http://code.google.com/p/pure-lang/ * The UnLambdaLanguage has only functions. ''(But it's probably of theoretical interest only.)'' It's an EsotericProgrammingLanguage. * There is also another (purer) functional EsotericProgrammingLanguage: Lazy-K. * Opal -- http://uebb.cs.tu-berlin.de/~opal/opal-language.html * Refal [RefalLanguage] * Dylan [DylanLanguage] -- allows functional programming style, but also imperative/o-o style * Needle [NeedleLanguage] -- similar to Dylan, but leans more towards the statically-typed side * Goo [GooLanguage] -- Scheme with some concepts (notable GenericFunction''''''s) borrowed from Dylan. * Mathematica [MathematicaLanguage] -- the crux of the MathematicaPackage produced by WolframResearch * XSLT [XsltLanguage] -- "The Functional Programming Language XSLT - A proof through examples" http://www.topxml.com/xsl/articles/fp/ * Scala [ScalaLanguage] * Ruby [RubyLanguage] -- pretty mix of functional and object oriented * Pick language and derivatives - OpenInsight, AdvancedRevelation, Universe, Unidata, Maverick, Jbase and many others. ---- ''What are the criteria for inclusion above?'' There will be different opinions. I would include any language that encourages a functional style of programming. So ML and CommonLisp and Scheme could be in this list. ''What about Lisp? Too old? Too many side effects? Too many dialects?'' Each Lisp should be listed on its own since they are so different especially in how they encourage functional programming. Clojure is the most "functional purist" of them, followed by Scheme and Common Lisp (in that order), which like to think of themselves as being multi-paradigm. ''What about Pizza? Too young? Too short-lived? Too close to Java?'' I would include Pizza since it extends Java by adding first-class functions, and so encourages a functional style of programming. Much more so than the anonymous classes of Java. ''What about Prolog? Too old, too academic?'' You cannot define a function in the PrologLanguage, or apply a function to its arguments. Prolog is not about functions, it is about predicates; it is a LogicProgrammingLanguage. However, both Erlang and Mercury were developed from Prolog. ''What about PythonLanguage?...'' Guido seems to have spent a lot of breath convincing us that Python is ''not'' a functional programming language. Guido even wanted to remove lambdas; however, public outcry ultimately forced him to keep lambdas in the language. ''Guido wanted to remove lambdas in the belief that named functions are easier to read, not out of any particular dislike for functional programming. Python contains functional features adopted from many other languages, such as Haskell's list comprehensions and LISP's map/filter/reduce (= Haskell foldl). Use of first-class functions is common in the standard library's API.'' ---- There is some discussion about the relative advantages and disadvantages of FunctionalProgramming and ObjectOrientedProgramming and about the degree that FunctionalProgramming and ObjectOrientedProgramming can be used in the same language. See FpVsOo, OoVsFunctional, ClosuresAndObjectsAreEquivalent. ---- ''What about CeeOmega and C# 3.0? They have a hybrid mix of imperative and functional paradigms.'' Those are basically vaporware at the moment, aren't they? If so, then who knows what directions they may take in the future. ---- ---- Most newer FunctionalProgrammingLanguage''''''s support static type-checking, so if you have a function f of type A->B i.e. f takes an arg of type A and returns a result of type B, and an expression x of type A then you can apply f to x to get something of type B. Since functions are first class citizens the x could it self be a function. E.g. suppose I want a function dot which takes two functions and returns a function which applies the second fn then the first fn , its type would be:- dot :: (b -> c) -> (a -> b) -> (a -> c) (using Haskell syntax - x :: T means x is of type T. Identifiers in types starting with lower case are TypeVariable''''''s and denote arbitrary type. That is called ParametricPolymorphism). It could be defined as:- dot f g = \x -> f (g x) (The "\x -> .." part is an AnonymousFunction.) This would be another way of defining dot:- dot f g x = f (g x) (The dot function is actually defined as an infix "." operator in HaskellLanguage) Another example is the curry function from the Haskell prelude :- curry :: ((a,b) -> c) -> (a -> b -> c) curry f x y = f (x,y) i.e. it takes a function which takes it arguments as a pair and returns an equivalent function which takes it arguments in a curried form. (See CurryingSchonfinkelling.) Hence functions can be manipulated in a quite sophisticated fashion. Try to do this in C++/Java and you will probably have to write an FP interpreter. -- JonHanson I wonder if you could write an FpInterpreterUsingTemplates? ----- '''[CleanLanguage]''' To do I/O in Clean in a functional way, you pass the world around, and compute new values of the world. Because Clean has UniqueType''''''s, the Clean compiler can guarantee that there is always only one live copy of the world around. Therefore, it can mutate the world in-place, rather than having to copy it entirely, which would be computationally costly, to say the least. ;-) Haskell doesn't have UniqueType''''''s, so it cannot take this approach. Therefore it uses monads. ''This is a subject of HolyWar''''''s, but ''I'' prefer using monads to UniqueType''''''s. Monads are at least native functional constructs and don't need specific language support. Besides, you get rid of the explicit passing of world - which has no benefit anyway, because you can't copy the world.'' UniqueType''''''s aren't used just for IO, other uses include arrays with destructive updating. Also UniqueType''''''s are easier to use when you want to write code that has two kinds of effects (e.g. read a file and put the contents in an imperative array). In Clean you can freely mix the two kinds of UniqueType''''''s where in Haskell you need to write some specific monad transformer to let you mix IO and State monads. Also you can have monads (modulo syntatic sugar like DoNotation) in Clean, but the inverse isn't possible in Haskell. Saying that UniqueType''''''s can be very hard to grok. ---- '''[JayLanguage]''' I've been peeking at J, from http://www.jsoftware.com/, and see the ad phrase that says "OOP is easy with J4!". But reading the documentation, I can't see that "locales" can be constructed as variables, so I can't see how to implement polymorphism or inheritance. Anyone got a clue? --AlistairCockburn, 7/99 ''[I believe the "J4 makes OOP easy!" statement was some part fluff, in response, after OO abilities were added, to many previous "Does J do OOP?" questions.]'' It doesn't look OO at all to me, it looks like Backus's FP revived. Where does it say that OOP is easy with J4? I think I am too old to decipher line noise any more. --JohnFarrell It says, "J4 makes OOP easy! New language extensions include hierarchical paths and object locales that can be dynamically created and referenced. The underlying primitives allow you to follow the OOP model exactly. The new facilities are of general applicability, and so powerful and easy to use that they should dramatically improve the way we build systems in J. " from the j download page. http://www.jsoftware.com/download/download.htm ? Maybe the page has changed. The site now talks about J403. ''[J4 refers to all releases numbered J4xx; J403 is the 3rd revision of J4.]'' I don't recall anything that I would consider object-oriented in J, though I don't consider that a problem. The locales seemed to be more a module or namespace feature. -- WardCunningham ''The documentation for some recent features (OO, sparse arrays, memory mapped nouns) has not made it to the manuals and help files. Instead, Lab session scripts (which provide interactive tutorials) are included, but they are not fully meaningful outside of a J Session. J's OO abilities are implemented using locales. It's worth downloading a trial copy just to go through the labs. -- JimRussell'' Don't know if it's of any help, but I've been playing with a simple OOP example in a number of different languages - mostly for recreational reasons ( see http://w3.one.net/~jweirich/oostuff/ ). I've completed the example for the J language (as well as a couple of others) which can be found at http://www.angelfire.com/tx4/cus/shapes/index.html . -- ChrisRathman [2001/08] A HTML Manual is installed together with the software, which is more up-do-date than the PDFs on the download page. In the manual for the free edition for windows I found a chapter on OOP. Its path is \system\extras\help\learning\25.htm http://www.jsoftware.com/download/download.htm ---- '''[C++]''' You can get currying in native CeePlusPlus using Templates. And a form of lambda functions are also possible. See * BoostLambdaLibrary - part of the BoostLibraries * http://www.fz-juelich.de/zam/FACT * FunctoidsInCpp (http://www.cc.gatech.edu/~yannis/fc++/) See also FunctionalProgrammingInCpp. ---- '''[PHP]''' PHP programmers may want to check out this library that adds some functional programming abilities to PHP4. See * http://functional-php.sourceforge.net/ ---- '''[AlephLanguage]''' (See http://www.aleph-lang.org/). From the website: "Aleph is a multi-threaded functional programming language with dynamic symbol bindings that support the object oriented paradigm. Aleph features a state of the art runtime engine that supports both 32 and 64 bits platforms. Aleph comes with a rich set of libraries that are designed to be platform independent" The last release is from mid-2001 but the language is kinda interesting, and the compiler is really cool (written in C++, it compiled without errors on gcc 2.96.x and just two unprotected #define's in a couple of header files in gcc-3.2. No warnings. It's a shame they don't seem to be developing/supporting it further. Maybe it can be saved if we manage to get a community effort (licenses providing, the compiler was FreeSoftware). * ''(Update: I have managed to get in touch with Aleph author, AmauryDarsch, and he's indeed silently working on version 0.9.0, with updates on the web site coming soon. Joy!)'' ---- ChristophePoucet asks WhichFunctionalLanguageToLearn. ---- 20081106 -- ChrisGarrod asks would it be ok to alphebetize the languages on this page? That would be reasonable, but I would consider ensuring there is a list naming the most 'mainstream' FPLs at the top (Haskell, ML, Erlang). Other orders that are okay would be order of creation. ---- April 2010 What kind of programs do you think are written more easily in FP languages? Specifically for people who use FP and non-FP languages - what situations do you find yourself using FP languages for? For example, I'm an aspring academic. Are they especially suited to mathematical and/or logical thinking? Number crunching? --JasonEspinosa ---- Is LuaLanguage a functional programming language? I was just debating this with someone who claims it is not. But if not, what disqualifies it (that does not also disqualify SchemeLanguage?) ---- WhyFunctionalProgrammingLanguagesArentMainstream ---- CategoryFunctionalProgramming