Functional Codi
6 Mar 2018
•
5 min read
The development of modern functional languages kicked off with the Turing Award Lecture by John Backus, the creator of Fortran, titled Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs.
Below is a quick primer to the six main languages that have developed since then. They are listed in alphabetical order, not with any ranking or preference.
Clojure is a Lisp-based functional language hosted on the Java Virtual Machine. It was designed for running programs concurrently, while incorporating all the benefits of Lisp, the functional paradigm and the java ecosystem.
It was created by Rick Hickey in 2007, who is currently the CTO of Cognitect. They provide commercial support for Clojure (and Datomic), and are based out of North Carolina, USA. Clojure is maintained in the clojure/clojure repository. The main conferences include Clojure/conj, Clojure West and EuroClojure. Clojure is used by the Functional Works, uSwitch and DRW.
Example from Rosetta Code: 99 Bottles
(defn sing
[start]
(doseq [n (range start 0 -1)]
(printf "%d bottles of beer on the wall,
%d bottles of beer,
Take one down, pass it around,
%d bottles of beer on the wall.\n\n"
n
n
(dec n))))
(sing 99)
Erlang refers to the mathematical unit Erlang, and is an abbreviation of Ericsson Language. It was designed to be scalable and fault tolerant, with Erlang applications being famous for a 99.9% uptime. It was originally proprietary but is now open source.
It was created by Joe Armstrong, Robert Virding and Mike Williams in Ericsson’s Computer Science Lab, Stockholm, in 1986. Robert Virding works as principal language expert at Erlang Solutions, a company that provides commercial support for Erlang.
Erlang is maintained in the erlang/otp repository.
The main conferences include the Erlang User Conference and Erlang Factory, both of which are run by Erlang solutions.
Erlang is used by Whatsapp, Couchdb, Gambit Research and is responsible for providing connection for 40% of the world’s mobile internet.
Example from Rosetta Code: 99 Bottles
-module(beersong).
-export([sing/0]).
-define(LIMIT, 99).
-define(TEMPLATE_0, "~s of beer on the wall, ~s of beer.~nGo to the store and buy some more, 99 bottles of beer on the wall.~n").
-define(TEMPLATE_N, "~s of beer on the wall, ~s of beer.~nTake one down and pass it around, ~s of beer on the wall.~n~n").
print_verse(0) -> io:format(?TEMPLATE_0, phrase(0));
print_verse(Bottle) -> io:format(?TEMPLATE_N, phrase(Bottle)).
phrase(0) -> ["No more bottles", "no more bottles"];
phrase(1) -> ["1 bottle", "1 bottle", "no more bottles"];
phrase(2) -> ["2 bottles", "2 bottles", "1 bottle"];
phrase(Bottle) -> lists:duplicate(2, integer_to_list(Bottle) ++ " bottles") ++
[integer_to_list(Bottle-1) ++ " bottles"].
sing() -> lists:foreach(fun print_verse/1, lists:seq(?LIMIT,0,-1)).
F# is a functional-first language, interoperable with .NET languages and libraries, and designed to speed up production time and simplify data-rich programming.
It was created by Don Syme in 2005, at Microsoft Research (based in Cambridge), where Don Syme is still a principal researcher. F# is maintained in the fsharp/fsharp repository.
The main conferences include Code Mesh and DDD East Anglia. F# is used by Jet, Gamesys and Microsoft Research.
Example from Rosetta Code: 99 Bottles
let rec bottles n =
let (before, after) = match n with
| 1 -> ("bottle", "bottles")
| 2 -> ("bottles", "bottle")
| n -> ("bottles", "bottles")
printfn "%d %s of beer on the wall" n before
printfn "%d %s of beer" n before
printfn "Take one down, pass it around"
printfn "%d %s of beer on the wall\n" (n - 1) after
if n > 1 then
bottles (n - 1)
Haskell is named after Haskell Curry, an American mathmatician / logician. A committee came together in Portland, in 1987 (at the progenitor of the International Conference on Functional Programming), to consolidate current functional programming research efforts into a single language.
In 1990, this became Haskell, which was designed to be a pure, general-purpose functional language.
The main creators of Haskell are considered to be: Simon Peyton Jones, who is also a Principal Researcher at Microsoft Research; Phillip Wadler, who is a Professor at the University of Edinburgh; Paul Hudak, who was a Professor at Yale University; and John Hughes, who is a Professor at Chalmers University of Technology.
Haskell is maintained in the haskell/haskell-platform repository. The main conferences include the Haskell Symposium and the ICFP. Haskell is used by Facebook, Takt, LeapYear, Digital Asset, Inchora, Front Row, First Republic, IOHK, investment banks and quantitative trading firms, as well as for small internal projects in various industries.
Example from Rosetta Code: 99 Bottles
main = mapM_ (putStrLn . beer) [99, 98 .. 0]
beer 1 = "1 bottle of beer on the wall\n1 bottle of beer\nTake one down, pass it around"
beer 0 = "better go to the store and buy some more."
beer v = show v ++ " bottles of beer on the wall\n"
++ show v
++" bottles of beer\nTake one down, pass it around\n"
++ head (lines $ beer $ v-1) ++ "\n"
OCaml was originally called Objective Caml, as it added object orientation to the Caml language. It was designed for safety, intended to be used in systems where errors would be incredibly costly.
It was created by developer teams at Inria, the French Institute for Research in Computer Science and Automation. Three teams have led OCaml development since its release in 1996: Formel, Cristal, and Gallium. OCaml is maintained in the ocaml/opam repository.
The main conference is OCaml 2015, with the largest meetup being OCaml Users in Paris. OCaml is used by Facebook, Jane Street and others.
Example from Rosetta Code: 99 Bottles
for n = 99 downto 1 do
Printf.printf "%d bottles of beer on the wall\n" n;
Printf.printf "%d bottles of beer\n" n;
Printf.printf "Take one down, pass it around\n";
Printf.printf "%d bottles of beer on the wall\n\n" (pred n);
done
Scala was designed for projects that need to scale. Scalable language became Scala. It is interoperable with Java, embraces the Object Orientated paradigm as well as Functional, and has the same benefits as Clojure by being based on the Java Virtual Machine. It was created by Martin Odersky in 2003, at École Polytechnique Fédérale de Lausanne. Martin Odersky currently serves as Chairman of Typesafe, head-quartered in Switzerland, a company created to provide commercial support for Scala. Scala is maintained in the scala/scala repository.
The main conferences include Scala Days, Scala by the Bay, and Scala World. Scala is used by many companies, from big names such as Twitter, IBM, Verizon etc. to small-medium companies as IOHK, Novus Partners, OVO Energy, Chartboost, Infusion, ZocDoc and many others.
Example from Rosetta Code: 99 Bottles
99 to 1 by -1 foreach { n =>
println(
f"$n%d bottles of beer on the wall\n" +
f"$n%d bottles of beer\n" +
f"Take one down, pass it around\n" +
f"${n - 1}%d bottles of beer on the wall\n")
}
Thanks for finishing the post :)
If you're looking for a job using functional programming, check out our job board!
Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ
108 E 16th Street, New York, NY 10003
Join over 111,000 others and get access to exclusive content, job opportunities and more!