Gleam is a statically typed functional language that runs on the Erlang virtual machine (BEAM) and can also compile to JavaScript. It was created by British developer Louis Pilfold, who began the project around 2016, and it reached its first stable release, v1.0, on March 4, 2024. For developers who like the BEAM but miss a compiler that catches mistakes, the obvious question is whether Gleam is a good typed alternative to Elixir. The answer depends on what you value more: a sound type system and a tiny language, or a large, mature ecosystem.
Origins and goals
Pilfold had worked with Erlang and Elixir and appreciated the BEAM's concurrency and fault tolerance, but he wanted the safety of languages like Elm, OCaml and Rust. Earlier attempts to add types to the BEAM existed, including Erlang's Dialyzer tool and the Alpaca language, but none had become mainstream. Gleam set out to be small and consistent, with friendly error messages and a single, built-in toolchain. The compiler itself is written in Rust.
The project is funded by sponsorships from companies and individuals, with Fly.io providing about half of the funding at the time of v1.0, and its mascot, a friendly pink starfish called Lucy, reflects the friendly tone the community aims for.
Design and key features
- Full type inference: you rarely need annotations, yet every value has a known type at compile time.
- No null and no exceptions for normal errors; functions return
ResultandOptionvalues that must be handled. - Immutable data, custom types (tagged unions) and exhaustive pattern matching.
- A deliberately small language: no macros, no type classes, no method syntax. A
useexpression handles callback-heavy code. - One tool: the
gleambinary includes the compiler, build tool, package manager, formatter and language server. - Two targets: Erlang bytecode for servers and JavaScript for browsers or JavaScript runtimes.
A short Gleam example
This snippet parses a string into an age and handles every case explicitly with pattern matching and a guard:
import gleam/int
import gleam/io
pub fn parse_age(input: String) -> Result(Int, String) {
case int.parse(input) {
Ok(age) if age >= 0 -> Ok(age)
Ok(_) -> Error("Age cannot be negative")
Error(_) -> Error("Not a number: " <> input)
}
}
pub fn main() {
case parse_age("42") {
Ok(age) -> io.println("Age: " <> int.to_string(age))
Error(msg) -> io.println(msg)
}
}
Is Gleam a good typed alternative to Elixir?
Gleam and Elixir share the same runtime, so both benefit from lightweight processes, message passing and the BEAM's reliability. Gleam can call Erlang and Elixir code through external function declarations, and Gleam packages are published to the same Hex repository. The differences are in the language itself:
- Types: Gleam's type checking is complete and sound from the start. Elixir is adding a gradual type system, but it remains a dynamic language at heart.
- Metaprogramming: Elixir's macros power Phoenix, Ecto and many DSLs. Gleam has no macros by design, which makes code easier to read but limits that kind of library.
- OTP: Elixir uses OTP directly. Gleam offers typed actors and supervisors through the
gleam_otppackage, which covers common patterns but not all of OTP's flexibility. - Ecosystem: Elixir has Phoenix, LiveView, Ecto, Nx and over a decade of libraries. Gleam's ecosystem, including the Wisp web framework and the Lustre frontend framework, is promising but much younger.
Where Gleam is used
Gleam's adoption is still early. It is used for web back ends, command-line tools and frontend apps with Lustre, mostly by smaller teams, startups and hobbyists who value type safety. Its stable language and friendly community have made it a popular choice for people learning functional programming, and it has ranked highly in developer surveys of admired languages.
Limitations
The main limitation is maturity. There are fewer libraries, fewer production case studies and fewer people to hire. Some BEAM features, such as hot code reloading and dynamic patterns common in OTP, fit awkwardly with static types. The JavaScript target is useful, but code that relies on BEAM-specific features does not run there. The language is stable since v1.0, while the standard library and tooling continue to evolve quickly.
Should you learn Gleam?
If you enjoy typed functional languages and are curious about the BEAM, Gleam is one of the most approachable places to start, and it is small enough to learn in a weekend. For a large commercial web product today, Elixir and Phoenix are still the safer bet. So is Gleam a good typed alternative to Elixir? For new services where type safety matters more than a big ecosystem, yes; for everything else, it is a strong companion to Elixir rather than a replacement.
Frequently asked questions
Does Gleam run on the Erlang VM?
Yes. Gleam compiles to Erlang and runs on the BEAM, so it gets the same lightweight processes and fault tolerance as Erlang and Elixir. It can also compile to JavaScript instead.
Can Gleam use Elixir libraries?
Gleam can call Erlang and Elixir functions through external function declarations, and it uses the same Hex package repository. You need to write type definitions for those calls, since the compiler cannot infer types for dynamic code.
Is Gleam stable?
Gleam reached v1.0 in March 2024, and the project has committed to keeping the language backward compatible. The surrounding libraries and frameworks are younger and still changing faster than the core language.







