TypeScript

Considering Elm Lang for future

I kept hearing about Elm in conference talks. "No runtime exceptions." "Compiler as assistant." So I spent a few weeks building a small project with it. H...

14 Oct 2023

Considering Elm Lang for future

I kept hearing about Elm in conference talks. "No runtime exceptions." "Compiler as assistant." So I spent a few weeks building a small project with it. Here's what I found.

What Elm actually is

Elm is a functional programming language that compiles to JavaScript. It enforces two core ideas:

  • Functional purity — functions have no side effects.
  • Data immutability — you never mutate state directly.

The result: the compiler catches almost everything before your code runs. The creator claims zero runtime exceptions in production. That's not marketing. It's a consequence of the language design.

  • Strong static types with readable compiler messages
  • No null or undefined — impossible to leave edge cases unhandled
  • Immutability by default — code is easier to reason about
  • No runtime exceptions — reliability you can't get from JavaScript alone

The architecture

Elm's architecture is simple: Model, Update, View. If you've used Redux, this will look familiar. Redux was directly inspired by Elm.

Model — the state of your application

1_3E0MAqb2RpA6jMSOf1VeGg.webp

Update — a way to update your state

1_lRTJxiVAOZwrrnxbots6ow.webp

View — a way to view your state as HTML

1_vSQLxJbIUGUYfpvFfx3XVg.webp

The syntax is different from JavaScript. But the architecture gives you a standard way to structure every project.

Performance

Elm compiles to efficient JavaScript and uses a virtual DOM. It consistently benchmarks well against React and Angular.

Elm vs React, Angular, and others

  • Both Elm and React install via npm. Elm also ships its own package manager.
  • Elm communicates with JavaScript through flags (one-way) and ports (two-way).
  • elm-reactor gives you a built-in dev server for rapid prototyping.
  • Elm's package ecosystem is tiny compared to React's.

1_ew34mZ05AD_t9BvH3_x03g.webp

The real drawbacks

Skills don't transfer. Elm knowledge doesn't help you in React, Vue, or any other frontend framework. You're investing in an island.

No server-side rendering. If SEO matters to you, Elm is a non-starter right now.

No DOM access. You can't measure element dimensions or do manual DOM manipulation. That's how they guarantee no runtime exceptions — by removing the escape hatch.

Stateless messages. Simulating a click event isn't trivial like it is in JavaScript.

My verdict

I love the compiler. I love the zero-exception guarantee. But for the projects I work on, two things killed it:

  1. No SSR. Most of my sites need server rendering.
  2. No DOM access. That's a dealbreaker for the interactive UIs I build.

The language trades flexibility for safety. That trade-off is worth it for some teams. It wasn't worth it for mine.

If you do decide to try Elm, start small. You can embed compiled Elm JavaScript into an existing project — just convert a few components first before going all in.

Resources