elm christmas

Hello world!

Next post →

What is Elm?

A 3 min read written by
Ingar Almklov

This one is for you who have not heard of Elm before, or maybe you have heard the name mentioned somewhere but never gotten around to checking out what all this fuss is about.

What is Elm?

Elm is, according to https://elm-lang.org, a delightful language for reliable webapps.

It started out as Evan Czaplicki's thesis in 2012 called Elm: Concurrent FRP for Functional GUIs. The thesis examined using Functional Reactive Programming as a pattern for building GUIs, and the language Elm was built for this purpose. Already at that point Elm was a language made for being run in the browser. The thesis included a fully functional compiler for Elm, and an interactive editor that allowed you to write and run Elm online.

On the technical side Elm is a purely functional programming language that compiles to JavaScript. It is made for being a language that is easy to learn and to use. Because of this, Elm's feature set is quite small. This does not mean that there are few things you can do in Elm, but rather that for each thing you'd want to do there is usually only one way to do it. This is good for beginners as there are fewer things you'll have to learn when starting out with Elm.

Elm also has static typing and type inference, a package manager that _enforces semantic versioning(!)_, a REPL and an ecosystem of community created packages. Perhaps one of the biggest selling-points of Elm is that it has "no runtime exceptions"! This might seem like an impossible feat, but reports tell us that it holds true (unless you specifically tell your code to crash)! We will go into more detail on these features in later articles.

Most Elm projects use elm-format. If you are familiar with prettier for JavaScript, gofmt for Go or rustfmt for Rust you know the drill. This tool will take care of all code formatting for you so you don't have to worry about it at all. One thing to note is that elm-format formats the code according to the official Elm Style Guide and does not accept any configuration. Because of this the code might not be formatted exactly the way you want it, but it has the added benefit that all Elm code in the ecosystem is formatted the same way. Also, no more arguing with your team whether to use tabs or spaces or where to place curly braces!

Getting started

So, that was a brief introduction to what Elm is. Hopefully, you are sitting there wondering how to get started writing some Elm code and trying it out for yourself.

Some useful resources are found in the links below. If you like to learn by reading, the official Elm guide and "Elm in Action", a book by Richard Feldman, are great. If you prefer to code along, "Elm Tutorial" by Sebastian Porto focuses on developing single-page web applications (note: it is currently not updated for Elm 0.19) and "Elm Arcade" (shameless plug, as this was made by me and my colleague Erik Wendel) serves as a starting point for learning Elm through making simple games.

If you want to just dive in and look at and try writing some Elm code, check out Ellie, an online Elm editor!

And of course, check back here every day until December 24! Each day we will have a new article about Elm. Also, visit our siblings:

Next post →