The joy of Elm
Elm is a purely functional programming language for creating web frontend. It is strongly typed, largely influenced by Haskell – without some of the things that make Haskell difficult for newcomers, and with much better error messages.
I’ve recently written two small (~2k lines total) side projects in Elm. Writing code in Elm is an absolute joy:
- It’s easy to get started and Elm is a simple language.
Very strong typing – seems somewhat stronger than in Haskell. Eg
List.headis of type
List a -> Maybe aand won’t crash on you in runtime – if the list is empty you get
Nothing. If it compiles it usually works.
- Elm has amazing error messages. They don’t just tell you what’s wrong, they try to explain why that could be and suggest how you could try to fix the error. I have never before encountered errors this helpful.
- There’s Ellie – a wonderful online environment to play around and share snippets.
- The Elm Slack is the most helpful and responsive community I’ve ever participated in.
- Refactoring is a breeze – it compiles it works. I’ve never had a refactoring mess up things that worked before.
That said, there are some potential drawbacks:
No higher kinded polymorphism: to map over a
List, you need to use
List.map, to map over
Set.map. This is slightly verbose and sucks for the library developers, but isn’t a big problem for the end user.
- Elm-land is an autocracy. Evan has been a very enlightened ruler, so this could also be seen as a benefit.
- The development of Elm itself is intentionally slow: they try to get it right rather than get it out quick. Some things one would like in the standard library are external libraries. The repository of Elm packages is rather comprehensive.