Vibeleaderboard
Index / tool
Visit samyeyo.github.io
Category
Developer Tools
Rank
No. 1233Tools index

Previous survey · No. 1212 ·

Type
TOOL
Use case
Coding
GitHub
172 stars
Latest release
v0.5.0
Date

About

clx is a native compiler that turns Lua 5.5 scripts into standalone executables. Version 0.4.0 adds a generational garbage collector, faster function calls, table iteration and SIMD string operations on x64 and ARM64, plus optional dynamic execution of Lua code through an embedded Lua VM. It also fixes crashes caused by values being freed while native code still used them, and can now compile the Teal compiler into a native executable.

What it does

clx takes an ordinary Lua program, translates it into C++ source, and hands that to the C++ compiler already on your machine, so the result is a single native binary with no interpreter shipped beside it. A type-inference step marks values it can prove are plain numbers or integer-keyed arrays, and those become raw machine arithmetic; anything it cannot prove falls back to checked, slower code. An opt-in mode also bundles the real Lua engine so a compiled program can still load and run Lua text at runtime.

Why it's ranked here

Few projects compile Lua ahead of time into standalone executables on Linux, macOS and Windows at once, and this one publishes its numbers. Its own suite of 22 scripts, timed against stock Lua and LuaJIT on all three platforms, shows large wins on recursion and JSON encoding and losses to LuaJIT on float physics, sorting and coroutines. It is MIT licensed, describes itself as beta, and ships an end-to-end test runner plus a feature-by-feature compatibility table. The honest benchmark tables, losses included, are the main reason to trust it.

What's good

The code generator has a stated safety rule: when the optimizer cannot prove a type, it emits the generic checked path, so a wrong guess costs speed rather than correctness. Output size is the default build profile, with a separate speed profile and a debug profile. Standard libraries are split into separate archives, and a minimal mode links only the base and package libraries. Existing C modules written against the stock Lua 5.5 C API are linked statically without source changes, and the test runner exercises that path. Coroutine switching uses hand-written assembly on ARM64 and on x86-64 Linux.

Tradeoffs

Speed is uneven. On Windows with MSVC, three of the 22 timed scripts run slightly slower than plain Lua, and LuaJIT is faster on 13 or 14 of the 22 on each platform. Loading Lua text at runtime and requiring Lua files from disk both need the bundled-engine mode, and loading accepts only strings, not reader functions. The debug library is not exposed. Native modules must be linked in at build time; there is no runtime loading of shared libraries. A list of remaining behavioral differences exists but is kept out of the repository. The C++ compiler is fixed when clx itself is built.

How to use it well

Reach for it when you want to ship a Lua tool, game or utility as one native file, especially one that leans on recursion or JSON encoding, where its own numbers show the biggest gains. Build clx with the compiler you want your programs built with, since switching later means rebuilding it. Use the speed profile for hot code and keep the default size profile for distribution. Run your own suite before trusting it, because the compatibility notes list known gaps. If you need a debugger hook, runtime module loading or the fastest float math, stock Lua or LuaJIT still fits better.

Technical notes+

Pipeline per doc/internals/architecture.md: lexer, recursive-descent parser that resolves every name to global, local or captured at parse time, an optimizer of 15 annotate-only passes (owners, numbers, functions, tables, structs), then a code generator that emits either native double/int64 shapes or generic runtime calls. In src/codegen/codegen.cpp the integer-subtype tracking (int_flag_expr, int_value_expr) recurses to a depth cap of 24 and returns the conservative answer past it. include/clx_runtime.h defines a 16-byte LValue (8-byte payload plus type tag), short strings packed inline with length in the top byte, and GC headers with three ages (young, survivor, old). CMakeLists.txt builds two runtime archives (speed and size), one archive per std module, a separate C API bridge archive, and the vendored Lua VM only for dynamic mode; LTO is off under MinGW to avoid a GCC 15.3 internal compiler error, and x86 defaults to SSE2 unless CLX_ARCH is set. src/clx.cpp resolves the compiler from CLX_CXX or the one embedded at build time and classifies module archives as C or C++ by scanning symbol tables. tests/run.sh compiles conformance, regression, stress, edge_cases and realworld directories plus native-module and C API cases, invoking g++ directly for the module fixtures.

Observed

License
MIT
Implementation language
C++17, built with CMake 3.15 or newer
Input language
Lua 5.5
Interface
Command-line compiler producing executables, object files or static libraries
Platforms
Linux, macOS and Windows; GCC, Clang, MSVC, clang-cl and MinGW toolchains
Declared maturity
Beta, per the README
Runtime code loading
Only with the opt-in dynamic mode, which embeds the Lua VM
Not provided
debug library; runtime loading of shared-library modules
Test suite
End-to-end shell runner in tests/run.sh covering conformance, regression, stress, edge cases and real-world programs
Benchmark disclosure
Per-script timings against Lua 5.5 and LuaJIT on three platforms in doc/benchmarks.md, including cases where clx is slower

Read from README.md, CMakeLists.txt, doc/internals/architecture.md, doc/compatibility.md, doc/getting-started.md, src/clx.cpp, src/codegen/codegen.cpp, include/clx_runtime.h, doc/benchmarks.md, tests/run.sh.

Tags

luacompilernativeperformancetealexecutables

Comments (0)

No comments yet

Editorially curated, with community endorsements as a secondary signal. Corrections welcome.