Introducing Lua for Elixir
Execute arbitrary user code on the BEAM without spinning up Python or JavaScript VMs—this new Elixir library wraps a pure Erlang implementation of Lua for sandboxed scripting, born from a real need at a TV testing startup.
Read Original Summary used for search
TLDR
• Lua v0.1.0 lets you run sandboxed Lua programs directly on BEAM via Luerl (a complete Lua 5.3 implementation in Erlang, not C bindings)
• TV Labs uses it to compile drag-and-drop automation tests to Lua, avoiding the overhead of orchestrating separate JS/Python VMs for device testing
• The deflua macro makes exposing Elixir APIs to Lua trivial, with compile-time syntax validation via ~LUA sigils
• Robert Virding (Erlang co-creator) built Luerl as an experiment: "I did Prolog and Lisp on BEAM, so I wanted to try an imperative language"
• Roadmap includes merging into Luerl 2.0 with dramatically better error messages and deeper Lua ecosystem integration
In Detail
The Lua library for Elixir solves a specific problem: executing arbitrary user-defined code safely without orchestrating separate language runtimes. Built on Luerl—a complete Lua 5.3 parser, compiler, and runtime written entirely in Erlang—it lets you run sandboxed Lua programs directly on the BEAM VM. This isn't embedding the C Lua runtime; it's a pure BEAM implementation. The library adds ergonomic Elixir wrappers, including a deflua macro for exposing Elixir functions to Lua and compile-time syntax validation via sigils.
The practical motivation came from TV Labs, where the author is CTO. They needed customers to write high-level integration tests against physical TVs and streaming devices. Rather than managing Python or JavaScript VMs, they compile drag-and-drop automation workflows to Lua and execute them on compute adjacent to the hardware. This approach keeps everything BEAM-native and avoids the operational complexity of multi-language orchestration.
Luerl itself has an interesting origin: Robert Virding (Erlang co-creator) built it as an experiment after implementing Prolog and Lisp on BEAM, wanting to try an imperative language. The future roadmap focuses on merging the Elixir library into Luerl 2.0, with major improvements to error messages, stack traces, documentation, and sandboxing features. For anyone building platforms that need safe user code execution (plugins, automation, scripting), this demonstrates a BEAM-native alternative to spawning external runtimes.