A small gift for the LuaRT community: introducing clx
Hello everyone,
Before announcing it elsewhere, I wanted to share a project I've been working on for the last several months with the LuaRT community first.
While LuaRT continues to exist as its own project (even if it is now feature complete), clx is something completely different.
clx is a new ahead-of-time Lua compiler that translates Lua source code to C++, then uses the native C++ toolchain on your computer (Clang, GCC or MSVC) to produce standalone executables.
The goal is not to replace Lua or LuaJIT, nor to be the fastest Lua implementation in every benchmark.
Instead, clx focuses on:
- Native AOT compilation
- Standalone executables
- Fast startup times
- Cross-platform deployment
- Small binaries
- Lua 5.5 compatibility
- Integration with existing C++ toolchains
Current features include:
- Coroutines
- Metatables
- Module system
- Most standard libraries
- Binary module support through a dedicated C++ API
- Linux, Windows and macOS support
The repository also contains:
- A growing Lua compatibility test suite
- Performance benchmarks against Lua and LuaJIT
- Example projects
- Documentation and module development guides
A few examples from the benchmark suite:
Benchmarks (clx speedup over Lua 5.5) :
- fib.lua : 45.5x
- arraysum.lua: 4.1x
- spectralnorm.lua 7.5x
- warmup.lua 1.5x
The clx compiler is already capable of running a Pong game written in Lua, using a Sokol binary module built with clx C++ API, and all of this compiled to a single executable by clx (binary size near 550 kb). This is one of the few examples included right now.
Of course, there are still weak spots, especially some string-heavy workloads where traditional interpreters currently perform better.
The project is currently in beta and I'm sure there are still many edge cases to discover and fix.
Website : [Login to see the link]
Repository: [Login to see the link]
As always, feedback, bug reports, weird Lua programs and edge-case tests are welcome but not on this forum, only on GitHub by opening a new issue.
And finally, thank you to everyone who supported LuaRT over the years. Without this community, clx probably wouldn't exist today.
Samir