7 ms·
A few years ago, I tried to use Core Erlang as a compiler backend. It's fairly straightforward to learn even without thorough documentation. I wrote a bit about
by hkgumbs 6y ago
A few years ago, I tried to use Core Erlang as a compiler backend. It's fairly straightforward to learn even without thorough documentation. I wrote a bit about my process to try to help the next person [0]. For my particular project, I ended up abbandoning the approach and generating BEAM bytecode instead [1]. That was definitely more challenging, but it was neat to see Erlang's commitment to backwards compatibility in action. I believe that BEAM modules emitted by the first versions of Erlang are still valid on modern implementations. New functions are added and old ones are deprecated, but the actual file format version indicator hasn't changed.
[0]: https://8thlight.com/blog/kofi-gumbs/2017/05/02/core-erlang.html https://8thlight.com/blog/kofi-gumbs/2017/05/02/core-erlang....
[1]: https://github.com/hkgumbs/codec-beam https://github.com/hkgumbs/codec-beam
- macintux 6y agoNice. I added your codec-beam project to my Erlang resources gist: https://gist.github.com/macintux/6349828 https://gist.github.com/macintux/6349828
- h91wka 6y agoNeat! But please bear in mind that BEAM VM trusts the bytecode, so if your compiler emits buggy bytecode, it can crash the entire VM.