Est. 2016 Beginner

Gleam

A type-safe functional language for the Erlang VM and JavaScript runtimes, with friendly syntax and a focus on simplicity.

Created by Louis Pilfold

Paradigm Functional
Typing Static, Strong (with type inference)
First Appeared 2016
Latest Version Gleam 1.14.0 (2025)

Gleam is a type-safe functional programming language that compiles to both Erlang (BEAM bytecode) and JavaScript. Created by Louis Pilfold, it brings static typing and friendly error messages to the battle-tested Erlang virtual machine while maintaining a deliberately small and simple language design.

History & Origins

Gleam was created by Louis Pilfold in 2016, initially developed for a conference talk. Pilfold saw an opportunity to combine the reliability and concurrency of the Erlang VM with modern language features like static typing and helpful compiler errors that were missing from existing BEAM languages.

The first numbered release (v0.1) came on April 15, 2019. The language steadily evolved through the 0.x series, adding a JavaScript compilation target in 2021 (v0.16), which allowed Gleam code to run in browsers and Node.js alongside the traditional BEAM target.

The Gleam v1.0.0 milestone was reached on March 4, 2024, signaling language stability and a commitment to backward compatibility.

The Problem Gleam Solves

The Erlang VM (BEAM) is renowned for building concurrent, fault-tolerant systems. However, existing BEAM languages had limitations:

  • Erlang has dynamic typing and unfamiliar syntax for many developers
  • Elixir brought modern syntax but remained dynamically typed
  • Alpaca explored static typing on BEAM but didn’t gain traction

Gleam addresses these by providing:

  • Static type checking with helpful error messages at compile time
  • Type inference so you rarely need to write type annotations
  • No null values and no exceptions for safer code
  • Familiar C-family syntax that’s approachable for most developers
  • Full interoperability with Erlang and Elixir libraries

The Name

The name “Gleam” was chosen because it is both a synonym of and rhymes with “BEAM” - the name of the Erlang virtual machine that Gleam runs on.

Language Design Philosophy

Gleam takes a deliberately minimalist approach. The official FAQ describes it as aiming to be “small” and “consistent.” Notable design choices include:

  • No macros - Code is explicit and predictable
  • No type classes or traits - Simplicity over abstraction power
  • No mutable state - All data structures are immutable
  • No null - The Option type handles missing values
  • No exceptions - The Result type handles errors
  • Pattern matching - The primary control flow mechanism

This philosophy means Gleam is easy to learn and read, even if you’ve never seen it before.

Dual Compilation Targets

One of Gleam’s distinctive features is compiling to both Erlang and JavaScript:

Erlang/BEAM target:

  • Access to Erlang’s actor-based concurrency model
  • Millions of lightweight processes
  • Hot code upgrades
  • Decades of telecom-grade reliability

JavaScript target:

  • Runs in browsers and Node.js
  • Share code between server and client
  • Access to the JavaScript ecosystem

The same Gleam code can target either platform, though platform-specific code uses conditional compilation.

The Type System

Gleam’s type system catches errors at compile time:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// The compiler infers types automatically
let name = "World"          // String
let age = 42                // Int
let scores = [85, 92, 78]   // List(Int)

// Custom types with variants (like Rust enums or Haskell ADTs)
type Shape {
  Circle(radius: Float)
  Rectangle(width: Float, height: Float)
}

Pattern matching with exhaustiveness checking ensures you handle every case:

1
2
3
4
5
6
fn area(shape: Shape) -> Float {
  case shape {
    Circle(r) -> 3.14159 *. r *. r
    Rectangle(w, h) -> w *. h
  }
}

Tooling

Gleam includes a comprehensive built-in toolchain (written in Rust):

  • gleam new - Create new projects
  • gleam run - Compile and execute
  • gleam test - Run tests
  • gleam add - Manage dependencies
  • gleam format - Auto-format code
  • gleam docs - Generate documentation

The toolchain includes a built-in Hex client for package management (sharing the same package repository as Erlang and Elixir) and a Language Server Protocol (LSP) implementation for editor support.

Gleam vs. Other BEAM Languages

FeatureGleamErlangElixir
Type systemStaticDynamicDynamic
Null valuesNoneAtomsnil
Error handlingResult typeExceptionsExceptions
MacrosNoneLimitedExtensive
Syntax styleC-familyProlog-derivedRuby-inspired
JS targetBuilt-inNoNo

Gleam complements rather than replaces Erlang and Elixir - it can call into both ecosystems directly.

The Gleam Community

Gleam has a growing and welcoming community:

  • gleam.run - Official website with language tour and documentation
  • Gleam Discord - Active community chat
  • packages.gleam.run - Package discovery
  • Hex.pm - Package repository (shared with Erlang/Elixir)
  • Gleam Gathering - Community conference (inaugural event in February 2026)

The language appeared in the Stack Overflow Developer Survey in 2025, where it ranked as the second most admired language (behind Rust) among developers who use it.

Timeline

2016
Louis Pilfold begins developing Gleam, initially for a conference talk
2019
First numbered release (v0.1) published on April 15
2021
Gleam v0.16 adds JavaScript compilation target alongside Erlang/BEAM
2022
Language Server Protocol support added; tooling ecosystem matures
2024
Gleam v1.0.0 released on March 4, marking the first stable release
2025
Gleam 1.14.0 released; ranks second most admired language in Stack Overflow Developer Survey

Notable Uses & Legacy

Lustre

A web framework for building HTML templates, single-page applications, and real-time server components in Gleam.

Wisp

A practical backend web framework for Gleam with composable middleware and type-safe routing.

Gleam Package Index

The official package discovery site (packages.gleam.run) for the Gleam ecosystem, built with Gleam.

Gloogle

A search engine for the Gleam ecosystem, built with Lustre and Wisp.

Language Influence

Influenced By

Erlang Elm OCaml Rust Go Alpaca

Running Today

Run examples using the official Docker image:

docker pull ghcr.io/gleam-lang/gleam:v1.14.0-erlang-alpine

Example usage:

docker run --rm -v $(pwd):/work ghcr.io/gleam-lang/gleam:v1.14.0-erlang-alpine sh -c 'gleam new hello --skip-git > /dev/null 2>&1 && cp /work/hello.gleam hello/src/hello.gleam && cd hello && gleam run'

Topics Covered

Last updated: