Lesson 6: From source code to binary
You have written code. Now let us follow what happens when the CLI turns that code into an executable program.
The compilation pipeline
When you run arandu check, the compiler moves through stages that separate text, meaning, and execution:
- Lexer — turns characters into tokens such as
func,main,int, and literals. - Parser — organizes tokens into a concrete syntax tree (CST), preserving the file structure.
- Resolution and type checking — resolves modules, names, and types; it also checks ownership and usage rules.
- AMIR — represents the program in an intermediate IR where analyses and guarantees can be applied.
- Backend — translates the IR for the execution target. The current backend uses Cranelift for JIT and AOT.
check stops before generating and running an artifact. run uses the host execution path; build produces a native artifact for distribution.
Types and representation
Primitive types are not interchangeable:
| Type | Represents | Typical use |
|---|---|---|
int |
platform-sized integer | ordinary counters and quantities |
i8, i16, i32, i64 |
fixed-width integer | protocols, files, and binary layouts |
uint and unsigned variants |
non-negative integer | sizes and indexes when required by the domain |
f32, f64 |
floating-point value | measurements and approximate calculations |
bool |
true or false | states and conditions |
str |
text | messages and textual identifiers |
int is convenient when a value follows the target’s natural width. i32 does not mean “better integer”: it means exactly 32 bits, which matters when layout must remain stable across machines. The compiler and TargetInfo use the target to know size, alignment, and offsets.
What multiplatform means
The same source code can be analyzed for different targets, but a native binary is not universal. A Windows executable is not the same artifact as a Linux or macOS executable: each needs the corresponding ABI, linker, and system conventions.
src/main.aru
│
├── build for x86_64-pc-windows-msvc → Windows executable
├── build for x86_64-unknown-linux-gnu → Linux executable
└── build for aarch64-apple-darwin → macOS/Apple Silicon executable
Support for a new target depends on the backend, TargetInfo, and that system’s linking tools. Confirm the supported matrix for the installed release.
The pipeline is incremental: compiler queries can reuse results that did not change. Larger projects therefore do not need to reprocess everything after every edit.
Practice
Change balance in the first lesson from int to i32, run arandu check, and compare the contract. Then run arandu build and inspect the artifact produced for the current host.
This is the tour’s destination: write readable code, understand type contracts, control ownership, and know what the compiler guarantees at each stage.