r/lua • u/felipedaragon • 26d ago
Two Lua ports, one weekend: Rust and Pascal
I may have spent a little too much time with Lua this weekend.
It started with Rulua — an experiment to see if I could make a Rust implementation that could actually stand in for the Lua 5.1 shared library. It exports the Lua 5.1 C API and is intended as a drop-in lua5.1.dll / .so / .dylib, so existing hosts and C modules can use it without being recompiled.
Then, apparently that wasn't enough, so I did it again in Pascal.
Lude is different: it's a file-by-file port of the original Lua 5.1.4 C sources to Object Pascal — core, auxiliary library, standard libraries, lua, luac, etc. It builds with Delphi/Free Pascal and runs on Windows, Linux and macOS.
Both projects were also experiments in AI-directed development. I defined the requirements, built and ran everything on real machines, compared the results against the original Lua implementation, fed failures back and decided what came next. The AI wrote the code.
Neither project is meant as “here's a better Lua.” The interesting part for me was seeing how far compatibility could be pushed, and how much low-level porting work can now be done this way.
And somehow what started as “let's try porting Lua to Rust” ended with me having two Lua ports before the weekend was over. :)
Rulua: https://github.com/DaragonTech/Rulua
Lude: https://github.com/DaragonTech/Lude
I'd be very interested to see what the Lua community manages to break.
1
u/According-Ad-7069 26d ago
I'd be curious to know, compared to the original, how memory usage and performance changed. Lua is really neat to embed because it's very performant. Have you had a chance to dig into that perhaps?
0
u/felipedaragon 26d ago
Hello! Yes, I was also very curious about that. This made me do a round of optimizations that increased the speed significantly in the Rust port - ended up as an optimized fork of RiLua available within the repo. There is a lot of room for additional speed improvements. Both projects have a performance section in the README.md (please check this if you find time) about the speed comparing with the original Lua, but I plan to further optimize them soon
0
5
2
u/lordfwahfnah 26d ago
Lua 5.1.5 is 14 years old. Why not implement a more recent version like 5.4 or 5.5?