Since the beginning of this year, I’ve programmed almost exclusively in Elm . I’ve used many languages in my career, and I want to understand why I keep coming back to Elm and how it gives me joy. Maybe even encourage you to try it or think about the features of your preferred languages in a new way.

Language design is trade-offs all the way down. Elm has a pragmatic, minimal static type system that helps eliminate whole classes of runtime errors.

It has all the things you need to do disciplined functional programming — sum types, product types, exhaustive pattern matching, pure and strict evaluation and parametric polymorphism. It skips the things that add complexity — both syntactical and structural — like higher-kinded types and complex type classes.

At least, that’s the computer science answer to why Elm is good — it makes perfectly reasonable trade-offs. I have some more human answers to why I enjoy working in it.

Coming from Java and Ruby/Python, I viewed the type system as a puritan spoiler of fun. A Malvolio railing against my wit and manners through the medium of compilation errors. Functions or methods want to be free and the type system exists to restrict them.

I see it differently when I’m working in Elm. The type system is a positive thing that brings new values into the world. Instead of restricting the valid values in a program, it’s the magical thing that lets us create new values every bit as fundamental as the built-ins. Giving, in the words of the poet, “to airy nothing a local habitation and a name.”

It’s a change in mindset that makes me feel creative and inspired while working. It can go too far, become too abstract. Haskell does this for me — when I work in Haskell I find that I’m less building things up Lego-style than fitting things into an existing set of mathematical abstractions. With Elm I appreciate the so-far-but-no-further algebraic limits.

There are other things that ‘fit’ my brain mechanics too.

I have a freakishly bad working memory. It’s not that I can’t remember things — it’s that my memory doesn’t often show up. I have an extraordinary memory. When I was twelve, I placed third in a national memory competition from a field of thousands, winning all the hardest events. But, in real life, no-one asks you to memorize a pack of cards. In real life, they expect you to come back from the shops with the things you went for. That’s something I can’t do and, despite ongoing work on myself, something that causes me deep shame.

I like how Elm’s exhaustive and total functions act as a crutch for my attention. When I’m deep in a codebase, I can’t hold the entire state of an application in my head; I lose the thread of “what happens if this is null?” or “what if the user isn’t logged in?”. Elm doesn’t let me forget. By forcing me to handle every case the compiler compensates for the working memory I lack. It can be a pain having to handle every edge case — but it’s also often a signal that something about the design is wrong. I appreciate that nudge.

The enforced purity keeps my errors local. In other languages, a tiny change on line 100 can ripple outwards, breaking things in a module three layers deep, hidden behind a side effect I didn’t foresee. I’m actually pretty good at handling that, but I’d rather not. In Elm, if I break something, the error is isolated. I can trace it, fix it, and know it won’t quietly poison some other part of the system. I have to say, in the past I’ve often used this anxiety as motivation and it’s taken a while for me to understand that freedom from anxiety is also a gift.

The language’s limitations are its greatest feature. It’s usually framed in terms of reducing cognitive load but for me there’s an aesthetic aspect to the minimalism that I respond to. I have never been able to fathom languages like Perl — I need to sit back after I’ve written something and think, yes, that looks clean.

I know that the industry being what it is, I won’t be writing Elm forever. I’ll likely find myself back in the faster-moving waters of Ruby or Python soon. And of course, I’ll bring some of Elm with me. You might like to try Elm — can you tell I’m a fan? Trying different languages makes you a stronger programmer but, maybe more importantly, tells you something about what kind of thing brings you joy.