Lua in WebAssembly

Lua is a lightweight scripting language designed to be easily embedded. It enjoys broad usage as a plugin-and-extension language, and has a large ecosystem. But it is not generally considered one of the top programming languages.

Available Implementations

Lua does not have an official implementation of a Lua-to-Wasm compiler.

The following unofficial projects compile or run Lua in WebAssembly:

  • Wasmoon runs Lua as a script in the browser via a Lua engine compiled to Wasm. It also works with Node.js and Deno, but does not appear to have WASI bindings.
  • WebAssembly-Lua - Likely unmaintained emscripted-based compilation.
  • Wasm_Lua is a project that compiles the Lua engine to WebAssembly, allowing you to run Lua as a script. It also appears to be unmaintained

Usage

Wasmoon, the most promising of the above projects, is used to run Lua scripts (uncompiled) inside of browsers, Node, or Deno. The documentation describes usage.

Pros and Cons

No details.

Example

Currently, there are no examples. None of the known implementations have WASI support.

Learn More

Here are some great resources:

  • This fun blog post explains how to tweak Lua to compile the interpreter to WebAssembly.
  • Wasm2Lua is an interesting project that translates Wasm modules to Lua code.

Interested in learning more?

Get Updates