The Gleam Compiler Was First Prototyped in Erlang Before a Rewrite in Rust
Gleam is a statically typed functional language that runs on the Erlang virtual machine, and its own toolchain tells a revealing story about language design. The early prototype versions of the Gleam compiler were written in Erlang itself. That choice made sense at first. If you are building a language for the Erlang ecosystem, borrowing the host language for the compiler is a natural starting point. But the team eventually abandoned that approach and rewrote the compiler in Rust, and the reason is a masterclass in why trust matters in a compiler.
The official Frequently Asked Questions for Gleam states it plainly: prototype compilers were written in Erlang, but a switch was made to Rust because the lack of static types was making refactoring a slow and uncertain process. A compiler is one of the most aggressively refactored programs in existence. You are constantly reshaping an abstract syntax tree, rewriting passes, moving code generation around. Every adjustment is a risk that you have silently broken some path through the pipeline.
Working in a language without static types, the compiler author had to keep the whole transformation graph in their head and rely on discipline and tests to catch mistakes. That is exhausting at compiler scale. With Rust, the type system catches a huge class of mistakes before the code even runs. Reassigning a node type, changing what a pass returns, rewiring ownership, the compiler refuses to build until the shapes line up. Refactoring stops being a guessing game and becomes a set of type errors to resolve.
There is a deeper payoff here that applies to any senior developer. The choice was not a statement that Erlang is a bad language. Erlang is excellent at what it is for, fault tolerant concurrent systems. But it was not the best tool for a single, long lived, constantly morphing program like a compiler front end. The maintainers matched the tool to the shape of the problem, and on a problem this thorny, static typing gave them the confidence to move fast without breaking things.
For anyone working on a compiler or a similarly complex codebase, this is the practical takeway. Choose the language for the job by the kind of change the code will experience, not by the surrounding ecosystem. And when you rewrite a critical component, the new implementation is only worth it if it meaningfully reduces the risk of the daily work. Gleam is proof that a well timed, well justified rewrite, in the right language, can carry a young project through years of rapid iteration.