Introduction

In this post we will be looking at some popular choices of functional programming languages that compile to javascript. There will be the most emphasis on support of these languages both by the development of the compiler as well as the supporting ecosystem by looking at the packages made for the language. Some languages are infact not a new language but a flavor of an existing language specifically for targetting JS.

With packages

Name since commits commits / year contributers Contributers > 100 commits packages package site
elm 15-04-12 5655 808 78 1 (excluding bot) Yes 848 https://package.elm-lang.org/
purescript 29-09-13 3996 799 156 4 Yes 870 https://pursuit.purescript.org/
clojurescript 29-05-11 5687 711 184 5 Yes 722 https://cljsjs.github.io/
scala.js 01-05-11 5323 665 68 3 Yes/No 1434 * https://index.scala-lang.org/search?q=*&targetTypes=Js
reasonml 14-02-16 1808 603 119 5 Yes 297 https://redex.github.io/all
  • packages that can compile to JS. But not neccesarily written for browser API’s

Without packages

Name since commits commits / year contributers Contributers > 100 commits packages package site
fable 10-01-16 3266 1089 98 3 Compatibility with .NET base and F# core. No browser specific packages. Not specific for Fable
elixirscript 25-01-15 1363 341 27 1 No n/a
ghcjs 14-08-10 1273 141 46 2 Some for browser not specific for ghcjs

Observations

Packages

There are three contenders with the most mature package repositories: elm, purescript en clojurescript.

Scala.js, ReasonML, Fable and GHCJS try to leverage existing packages which were not written specifically for the browser.
Of those four languages scala.js, reasonml and ghcjs have packages specifically for the browser.
But only with scala.js and reasonml these packages are searchable on a website.

Elixirscript is still very young and at first sight nothing can be found about any packages.

Backing

Some languages are mainly being developed by a single person: elm, elixirscript and ghcjs.

Other languages have corporate backing and are developed by multiple persons: ReasonML and Fable.

Purescript, clojurescript and scala.js seem to be community projects that work well.

Recommendation

Working with a functional programming language is great. Just don't underestimate the value of available packages. Having to write a lot of supporting code yourself can really hurt productivity.

Scala.js has been in development for a long time and has good traction and can leverage a lot of packages, it remains however unclear at first site which packages where written specifically for browser API's like DOM. If you are interested in scala i encourage you to give scala.js a more thorough look.

Fable and ReasonML look really promising for the future but are not as mature as some other options.

Currently elm, purescript and clojurescript seem to have the best story when it comes down to packages.

Those three can be split into two families. Where clojurescript falls into the Lisp family and Elm and Purescript falls into the Haskell family. These families of languages have a lot of differences so choose wisely.

When you are going for Elm or Purescript both are mature. Purescript being a more advanced language where Elm is more beginner friendly, but still powerful. Purescript is a more community driven and can rely on a greater number of programmers.

Conclusion

If you have your reasons to choose a specific language, for example you are already on the .NET eco system, it can make sense to choose a matching FP language with your platform. If you are starting fresh without any additional requirements Clojurescript and Purescript are your safest bet.