DEV Community

Alex Spinov
Alex Spinov

Posted on

Gleam Has a Free Type-Safe Language That Runs on the BEAM — Erlang's Power, Modern Syntax

The BEAM Problem

Erlang powers WhatsApp (2 billion users, 50 engineers). Elixir made it beautiful. But both have a secret weakness: no static types.

Your Elixir app works great — until production reveals a type mismatch that the compiler never caught.

Gleam fixes this. Full static types. Runs on the BEAM. Zero runtime overhead.

What Gleam Gives You

Type-Safe Erlang/Elixir Interop

import gleam/io
import gleam/int

pub fn main() {
  let answer = add(20, 22)
  io.println("The answer is: " <> int.to_string(answer))
}

fn add(a: Int, b: Int) -> Int {
  a + b
}
Enter fullscreen mode Exit fullscreen mode

Every function has types. The compiler catches mistakes before runtime.

Pattern Matching

pub type Shape {
  Circle(radius: Float)
  Rectangle(width: Float, height: Float)
}

pub fn area(shape: Shape) -> Float {
  case shape {
    Circle(r) -> 3.14159 *. r *. r
    Rectangle(w, h) -> w *. h
  }
}
Enter fullscreen mode Exit fullscreen mode

Forget a case? Compiler error. Not a runtime crash at 3 AM.

Use All of Erlang's Libraries

// Call Erlang's crypto module directly
@external(erlang, "crypto", "strong_rand_bytes")
fn random_bytes(size: Int) -> BitArray
Enter fullscreen mode Exit fullscreen mode

Gleam compiles to Erlang. Every OTP library works. GenServers, supervisors, ETS tables — all available.

Also Compiles to JavaScript

gleam build --target javascript
Enter fullscreen mode Exit fullscreen mode

Same code, runs in Node.js or the browser. One language, two runtimes.

Quick Start

curl -sSf https://gleam.run/install | sh
gleam new my_project
cd my_project
gleam run
Enter fullscreen mode Exit fullscreen mode

Why This Matters

The BEAM VM is the best runtime for concurrent, fault-tolerant systems. Gleam adds the one thing it was missing: a modern type system that catches bugs at compile time.

If you're building APIs, real-time systems, or anything that needs 99.999% uptime — Gleam deserves a look.


Need to collect data for your BEAM applications? Check out my web scraping actors on Apify Store — structured data, ready to process. For custom solutions, email spinov001@gmail.com.

Top comments (0)