From Ruby to Elixir: Elixir does not compile to Erlang

The following sentence in the section " Erlang, OTP, Elixir, and Friends" is not correct:

“You’ll write Elixir code when you work on your app, but it’s compiled into a totally different programming language called Erlang.”

Elixir is not transpiled to Erlang. In fact, Elixir compiles to BEAM bytecode.

I am sure the author knows and meant to say this, I just wish he had stated it a bit more accurate.

It is fair to call this out. It’s sort of a complex part of the language—and I think core team members would probably phrase it differently than I have in the book. It’s not a clear cut thing to me and it has actively shifted over the years.

The intent of this is that (at least to my knowledge) Elixir compiles into intermediate formats along the way to becoming BEAM bytecode. (I use compile here because Elixir compiles things like macros in a more advanced way than Erlang does and the format it goes into is an AST instead of Erlang source code.)

The purpose of the paragraph is to show that there’s a deep connectivity between Erlang and Elixir—such that Elixir is built on top of Erlang and not simply compatible with it. It becomes Erlang terms on its way to becoming bytecode.

1 Like