Lame compiles to native code and has no garbage collector. Every value has one owner, and the compiler checks how values are lent and handed over. The vocabulary stays close to Lua: a few general mechanisms instead of one feature per situation.
Each step is a working program. Edit it, or press one of the mistakes, and the real compiler answers below the editor. It runs here in the page.
Yes: a whole compiler, written in Lua 5.4. It reads Lame, checks it, and writes one C file that any C compiler turns into a program. Press a stage to follow one line of code through it.
Lua was your first choice for the first compiler, and it lets the compiler run compile-time code with the same runtime. Writing C text needs no binding and gives Windows, Linux and macOS at once; the C compiler does the optimizing.
List, Map, Text helpers, Option, files, JSON, threads: all Lame source in std/, built on raw pointers inside unsafe. Only a small C header sits underneath.
A test suite of programs that must run, must be rejected, or must stop with a given message. The generated code was run under Valgrind and sanitizers, and as Windows programs under Wine.
Two benchmarks ran at about 1.2 times the time of hand-written C, with overflow and bounds checks on.
What you already write, and how it looks here.
| Lua | Lame | Note |
|---|
The page above checks code but cannot run it: running needs a C compiler. Locally you get both.
On Windows: Lua 5.4 and MinGW-w64 on the PATH, then bin\lame.bat. The generated programs were tested as Windows executables; running the compiler itself on Windows was not.
lame run file.lamecompile and runlame build file.lame -o appmake an executable; add --release for speedlame check file.lameonly report errorslame test file.lamerun every function named test_…lame fmt file.lamere-indent in placelame doc file.lamepublic functions and their comments as Markdownlame emit-c file.lamewrite the C file and stopexamples/: bank, shapes, tree, calculator, wordcount, life, todo (JSON), parallel (threads), callbacks (C)docs/tour.md and docs/ownership.md: the long form of this pagedocs/reference.md: every rule, with the grammardocs/std/: the library, generated from its commentslua5.4 tests/run.lua: the test suiteYou asked to see where the language ends up unsteered. These are the choices most likely to matter to you; the full list is docs/branch-decisions.md. main is untouched.
add, equals, get, next, drop), like metamethods.Sendable and Shareable.cond and a or b is an exact conditional.? converts an error into the function's error enum when its type is a member.@read; everything else still does.