Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why not compile directly to BEAM bytecode?


Elixir, LFE and a lot of other languages past and present that share the BEAM use this approach. As far as I understand it, the BEAM byte code isn't documented all that well and emitting Erlang terms is more straight forward.

This approach also makes keeping your language up to date with the BEAM easier. If you implement against the byte code directly and the byte code changes then you have to make big changes in your compiler. By emitting Erlang terms you can make direct usage of the Erlang compiler (which should be more stable) in a later compilation stage. It's a similar situation for the LLVM and why they suggest you output LLVM IR and not bitcode.


Worth noting that Elixir and LFE apparently use different target languages (although you're correct, neither compile straight to BEAM).

Elixir compiles to Erlang, LFE compiles to Core Erlang, which is an intermediate form used by the Erlang compiler.


Right. And Elixir may target Core Erlang one day, for a hypothetic 2.0


One of PureScript's main goals is to generate JS that can be read by humans. I'm guessing the author wanted to follow the PureScript spirit when creating purerl.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: