Gleam doesn't compile to Erlang source anymore

gleam.run · 2026-10-05 · by Long Nguyen ·generic
News post: Gleam v1.19.0 released!

Gleam doesn't compile to Erlang source anymore

Return Icon

05 October, 2026 by Louis Pilfold

Share IconShareCopied the post URL!

Gleam is a type-safe and scalable language for the Erlang virtual machine and JavaScript runtimes. Today Gleam v1.19.0 has been published, so let's go over what's new.

A new compilation target

Over the last few months Giacomo Cavalierihas entirely rewritten Gleam's Erlang code generator that has an entirely different design, and most notably, outputs a different format. Previously Gleam generated Erlang source code, now it generates Erlang abstract forms.

"Erlang abstract forms" is an intermediate representation used by the Erlang compiler. It is a metadata-annotated tree that represents Erlang syntax, and it is normally produced by running Erlang's tokeniser and parser. It has a binary encoding using Erlang's external term format, and with this binary format we can load our generated code directly, skipping the front-half of the Erlang compiler.

This new Erlang code generator brings several benefits:

Try Gleam

---

1. "Transpiler" means a compiler that outputs a human-readable format, such as source code. It's a cool sounding word, but most the time people use it to imply that a given compiler is in some way inferior. This is very silly, as there is nothing about compiling to a human-readable format that makes a compiler easier to implement. If you care about that output being nicely formatted it might even be harder than using a binary format.↩︎ 2. The code has been slightly edited for clarity, but the parts related to this improvement are unchanged.↩︎ 3. Gleam's compiler is the heart of the Gleam language server, so unlike traditional compilers it needs to be able to provide information about code even when it is in invalid state. If only valid code could be fully analysed then the language server would provide a degraded experience to the programmer when they are half-way-through a refactoring or other large edit.↩︎

gleam.run · 6 images · 365 links

Comments (0)

No comments yet