Functional Programming Languages

My favorite functional programming language is Clojure. I stumbled upon functional programming as a result of Clojure. Other popular functional programming languages are Haskell, Scheme, Scala, and Erlang. One of the newer functional languages is F#.

Haskell has a reputation as being a programming language that only allows functional programming. Where as a language like Clojure allows for mutation without a lot of difficulty. Haskell makes non-functional source hard to write.

Some of the other language choices out there are Erlang and OCaml/SML.

So here is the complete list:

  • Clojure / ClojureScript / ClojureCLR – for the JVM, JavaScript VMs, and .NET respectively. Clojure is a LISP like language. Everything from web pages to communications software are written in Clojure.
  • Scheme – is extremely easy to learn because it has a very small core, and very little complexity. This is a great first programming language. This is a dialect of LISP
  • Haskel – is considered the most functional of functional languages.
  • Scala – for the JVM. It is both functional and object-oriented. That makes it great for those of us that don’t want to give up our OOP.
  • OCaml – The O stands for object oriented. There is also the plain Caml that doesn’t have the object oriented parts.
  • SML – a modern ML language. That means there is a lot of maturity and history behind the language.
  • Erlang – easy to learn for first-timers.
  • F# – has great integration with .NET, managed .dll’s, and other MicroSoft technologies. Between ClojureCLR and F# you have two great functional programming languages for .NET.
  • Common Lisp – this is the grandfather of all modern LISPs.
  • Racket – part of the Scheme family. It also has great documentation.
  • Elixir – pretty good for writing web apps.

Non-functional programming languages that have hopped on the functional bandwagon include the following:

  • Java
  • JavaScript / ECMAScript
  • Python
  • Ruby
  • C#
  • C++

Here are other languages that support functional programming:

  • APL
  • ATS
  • CAL
  • Ceylon
  • Charity
  • Clean
  • Coq (Gallina)
  • Curl
  • Curry
  • D
  • Dylan
  • Elm
  • FPr
  • Frege
  • Groovy
  • J
  • Joy
  • Julia
  • Hope
  • Idris
  • Little b
  • Logo
  • Mathematica
  • Mercury
  • Miranda
  • Nemerle
  • Opal
  • OPS5
  • Poplog
  • Q (both of them)
  • R
  • Rust
  • SequenceL
  • Spreadsheets

Functional Programming Languages are Here to Stay

Before the year 2005, increased clock rate sold new computers. The each new generation of computers had better clock rates. Since 2005, clock rate has been replaced by the number of cores available to programs. Bus size, and and other features still improve, but increasingly, cores is where the most notable improvements come from.

Concurrency was mostly ignored when writing programs, until multi-core systems proved to be the wave of the future. Concurrency mattered when dealing with external events such as UIs or data retrieval from remote devices, but not for pure computational power.

After the first decade of speed bumps only coming from more cores, it was obviously the forced wave of the future. Now that multi-core systems are here to stay, modern programs need to look to concurrency for significant speed bumps. The problem with multi-threading is that it is difficult. Toy examples of locking one method or piece of data at a time don’t seem bad, but in an intricate system you will have multiple methods and chunks of data that need manipulating at once, and several threads seeking access to the same data and methods. Any complex concurrent system that is poorly written risks mutex bottlenecks, or worse yet, deadlocks.

Functional Programming prevents the need for locking data and synchronizing methods. Functional Programming uses pure mathematical functions that behave the same way no matter how many threads are hitting them at the same time. Mutation requires special considerations, but pure mathematical functions don’t have mutation. Functional Programming encourages use of immutable data that doesn’t have the risk of changing during access by multiple threads.

Functional Programmers take advantage of the multi-core revolution without the stress of side affects from multiple threads. Functional Programming allows for fully concurrent programs without locking or other threading considerations.

Lots of Functional Languages

As you can see, functional languages abound. You can choose from the popular ones that are easy to find jobs with, or from the more exciting, though less used languages. If you already program computers professionally, but have not learned functional programming, I suggest checking to see if your favorite language already supports functional programming. You can start there.

Don’t forget to read my post on the common features of functional languages.