DEV Community

Arhan Khan
Arhan Khan

Posted on

Gleam for Beginners: A Friendly Functional Language on the BEAM

Gleam is a functional programming language that runs on the Erlang virtual machine (the BEAM), the same runtime behind WhatsApp and Discord's reliability. It combines friendly syntax with a strong type system, and it compiles to both Erlang and JavaScript, so you can use it on the server and in the browser.

What makes Gleam different? First, it has no null values — the type system makes missing data explicit, so null errors disappear. Second, its syntax is clean and readable, closer to Rust or Python than to Erlang. Third, it runs on the BEAM, which means lightweight processes, fault tolerance, and hot code reloading come built in.

Here is your first Gleam program. Save it as src/hello.gleam in a Gleam project and run it with gleam run:

import gleam/io
import gleam/list

pub fn main() {
  let name = "Arhan"
  io.println("Hello, " <> name <> "! Welcome to Gleam.")

  let numbers = [1, 2, 3, 4, 5]
  let doubled = list.map(numbers, fn(n) { n * 2 })
  io.debug(doubled) // [2, 4, 6, 8, 10]

  let greeting = greet("Priya")
  io.println(greeting)
}

fn greet(user: String) -> String {
  "Hello, " <> user <> "!"
}
Enter fullscreen mode Exit fullscreen mode

Notice the <> operator for joining strings and the pipe-friendly list.map. Gleam's compiler checks every type, and its error messages are written for humans, not compiler engineers.

Where is Gleam used? It is used for web servers, APIs, and concurrent systems where reliability matters. The Lustre framework brings Gleam to the frontend, and its BEAM foundation makes it a natural choice for real-time apps, chat systems and tools that must stay up.

Who should learn Gleam? Erlang and Elixir developers who want static types, functional programmers who want a friendly syntax, and beginners curious about the BEAM without learning Erlang's older syntax. It is one of the most approachable ways into serious concurrent programming.

Gleam's limits are worth knowing. It is a young language, so libraries are fewer than in mature ecosystems. The job market is small, and some BEAM features still need Erlang interop. Learn it for the ideas and the reliability model, and you will carry those lessons into any language.

Your first step today: create a Gleam project with gleam new hello, run the program above, and then write a function that filters a list to keep only even numbers. In a week, the absence of null will feel like a superpower.

Top comments (0)