3 ms·
Why not compile directly to BEAM bytecode?
by the_duke 10y ago
Why not compile directly to BEAM bytecode?
- rubiquity 10y agoElixir, 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.
- macintux 10y agoWorth 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.
- di4na 10y agoRight. And Elixir may target Core Erlang one day, for a hypothetic 2.0
- gilmi 10y agoOne 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.