track
A deterministic systems language with linear ownership, a Rust/Cranelift bootstrap compiler, and a native lexer marking its first step toward reproducible self-hosting.
Overview
Track is a low-level systems programming language built around deterministic resource management. It uses linear ownership, checked borrows, and non-escaping lexical lenses to prevent use-after-free, double-free, and resource leaks without a garbage collector, runtime, or lifetime annotations.
The current v0.7 toolchain is bootstrapped by a compiler written in Rust. Cranelift is the default native-code backend; LLVM remains an optional Cargo feature rather than the core compilation path.
Track has also crossed its first self-hosting boundary: the repository contains a native lexer written in Track, built and tested as a normal yard package. The parser, checker, and code generator are still implemented in the Rust bootstrap compiler today.
Language Model
- Linear ownership — Owned resources move exactly once and are cleaned up at their spend point or scope exit.
- Borrow references — Shared access is checked at compile time against moves and mutation.
- Lexical lenses —
withblocks provide exclusive mutable access that cannot escape its lexical scope. - Control-flow state merging —
Active,Borrowed,Locked, andSpentstates must agree across branches and loop back-edges. - Tuples and pattern matching — Anonymous tuples, destructuring, nested patterns, tagged unions, and guarded match arms.
- Explicit errors — Status codes,
(value, error)tuples, and out-parameters instead of exceptions, unwinding,Result, or hidden propagation. - Monomorphized generics — Generic functions specialize into concrete native functions at compile time.
import "std/io";
fn main() -> void {
let mut user = User { age: 30 };
with user -> current {
current.set_age(31);
}
io::print("ownership restored after the lens closes");
}
Current Compiler Architecture
The repository ships three Rust-bootstrap binaries:
track— single-file checking and native compilation;yard— package management, deterministic builds, linting, execution, and native Track tests;track-lsp— diagnostics, completion, and editor integration.
The bootstrap pipeline parses and checks Track in Rust, monomorphizes generic functions, and sends verified programs to Cranelift for native object generation. An optional llvm Cargo feature retains an LLVM 22 backend for experimentation, but a normal build does not depend on LLVM.
Self-Hosting Status
v0.7 — native lexer
compiler/src/lexer.trk and compiler/src/token.trk implement the first compiler component in Track itself. The lexer recognizes more than 50 token variants and has native regression coverage for declarations, functions, branches, operators, shifts, strings, and comments through yard test.
v0.8 — native compiler
The current plan ports the remaining compiler in bounded stages:
- lexer parity, source spans, diagnostics, AST, and deterministic module ordering;
- a native recursive-descent parser;
- the linear ownership checker, type inference, and escape analysis;
- a portable C emitter that invokes the platform C compiler through Track’s explicit process API.
Cranelift remains the backend of the Rust bootstrap compiler. The first self-hosted compiler emits C so Track can own its language semantics without first reimplementing Cranelift or maintaining a large native FFI surface.
v0.9 — reproducible bootstrap
The milestone is stricter than compiling the compiler once:
Rust bootstrap → Track compiler stage 1
Track stage 1 → Track compiler stage 2
Track stage 2 → Track compiler stage 3
Stage 2 and stage 3 output must be byte-for-byte identical. That requirement is why deterministic module discovery, emitted-file order, filenames, and build metadata are being specified before the native parser lands.
Build the Current Toolchain
The bootstrap compiler requires a stable Rust toolchain:
git clone https://github.com/dev-dami/track.git
cd track
cargo build --release
Compile a single Track source file:
./target/release/track check examples/hello.trk
./target/release/track build examples/hello.trk
./hello
Build and test the native lexer:
cd compiler
../target/release/yard check
../target/release/yard build
../target/release/yard test
Create a package with Yard:
./target/release/yard init my_app
cd my_app
../target/release/yard check
../target/release/yard build
../target/release/yard run
Track is active compiler research. The native parser, checker, and portable-C backend are planned work, not completed components. The current implementation and roadmap live in the Track repository.