Lua - an ergonomic interface to Luerl, aiming to be the best way to use Luerl from Elixir

I wanted to announce the stable release of a project started at TV Labs, called Lua.

Features

  • ~LUA sigil for validating Lua code at compile-time
  • deflua macro for exposing Elixir functions to Lua
  • Improved error messages and sandboxing
  • Deep setting/getting variables and state
  • Excellent documentation and guides for working with Luerl

Lua the Elixir library vs Lua the language {: .info}

When referring to this library, Lua will be stylized as a link.

References to Lua the language will be in plaintext and not linked.

From the blog post

The first stable release of the Elixir library, Lua v0.1.0, has been released to hex.pm!

Lua is a library that allows you to execute arbitrary, sandboxed Lua programs directly on the BEAM VM. This is not embedding the C Lua runtime and compiler, but rather a complete implementation of Lua 5.3. This feat is made possible by the underlying Luerl library, which implements a Lua parser, compiler, and runtime, all in Erlang.

The Lua Elixir library extends the capabilities of the Luerl library, improving error messages and providing robust documentation.

Blog post
Documentation

15 Likes

This looks excellent, excited to play with it and keeping an eye out for future luerl updates!

1 Like

Ha, congrats on the release! I did not realized I’d happened upon something that hadn’t been officially announced yet when asking this :grin:

1 Like

I have released version v0.2.0

[v0.2.0] - 2025-05-14

Changed

  • Any data returned from a deflua function, or a function set by Lua.set!/3 is now validated. If the data is not an identity value, or an encoded value, it will raise an exception. In the past, Lua and Luerl would happily accept bad values, causing downstream problems in the program. This led to unexpected behavior, where depending on if the data passed was decoded or not, the program would succeed or fail

Full Changelog: Comparing v0.1.1...v0.2.0 · tv-labs/lua · GitHub

Release tag: Release v0.2.0 · tv-labs/lua · GitHub
Hex: lua | Hex

2 Likes

[v0.2.1] - 2025-05-14

Added

  • Lua.encode_list!/2 and Lua.decode_list!/2 for encoding and decoding function arguments and return values

Fixed

  • Ensure that list return values are properly encoded

Full Changelog: Comparing v0.2.0...v0.2.1 · tv-labs/lua · GitHub

2 Likes