High-level overview of Gleam components/BEAM interop

I think a high-level overview on Gleam components would be useful to folks not (yet) using Gleam but trying to get a quick understanding on how things work.

Mainly from a perspective of “Erlang compatibility”:

There’s gleam-lang/otp, gleam-lang/erlang, gleam-lang/stdlib.

  • gleam-lang/gleam:
    This is the Gleam->Erlang compiler, written in Rust.

  • gleam-lang/sdtlib:
    Those are standard lib functions written in Gleam. They have nothing to do with any Erlang standard libraries.

  • gleam-lang/otp:
    Let’s call this Gleam’s implementation of an actor framework. It is closely modelled after Erlang’s OTP, but it does not use OTP directly. It also adds a couple new things, like channels. A small part is written in Erlang, most of it is written in Gleam.

  • gleam-lang/erlang:
    “A library for making use of Erlang specific code!” (How, and why is it needed?)

Also, applications. An example here is Cowboy:

What exactly is a “service adapter”? A couple days ago, I read that Gleam finally is able to compile Cowboy. Is this related to the Cowboy service adapter? or Erlang Cowboy?

It was not immediately clear to me how compatibility to other BEAM languages works in Gleam. A diagram/explanation would likely help much for that first “let’s check out what Gleam actually is” moment.
Just a suggestion & let me know when I missed anything in the docs.

Thank you for creating awesome technology! :slight_smile:


That news was about Gleam’s own build tool being able to interface with rebar3 to compile rebar3 dependencies. I’m sure this will be cleared up soon in a news blog post when Gleam v0.18 comes out!


I see, thank you! :slight_smile:


Thanks for checking out Gleam! As you’ve notice we can certainly do with some more documentation. This is a priority for sure.

The standard library doesn’t include any target specific features, it is rather minimal and largely only has modules for working with standard data structures such as lists, maps, options, results, and so on.

In reality Gleam programs running on the BEAM (as opposed to in the browser via the JavaScript backend) will want some BEAM specific features, such as being able to work with atoms or OTP applications. For this the gleam_erlang library exists, which has bindings to these Erlang functions.

The gleam_http library defines an interface for HTTP service, but it doesn’t provide a way to run to run the web services created with this interface. For that you’ll need an adapter for a HTTP service, and this library is one for Cowboy. There’s also one for Elli, and another for Plug.
Overall it’s very similar in function to Elixir’s Plug.


Thank you for the explanations!
Ok, so gleam-lang/erlang is kind of an extension to gleam-lang/stdlib for stuff that need bindings to Erlang types. Got it.