Getting Started
Building the Compiler
The Lake native compiler is written in Rust (edition 2024) and uses Cranelift as its code generation backend:
git clone https://github.com/morphqdd/lake-native-compiler.git
cd lake-native-compiler
cargo build
Running an Example
cargo run -- examples/counter.lake -o counter
./counter
First Program
Here is a minimal Lake program:
@rt(rt_write)
main is {
_ i64.0 -> {
rt_write(1 "hello, lake!\n" 14)
}
}
This program:
- Declares a runtime function
rt_writevia the@rtdirective - Defines a
mainmachine with a single branch - Calls
rt_writewith a file descriptor (1= stdout), a string, and its length
Program Structure
Every Lake program consists of:
- Directives — compiler attributes that declare runtime functions (
@rt) - Machines — the program logic, defined with
is
@rt(rt_write) # 1. directive
main is { # 2. machine
_ i64.0 -> {
rt_write(1 "done\n" 5)
}
}
Machines can be declared in any order — forward references are resolved automatically.