# Any tips on how to create a BEAM language?

**URL:** <https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210>\
**Category:** BEAM Chat / Discussions\
**Tags:** beam-languages\
**Created:** [November 3, 2025, 8:16am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210 "2025-11-03T08:16:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ValorZard](https://erlangforums.com/user_avatar/erlangforums.com/valorzard/32/3038_2.png) [@ValorZard](https://erlangforums.com/u/ValorZard)\
**Post date:** [November 3, 2025, 8:16am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/1 "2025-11-03T08:16:36Z")

</div>

This is a bit off topic, but I wish there was some sort of tutorial or book on HOW to make a new language for the BEAM.

It seems like a lot of fun but I have no idea where to start lol. O

---

<div class="post-metadata">

**Author:** ![vances](https://erlangforums.com/user_avatar/erlangforums.com/vances/32/710_2.png) [@vances](https://erlangforums.com/u/vances)\
**Post date:** [November 3, 2025, 9:09am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/2 "2025-11-03T09:09:50Z")

</div>

Implementing languages on the BEAM by Robert Virding & Mariano Guerra

https://www.youtube.com/embed/0MTiqI9v-ck?feature=oembed&wmode=opaque

---

<div class="post-metadata">

**Author:** ![bjorng](https://erlangforums.com/user_avatar/erlangforums.com/bjorng/32/174_2.png) [@bjorng](https://erlangforums.com/u/bjorng)\
**Post date:** [November 3, 2025, 12:22pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/3 "2025-11-03T12:22:08Z")

</div>

Not a tutorial as such, but in Erlang/OTP 29 there will be some recommendations for developers of new languages running on the BEAM:

> <https://github.com/erlang/otp/pull/10230/files>
>
> \* Document the \`to\_abstr\`, \`to\_exp\`, and \`from\_abstr\` compiler options.
> 
> \* Doc…ument that \`erlc\` accepts the \`.abstr\` extension.
> 
> \* Add a new section with recommendations for language implementors.

---

<div class="post-metadata">

**Author:** ![ValorZard](https://erlangforums.com/user_avatar/erlangforums.com/valorzard/32/3038_2.png) [@ValorZard](https://erlangforums.com/u/ValorZard)\
**Post date:** [November 3, 2025, 6:03pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/4 "2025-11-03T18:03:48Z")

</div>

Interesting…. If compiling to .BEAM is so highly discouraged, why do Gleam and Cure do it?

Also, is there a reference/specification on how the Erlang ast works?

---

<div class="post-metadata">

**Author:** ![mudasobwa](https://erlangforums.com/user_avatar/erlangforums.com/mudasobwa/32/231_2.png) [@mudasobwa](https://erlangforums.com/u/mudasobwa)\
**Post date:** [November 3, 2025, 7:03pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/5 "2025-11-03T19:03:10Z")

</div>

> [@ValorZard](#):
>
> why do Gleam and Cure do it?

Can’t say anything about Gleam, but Cure is literally forced to do it to preserve correctness proof.

---

<div class="post-metadata">

**Author:** ![LeonardB](https://erlangforums.com/user_avatar/erlangforums.com/leonardb/32/1856_2.png) [@LeonardB](https://erlangforums.com/u/LeonardB)\
**Post date:** [November 3, 2025, 7:04pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/6 "2025-11-03T19:04:32Z")

</div>

AFAIK the Gleam compiler produces .erl files, and I may be wrong, but it looks like `Cure` compiles to AST, not .beam

See

> **[gleam/docs/compiler at main · gleam-lang/gleam](https://github.com/gleam-lang/gleam/tree/main/docs/compiler)**
>
> ⭐️ A friendly language for building type-safe, scalable systems! - gleam-lang/gleam

> <https://github.com/am-kantox/cure-lang/blob/main/src/codegen/cure_beam_compiler.erl>

Edit: A brief scan through the `Cure` repo leads me to believe it’s producing Erlang .ast from the .cure files, then compiling to .beam using `compile:forms`

---

<div class="post-metadata">

**Author:** ![mudasobwa](https://erlangforums.com/user_avatar/erlangforums.com/mudasobwa/32/231_2.png) [@mudasobwa](https://erlangforums.com/u/mudasobwa)\
**Post date:** [November 3, 2025, 7:18pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/7 "2025-11-03T19:18:20Z")

</div>

Correct. `Cure` compiles to erlang forms, and then to `.beam`.

---

<div class="post-metadata">

**Author:** ![LeonardB](https://erlangforums.com/user_avatar/erlangforums.com/leonardb/32/1856_2.png) [@LeonardB](https://erlangforums.com/u/LeonardB)\
**Post date:** [November 3, 2025, 7:23pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/8 "2025-11-03T19:23:03Z")

</div>

Yay!

I think I was just trying to clarify that `Cure` is not producing it’s own BEAM code _independently_ of the Erlang compiler, which is what I believe @bjorng was actually referring to in his documentation PR [Update compiler and erlc documentation](https://github.com/erlang/otp/pull/10230/files#diff-3f0859234ee3b499e4eeec6cf88815b8897badc37473a34d2a47f6d13e768ef6R190)

---

<div class="post-metadata">

**Author:** ![mudasobwa](https://erlangforums.com/user_avatar/erlangforums.com/mudasobwa/32/231_2.png) [@mudasobwa](https://erlangforums.com/u/mudasobwa)\
**Post date:** [November 3, 2025, 7:36pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/9 "2025-11-03T19:36:39Z")

</div>

> [@LeonardB](#):
>
> it’s own BEAM code _independently_ of the Erlang compiler

There are many reasons it does not, and the main is I am not a moron to try to outperform F1 car on my VW Beetle.

🙂

---

<div class="post-metadata">

**Author:** ![michallepicki](https://erlangforums.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@michallepicki](https://erlangforums.com/u/michallepicki)\
**Post date:** [November 3, 2025, 8:07pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/10 "2025-11-03T20:07:24Z")

</div>

> [@ValorZard](#):
>
> I have no idea where to start lol

Maybe take a look at[all the existing attempts](https://github.com/stars/michallepicki/lists/beam-languages?page=1) and learn and get inspiration from them!

---

<div class="post-metadata">

**Author:** ![AstonJ](https://erlangforums.com/user_avatar/erlangforums.com/astonj/32/9_2.png) [@AstonJ](https://erlangforums.com/u/AstonJ)\
**Post date:** [November 3, 2025, 8:42pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/11 "2025-11-03T20:42:50Z")

</div>

There are quite a few books on complier design, [https://craftinginterpreters.com](https://craftinginterpreters.com) has [been mentioned](https://elixirforum.com/t/implementing-closures-in-a-recursive-descent-parser-using-immutable-datastructures/66530) a few times on EF by @linusdm. Was also mentioned by @LincolnBryant here:

> [@What Erlang/BEAM related stuff are you doing?](https://erlangforums.com/t/what-erlang-beam-related-stuff-are-you-doing/198/6):
>
> over the summer I wrote a tree-walking interpreter that implements a subset of [Godot](https://www.godotengine.org)’s built-in scripting language, [GDScript](https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_basics.html). It’s a whitespace-significant imperative language, so implementing that in Erlang was challenging but also really fun! I have never implemented a programming language before, so I spent a lot of time staring at the [Luerl](https://github.com/rvirding/luerl) source code, the documentation for [leex](https://erlang.org/doc/man/leex.html) and [yecc](https://erlang.org/doc/man/yecc.html), and the book [Crafting Interpreters](https://craftinginterpreters.com/). overall I’m pretty happy with it, but the interface is rather ba…

It’s also #1 in Amazon’s Best Sellers in Compiler Design list:

[https://www.amazon.com/gp/bestsellers/books/3970](https://www.amazon.com/gp/bestsellers/books/3970)

---

<div class="post-metadata">

**Author:** ![ValorZard](https://erlangforums.com/user_avatar/erlangforums.com/valorzard/32/3038_2.png) [@ValorZard](https://erlangforums.com/u/ValorZard)\
**Post date:** [November 3, 2025, 9:00pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/12 "2025-11-03T21:00:50Z")

</div>

There are probably limitations on what kind of languages you can make on the BEAM though right? Like, Lox from crafting interpreters requires mutation I’m pretty sure, and idk how you’d represent something like C with pointers and manual memory management.

Though I know there was a project that tries to compile Rust to C#/.NET Bytecode so it’s obviously not impossible

> **[GitHub - FractalFir/rustc\_codegen\_clr: A Rust compiler backend targeting CIL(.NET IR) and...](https://github.com/FractalFir/rustc_codegen_clr)**
>
> A Rust compiler backend targeting CIL(.NET IR) and C.

---

<div class="post-metadata">

**Author:** ![AstonJ](https://erlangforums.com/user_avatar/erlangforums.com/astonj/32/9_2.png) [@AstonJ](https://erlangforums.com/u/AstonJ)\
**Post date:** [November 3, 2025, 9:18pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/13 "2025-11-03T21:18:40Z")

</div>

I’m not sure what those limitations might be tbh… you could ask our resident expert, @rvirding, who, if I am not mistaken, has created more BEAM languages than anyone else - including Erlang itself :003:

---

<div class="post-metadata">

**Author:** ![ValorZard](https://erlangforums.com/user_avatar/erlangforums.com/valorzard/32/3038_2.png) [@ValorZard](https://erlangforums.com/u/ValorZard)\
**Post date:** [November 3, 2025, 9:48pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/14 "2025-11-03T21:48:38Z")

</div>

Yeah I guess the main thing I’m thinking about is that I’m pretty sure all values in the BEAM are boxed, and there’s no such thing as a struct. Meanwhile .NET has both struct and classes, and the JVM with project Valhalla is getting “value classes”

---

<div class="post-metadata">

**Author:** ![vances](https://erlangforums.com/user_avatar/erlangforums.com/vances/32/710_2.png) [@vances](https://erlangforums.com/u/vances)\
**Post date:** [November 3, 2025, 10:03pm UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/15 "2025-11-03T22:03:54Z")

</div>

> [@ValorZard](#):
>
> There are probably limitations on what kind of languages you can make on the BEAM though right?

It’s [Turing Complete](https://en.wikipedia.org/wiki/Turing_completeness) so you can do anything. 😉

… however just because you can do something doesn’t mean you should. Building a C compiler to target the BEAM wouldn’t result in anything truly useful.

---

<div class="post-metadata">

**Author:** ![fancycade](https://erlangforums.com/user_avatar/erlangforums.com/fancycade/32/1187_2.png) [@fancycade](https://erlangforums.com/u/fancycade)\
**Post date:** [November 4, 2025, 3:29am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/16 "2025-11-04T03:29:57Z")

</div>

Yes, and no. Technically you can do whatever you want. Realistically the BEAM runtime is Erlang semantics. So you are limited by what Erlang is good at.

---

<div class="post-metadata">

**Author:** ![mudasobwa](https://erlangforums.com/user_avatar/erlangforums.com/mudasobwa/32/231_2.png) [@mudasobwa](https://erlangforums.com/u/mudasobwa)\
**Post date:** [November 4, 2025, 5:11am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/17 "2025-11-04T05:11:08Z")

</div>

> [@fancycade](#):
>
> you are limited by what Erlang is good at

In runtime you are limited, that’s correct. In compile time you are absolutely free to do any weird stuff, as I (hopefully) successfully demonstrated with [Cure](https://cure-lang.org/).

---

<div class="post-metadata">

**Author:** ![mudasobwa](https://erlangforums.com/user_avatar/erlangforums.com/mudasobwa/32/231_2.png) [@mudasobwa](https://erlangforums.com/u/mudasobwa)\
**Post date:** [November 4, 2025, 5:14am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/18 "2025-11-04T05:14:46Z")

</div>

> [@AstonJ](#):
>
> what those limitations might be tbh

Rust’s borrow checker would have been implemented with (backed up by) a process, which might be crucial, to begin with.

I have an experience trying to compile Ruby to BEAM and trust me mutable object \<\> process interop is not anything one wants to deal with.

---

<div class="post-metadata">

**Author:** ![mudasobwa](https://erlangforums.com/user_avatar/erlangforums.com/mudasobwa/32/231_2.png) [@mudasobwa](https://erlangforums.com/u/mudasobwa)\
**Post date:** [November 4, 2025, 5:17am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/19 "2025-11-04T05:17:11Z")

</div>

> [@ValorZard](#):
>
> JVM with project

This all can be solved during the compilation stage, so that particular issue is a piece of cake. Unless one needs reflection and/or aspect-oriented programming.

---

<div class="post-metadata">

**Author:** ![bjorng](https://erlangforums.com/user_avatar/erlangforums.com/bjorng/32/174_2.png) [@bjorng](https://erlangforums.com/u/bjorng)\
**Post date:** [November 4, 2025, 6:22am UTC](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210/20 "2025-11-04T06:22:33Z")

</div>

> [@ValorZard](#):
>
> is there a reference/specification on how the Erlang ast works?

Yes, there is link to it from the pull request, although that link is a little bit cryptic in the Markdown format. Here is a direct link:

> **[The Abstract Format — erts v16.1.1](https://www.erlang.org/doc/apps/erts/absform.html)**

> [@LeonardB](#):
>
> I think I was just trying to clarify that `Cure` is not producing it’s own BEAM code _independently_ of the Erlang compiler, which is what I believe @bjorng was actually referring to in his documentation PR [Update compiler and erlc documentation](https://github.com/erlang/otp/pull/10230/files#diff-3f0859234ee3b499e4eeec6cf88815b8897badc37473a34d2a47f6d13e768ef6R190)

Yes, that was what I meant.

I am not sure whether any language developer has ever tried to produce BEAM files directly.

> [@AstonJ](#):
>
> There are quite a few books on complier design, [https://craftinginterpreters.com](https://craftinginterpreters.com) has [been mentioned](https://elixirforum.com/t/implementing-closures-in-a-recursive-descent-parser-using-immutable-datastructures/66530) a few times on EF by @linusdm.

I can recommend another book, which includes a section describing how to implement a simple interpreted language ([hoc](https://en.wikipedia.org/wiki/Hoc_(programming_language))) using [yacc](https://en.wikipedia.org/wiki/Yacc). That’s how I got started implementing (simple) compilers and interpreters.

> **[The Unix Programming Environment](https://en.wikipedia.org/wiki/The_Unix_Programming_Environment)**
>
> The Unix Programming Environment, first published in 1984 by Prentice Hall, is a book written by Brian W. Kernighan and Rob Pike, both of Bell Labs and considered an important and early document of the Unix operating system.
> The book addresses the Unix philosophy of small cooperating tools with standardized inputs and outputs. Kernighan and Pike gives a brief description of the Unix design and the Unix philosophy:
> Even though the UNIX system introduces a number of innovative programs and techn...

[Next page](https://erlangforums.com/t/any-tips-on-how-to-create-a-beam-language/5210.md?page=2)
