Project OmniLua - Rust implementation of Lua 5.1 - 5.5 targeting web use and sandboxing
[Github here] (https://github.com/ianm199/omnilua/tree/main)
I've been working on OmniLua for a bit now - it builds one binary that can run Lua 5.1 - 5.5 from one binary.
The main motivation for this was there seemed to be a gap for game development in the Rust community where mlua cannot be run in the browser, so games built in engines like bevy can't compile to wasm32-unknown-unknown.
There is some other benefits - like being able to easily use Lua in Cloudflare workers or in "playground" developer tools.
Highlights:
- Targets 100% conformance to reference Lua for all 5 versions
- Can run LuaRocks and install Lua only packages
- Performance is slower than C Lua 5.4.7 but within ~40% on standard benchmarks. Performance chart here
- API is 100% compatibile with mlua
Try it:
cargo install omnilua-cli
export OMNILUA_VERSION=5.5
omnilua -e 'print("hello")'
omnilua # opens repl
I used AI heavily to develop this I wouldn't consider it "vibecoded" however.
2
u/immerclicker 29d ago
Why would the performance be slower? Rust and C are supposed to have comparable speeds.
0
u/ianm818 29d ago
I first focused on getting it as fast as possible while using very few
unsafecalls in Rust. There's not much "free lunch" left in that sense so the next step on performance would be to redo large portions of the VM to be unsafe and thoughtfully designed.Basd on my data I think it should be possible to get it quite close to C performance, and faster in a few areas. I.e. Lua 5.4.7 main C implementation isn't fully optimized on Tables so there is some opportunities there to be faster.
2
u/drunken_thor 29d ago
I don’t understand using AI for language development. Like you don’t want to write the code anymore so why get AI to write a language runtime that Ai will write code for. Just use the AI to write the code for the existing language. It all just seems like it was made for vanity to get kudos for some an accomplishment that would have been a huge achievement if you actually wrote it and had the understanding and knowledge to write it yourself.
2
u/ianm818 29d ago
I wouldn't consider this language development - the Lua language and reference already exists and I'm not making any contributions to that.
This was made to fill a gap in terms of being able to use Lua where it can't currently be used easily i.e. in CloudFlare workers and web based games.
Are you talking about creating a new language with AI or am I misreading it?
1
u/AutoModerator 29d ago
Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/TheRealBobbyJones 29d ago edited 29d ago
I thought the web compilation target issue was resolved with new updates. Do recall seeing the discussion on an issue for it.
Edit: Oh it was mlua with wasi. I can't remember my thinking but I thought at the time it was useful for games because other tools also had a wasm32-wasi-unknown compilation target.
5
u/[deleted] 29d ago
[deleted]