The Lake Programming Language
Lake is a process-oriented programming language built around machines, branches, and state transitions.
Programs in Lake are composed of machines — lightweight processes that define behavior through pattern-matched branches with typed parameters. Machines communicate by spawning new processes or transitioning their own state via self(). A cooperative scheduler manages concurrent execution of all spawned machines.
@rt(rt_write)
counter is {
n i64 -> {
when 0 == n {
true -> { rt_write(1 "done\n" 5) }
false -> { self(n-1) }
}
}
}
main is {
_ i64.0 -> {
counter(5)
counter(3)
counter(7)
}
}
This program spawns three independent counter processes that run concurrently. Each counter decrements until it reaches zero, then prints “done”.
Key Ideas
- Machines are the core abstraction — each machine call spawns a new cooperatively-scheduled process
- Branches define behavior through pattern matching on argument types
self(args)performs a state transition within the current process (no new process is spawned)- Calling another machine spawns it as a new concurrent process
- Cooperative scheduling — each process runs a quantum of work before yielding to the scheduler
- O(1) branch dispatch — branches are selected by hashing the argument types at compile time
Status
Lake is in active development. This book documents the features that are currently implemented and working in the native compiler.