r/lua • u/monolith_core • 6d ago
Help Help needed: Best Lua version/implementation for Rust integration and general scripting?
Hey everyone,
I'm trying to pick up Lua mainly for general scripting and embedding into Rust projects for things like config files. If I end up liking it as much as Rust, I'll probably dive deeper into it.
The main thing tripping me up is how many versions and runtimes exist out there (Lua 5.1, 5.4, LuaJIT, Luau, ...).
If anyone has experience embedding Lua in Rust (maybe using `mlua`), which version should I actually focus on learning? Also, are there any weird compatibility traps or gotchas I should watch out for?
Appreciate any advice or resources 🙏
13
Upvotes
1
u/Additional-Elk-3712 22h ago
I use Lua (luau default) as scripting language for my Rust runtime using mlua-rs. its SpyWeb - a lightweight scraping/monitoring automation engine.
Lua 5.1 -> 5.4 version has some enhance and feature improvements, like < 5.3 Lua only has number type, while 5.3 and up has floating point and integer.
JIT version may have improve performance, though I never really benchmark them on my use case.
but there are noticeable difference bewteen standard Lua and Luau, like for Luau, it support type system and some feature are strip like io, os, package, debug which limit what it can do. and the reason I specifically use Luau as default as I need a sandbox environment for better security then just added my own package loader and fs support
So;
If you want the latest feature of Lua, just use 5.4
if you want JIT, you can only use 5.1 or 5.2
if you want type system support, you can use Luau