What is the feasibility of mixing BEAM languages within a single project?

Hi,
I’m exploring the Erlang ecosystem and I’m very pleased with the variety of programming languages that run on the BEAM. Given that my interest is related to the web platform, the most popular libraries and projects seem to be written in Elixir, however it is not my favorite of the language options. What is the feasibility of mixing languages within a single project? Do you have any advice on how to approach the project build and are there any practical examples of mixed language projects I can look at?

All BEAM languages compile to the same .beam files. You can mix and match to your heart’s content.

You can compile a mixed Erlang/Elixir project with Erlang’s mix or with rebar3, or with erlang.mk.

Elixir can be awkward to call from Erlang, because it prefixes everything with Elixir., and because of macros, but it’s not impossible. Erlang is easy to call from Elixir (that’s how it’s implemented, after all).

Gleam is a little bit trickier – because it wants to see the whole project, it’s harder to use it in the same project, but you can use it for one or more libraries and then call it from (or have it call into) Erlang and Elixir libraries.

I’ve not tried with other BEAM languages, such as LFE, but I don’t see why it’d be any different.

The best option is probably to separate each language into a separate library, using their own build tooling, and then to combine them in the overall project later.

3 Likes