Part of:

Functional Programming Languages: Past, Present and Future

Why Trust Techopedia
KEY TAKEAWAYS

To better understand this distinct class of programming languages, we’ll look at the definition, characteristics and the history associated with it.

Clojure, Elixir, Elm, F#, Haskell, Idris and Scala are all names you are likely to see among recommendations for functional programming languages worth learning. These are the languages in use today and which may well be in use in years to come.

A language like haskell features the most longevity, but even more recent ones like Clojure are actually rooted in earlier languages that continue to shape the evolution of functional programming (FP). (Read Straight From the Programming Experts: What Functional Programming Language is Best to Learn Now?)

To better understand this distinct class of programming languages, we’ll look at the definition, characteristics, and the history associated with it. (Check out INFOGRAPHIC: The History of Programming Languages.)

Why Is it Called Functional Programming?

FP gets its name from an approach to software construction built off the creation of pure functions. The foundation of all functional programming languages is Lambda Calculus (also written as λ-calculus). It is described as “the smallest universal programming language of the world.”

Accordingly, an FP is based mathematical functions that employ conditional expressions and recursion to perform the calculation. It includes the following characteristics:

  • The data contained in it is immutable.
  • It avoids side effects, which are any state changes which occur outside of a called function, and shared states.
  • FP programming is easier to maintain as you don't need to worry about accidentally changing anything outside the given function.
  • It has referential transparency.
  • Modular design allows for small modules that can be coded quickly and are likelier to be able to be reused, which contributes to faster program development. Also the modules can be tested individually separately which can reduce the time spent on testing and debugging.

Rooted in Mathematical Functions

As functional programming is rooted in Lambda Calculus, its history would date back to the 1930s when Alonzo Church introduced it. Of course, it wasn’t used for computers then.

Advertisements

1960

I wasn't until 1960 when an an American computer and cognitive scientist named John McCarthy published Recursive Functions of Symbolic Expressions and Their Computation by Machine. As a result of his research into such function, McCarthy created what is recognized as the first functional programming language: LISP.

A good summation of it can be found in The birth of LISP – a summary of John McCarthy’s original paper. The language had offshoots, including Common Lisp, Scheme and elisp, not to mention Clojure, which is currently very much in use.

As explained here, the capabilities built into LISP shaped the way functional programming is used even today.

  • Use closures to implement static scoping. For example, in "let x = 3 in f = λ y. x + y", function f is not closed since it has a free variable x. To use f, it has to be bound with an environment that tells the value of x. A function with the environment for its free variables is called a closure.
  • Invention of the conditional expression and its use for writing recursive functions. This has something to do with the evaluation order of expressions (see lazy evaluation).
  • Use higher-order operations on list such as the mapcar function.

It also introduced what is called “garbage collection.” This is an important feature for functional langauges because they “tend to generate larger amounts of short-lived garbage than imperative languages do.“

1978

Nearly two decades later, the next major advance took place at the University of Edinburgh where researchers defined the ML (Metalanguage). The researchers required a language that would work for their automatic theorem proving system (LCF).”

ML fit the bill for that, and they also found in 1978 that it could be useful as a a general programming language. Versions include Standard ML of New Jersey and CAML.

Another name associated with the year 1978 and Edinburgh is Hope. The source of the name is Hope Park Square, where Edinburgh's Computer Science Department was (but also for Higher Order Parameters and ‘springs eternal’ and so forth.)” Hope is distinguished as the first language to employ call-by-pattern.

1990 to present and beyond: Haskell

Haskell, named after the logician Haskell B. Curry, was the product of a committee that set out to work on formulating the language in 1987 and released the first version in 1990. The latest standard is Haskell 2010, and another version is slated for 2020.

Haskell has become the paradigm of modern functional languages, distinguished by “features such as higher-order functions, type inference, lazy evaluation and user-defined datatypes.”

Higher-order functions take other functions as arguments or return them as results. They allow for applications that could also be called currying. Doing that will individually apply a function to its arguments, and as each application returns a new function, it then accepts the next argument.

While laziness is generally considered a bad thing, it is does serve a purpose in programming. As explained in What is Lazy Evaluation? In contradistinction to “strict evaluation,” the approach of lazy evaluation is to evaluate only what is required.

Current Top Functional Programming Languages

Haskell is the most dominant name for this category, likely because of its extended history relative to other FPs. It also was a major influence on their development. Simon Peyton Jones, principal researcher at Microsoft and key contributor to Haskell, spoke about Haskell’s enduring influence both in its own right and in the way it shaped other languages.

"Things like Linq, the language-integrated query stuff in C#, that's straight from Haskell actually. F# workflows are drawn directly from this [Haskell's] monadic I/O story."

Clojure

Clojure is a new dialect of Lisp created by Rich Hickey. Ihat distinguishes Clojure from other LISP dialects is that it runs on the Java platform and is compiled to JVM bytecode. The advantage that offers is its integration with Java even those that were not written in Clojure.

As Hickey explains in Clojure.org says, “Clojure provides easy access to the Java frameworks, with optional type hints and type inference, to ensure that calls to Java can avoid reflection.”

It also says, that “Lisp's approach to code-as-data and its macro system still set it apart” from other Lisp dialects, and adds that its “maps, sets, and vectors are as first class in Clojure as lists are in Lisp.”

Hickey also shared his rationale for creating Clojure as reaping all the benefits of Lisp without some of its drawbacks. After setting out multiple bullet points under different headers, Hickey sums it up as follows: “In short, I think Clojure occupies a unique niche as a functional Lisp for the JVM with strong concurrency support. “

Elm

Elm is the name of a purely functional language first designed by Evan Czaplicki in 2012. It is popular among web developers who like it for building user interfaces. The Elm compiler targets HTML, CSS, and JavaScript. It works with JavaScript libraries in much the same way as Clojure works with Java libraries.

What’s different about Elm is that it uses static type checking, which aids in the elimination of runtime exceptions as the errors would be caught at compile time. As the Elm site boasts, “NoRedInk switched to Elm about two years ago, and 250k+ lines later, they still have not had to scramble to fix a confusing runtime exception in production.”

The absence of visible errors on the user end, is an obvious advantage for a language. That may be why it also feels justified in applying the description of: “A delightful language”, to itself.

Elixir

As the Elixir's site describes itself: “Elixir is a dynamic, functional language designed for building scalable and maintainable applications.” Elixir is directed toward creating high-availability, low-latency systems. It runs on the Erlang VM, an ecosystem that is used by Heroku, WhatsApp, Klarna and others for “distributed, fault-tolerant applications.”

The advantage for Elixir programmers is that they can invoke an Erlang function without incurring any runtime cost.

F#

F# is an open source, cross-platform, functional-first programming language. Anyone can join the F# Software Foundation. The foundation’s site sums up the language this way:

F# runs on Linux, Mac OS X, Android, iOS, Windows, GPUs, and browsers. It is free to use and is open source under an OSI-approved license.

F# is used in a wide range of application areas and is supported by both an active open community and industry-leading companies providing professional tools.

Idris

Idris is a general purpose pure functional programming language that has featureds influenced by Haskell and ML.

As explained here, it is characterized by dependent types, which enables "types to be predicated on values, meaning that some aspects of a program’s behaviour can be specified precisely in the type.” It is also distinguished by being compiled, with eager evaluation.

JavaScript

While JavaScript is not strictly a functional programming language in that it also allows for an object-oriented approach, it does have component that stem from functional programming. That includes higher-order functions. Also newer versions of the ECMAScript standard provide fixes for the problem of mutability.

Kotlin

Among the newest of languages (released only in February 2016), Kotlin was five years in the making and the testing. Companies like Amex, NBC Digital, Expedia, and Gradle use it. It’s not a pure functional language.

Like JavaScript, Kotlin is capable of both object-oriented and functional constructs. Plus, it is completely interoperable with Java programming languages.

Among the benefits it offers is that it is more concise than Java programming. Some think it’s possible to cut out over a third of the lines of code. It also offers all the advantages associated with functional programming languages, including higher-order functions, extension functions and lambdas.

Its versatility make it suited “for any kind of development, be it server-side, client-side web and Android,” and it is working on becoming compatible with Apple’s iOS.

Scala

Scala is another hybrid in that it offers both object-oriented and functional programming.

“Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries,” as it explains on its site.

What We've Learned

Telstra’s Big Data Analytics GM Mark Moloney sums up why we it is now time to embrace functional languages and why programmers should consider learning them:

One myth is that functional programming is hard or too academic. It is just another skill to learn. It takes time and practice to master — no different to the journey that developers went through to learn object-oriented programming in the late 80s / early 90s. Technology continues to evolve. It is one of the reasons I love software. Learning how to learn is as important as what you know.

Advertisements

Related Reading

Related Terms

Advertisements
Ariella Brown
Contributor
Ariella Brown
Contributor

Ariella Brown has written about technology and marketing, covering everything from analytics to virtual reality since 2010. Before that she earned a PhD in English, taught college level writing and launched and published a magazine in both print and digital format.Now she is a full-time writer, editor, and marketing consultant.Links to her blogs, favorite quotes, and photos can be found here at Write Way Pro. Her portfolio is at https://ariellabrown.contently.com