Trials and Tribulations of Native Lua Compilation
Posted by _samt_ 3 days ago
Comments
Comment by Philpax 17 hours ago
Comment by _samt_ 8 hours ago
Comment by drdexebtjl 13 hours ago
This is already true of upstream Lua implementations. It is very easy to write thin Lua binding layers to C libraries.
That is the entire point of Lua. It’s easy to call Lua from native code, and it’s easy to call native code back from Lua, so you can have call stacks that seamlessly interweave Lua and native code.
I’m very skeptical of the idea that this can unlock improvements in performance or size. We already have LuaJIT which is plenty fast, and PUC-Lua which is so small, it runs on MCUs.
Comment by _samt_ 8 hours ago
Comment by drdexebtjl 6 hours ago
Comment by _samt_ 4 hours ago
Comment by gucci-on-fleek 4 hours ago
Comment by _samt_ 4 hours ago
Comment by gucci-on-fleek 4 hours ago
If you have the source code for these modules, you can statically link to them too. I've done this myself for Windows a few times, and it works pretty well in my experience.
Comment by _samt_ 4 hours ago
Comment by wiradikusuma 17 hours ago
Comment by PhilipRoman 16 hours ago
2) You may like Lua as a language and want to use it for general purpose programming, not necessarily embedding into host program
I will say though that the performance aspect has to be taken with a grain of salt, "native compilation" is not a meaningful improvement if every source line translates to multiple branches or vtable lookups. From my experience plain conversion of Lua to C (assuming you faithfully follow the specification, including coroutines, metatables, etc.) produces equal or slower code with rare exceptions for numerical loops. If it wasn't all AI generated I'd maybe spend time understanding this project.
Comment by le-mark 11 hours ago
This has been a long known reality of compiling dynamically typed and functional languages to native code.
Comment by _samt_ 8 hours ago
Comment by _samt_ 8 hours ago
Comment by _samt_ 3 days ago