Gleam is a friendly language for building type-safe, scalable systems! ✨

Get Started
Kindly supported by

Hello, Gleam!

The power of typed functional programming with the performance and reliability of the Erlang VM, all wrapped up in a familiar modern syntax.

import gleam/io

pub fn main() {
  io.println("Hello, world!")
}

Productivity focused

No nulls, no exceptions, clear error messages, and a practical type system. Whether you're writing new code or maintaining old code Gleam is designed to make your job as fun and stress-free as possible.

error: Unknown record field
  ┌─ ./src/app.gleam:8:16
  │
8 │   user.alias^^^^^^^^^^ Did you mean `name`?

The value being accessed has this type:
    User
It has these fields:
    .name

Model your domain

With Gleam's custom types, generics, and pattern matching features it can implement your business logic precisely and clearly. We think it should always be clear to the reader what code is doing.

pub type Pet {
  Cat
  Dog
  Other(name: String)
}

pub fn greet(pet) {
  case pet {
    Dog -> "Who's a good boy?"
    Cat -> "What a little sweetie!"
    Other(name) -> "Hello, " <> name
  }
}

Ready out of the box

Gleam comes with compiler, build tool, formatter, editor integrations, and package manager all built in, so creating a gleam project is just running gleam new.

Part of the wider BEAM ecosystem, Gleam programs can use the thousands of published packages whether they are written in Gleam, Erlang, or Elixir.

~/app $ gleam add gleam_json
  Resolving versions
Downloading packages
 Downloaded 2 packages in 0.01s
      Added gleam_json v0.5.0
~/app $ gleam test
  Compiling thoas
  Compiling gleam_json
  Compiling app
   Compiled in 1.67s
    Running app_test.main
.
1 tests, 0 failures

Made for production

Running on the battle-tested Erlang virtual machine that powers planet scale systems such as WhatsApp and Ericsson, Gleam is ready for workloads of any size.

Thanks to a multi-core actor based concurrency system that can run millions of concurrent tasks, fast immutable data structures, and a concurrent garbage collector that never stops the world, your service can scale and stay lightning fast with ease.

pub fn main() {
  // Run a million threads, no problem
  list.range(0, 1_000_000)
  |> list.map(spawn_task)
  |> list.each(task.await_forever)
}

fn spawn_task(i) {
  task.async(fn() {
    let n = int.to_string(i)
    io.println("Hello from " <> n)
  })
}

JavaScript compatible

As well as running on the Erlang VM Gleam code can also compile to JavaScript. Reuse your existing backend code in the browser, on mobile devices, or anywhere else JavaScript can run.

pub fn main() {
  try el = document.query_selector("button")

  element.add_event_listener(el, fn() {
    io.println("Button clicked!")
  })
}

Gleam's principles

Safe

Gleam's powerful static type system helps find and prevent bugs at compile time, long before it reaches your users. It also serves as a productive refactoring tool, enabling programmers to confidently make large changes to unfamiliar code, quickly and with low risk.

For problems the type system can't solve (such as your server being hit by a bolt of lightning) the Erlang virtual machine provides well tested mechanisms for gracefully handling failure.

Friendly

Hunting down bugs can be stressful so Gleam's compiler provides clear and helpful feedback about any problems. We want to spend more time developing features and less time looking for bugs or deciphering cryptic error messages.

As a community we want to be friendly too. People of all backgrounds, genders, and experience levels are welcome and must receive equal respect. See our community code of conduct for more.

Performant

Gleam builds on top of the Erlang virtual machine, a best-in-class runtime that has enabled companies such as Discord, Ericsson, Heroku, and WhatsApp to provide low-latency services at a global scale. Gleam takes full advantage of the Erlang runtime and adds no overhead of its own, so all Gleam programs are as fast and as efficiently multi-threaded as their Erlang counterpart.

Erlang compatible

Gleam makes it easy to use code written in other BEAM languages such as Erlang, Elixir and LFE, so there's a rich ecosystem of thousands of open source libraries for Gleam users to make use of.

In return Gleam code can be easily used by programmers of other BEAM languages, either by transparently making use of libraries written in Gleam, or by adding Gleam modules to their existing project with minimal fuss.

Let's go

Still interested? Try out getting started guide:

Get Started