If it has to go through compilation process to make it native, doesn't that defeat the purpose of Lua? I mean, why not just use the same language of the host application, in other words, just another function/module of that app.
1) You can use interpreted version for rapid development and switch to compiled for release
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.
> 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.
This has been a long known reality of compiling dynamically typed and functional languages to native code.
The primary goal of clx is not size or performance but to ship standalone executables without the need of the Lua VM with a native approach rather than the well known (and somewhat hacky) way to embed a script and the LuaVM inside an executable (and when using binary modules it can be quite tricky !)
15 comments
[ 6.0 ms ] story [ 40.9 ms ] thread2) 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.
This has been a long known reality of compiling dynamically typed and functional languages to native code.