Erlang and WebAssembly?

This just turned up in Ruby Weekly:

Proposal to Merge WASI-Based WebAssembly Support into Ruby

There have been experiments before, but having WebAssembly as an officially supported target for Ruby would open up some interesting use cases. While this is exciting news, it’s very early days and with a variety of expected limitations (e.g. around threading). A story we’ll keep an eye on, for sure, and hopefully a headline feature for Ruby 3.2.

So I was wondering whether there have been any Erlang related efforts?

I currently know of Lumen:

Lumen is not only a compiler, but a runtime as well. It consists of two parts:

  • A compiler for Erlang to native code for a given target (x86, ARM, WebAssembly)
  • An Erlang runtime, implemented in Rust, which provides the core functionality needed to implement OTP

The primary motivator for Lumen’s development was the ability to compile Elixir applications that could target WebAssembly, enabling use of Elixir as a language for frontend development. It is also possible to use Lumen to target other platforms as well, by producing self-contained executables on platforms such as x86.

Lumen is different than BEAM in the following ways:

  • It is an ahead-of-time compiler, rather than a virtual machine that operates on bytecode
  • It has some additional restrictions to allow more powerful optimizations to take place, in particular hot code reloading is not supported
  • The runtime library provided by Lumen is written in Rust, and while very similar, differs in mostly transparent ways. One of the goals is to provide a better foundation for learning how the runtime is implemented, and to take advantage of Rust’s more powerful static analysis to catch bugs early.
  • It has support for targeting WebAssembly, as well as other targets.

The result of compiling a BEAM application via Lumen is a static executable. This differs significantly from how deployment on the BEAM works today (i.e. via OTP releases). While we sacrifice the ability to perform hot upgrades/downgrades, we make huge gains in cross-platform compatibility, and ease of use. Simply drop the executable on a compatible platform, and run it, no tools required, or special considerations during builds. This works the same way that building Rust or Go applications works today.

Are there any more? Do you think this could be good for Erlang? Any thoughts on WASM in general?