Every Turf program in these pages is compiled by the language repository’s CI: an example either compiles, or is marked with the error code it must be rejected with. The pages here show real output, and the red error boxes are real compiler messages.
Where to start
Core language
- Variables and Types: declarations,
guessinference, definite assignment, the primitive types, literals, overflow,toconversions,sizeof/typeof. - Operators: the precedence table, arithmetic and its runtime checks, comparison, logical, bitwise,
give/otherwise. - Control Flow:
if,while,do/while,for,break/continue,defer,compareand the pattern language. - Error Handling:
errortypes and payloads,!T,recover,try, caller-located panics.
Structuring programs
- Functions and Modules:
fn, first-class functions, UFCS, annotations,import, the prelude,pubvisibility. - Structs and Enums: declaration, construction, methods, layout cycles, self-referential types,
enum. - State Machines: the
machineconstruct and its checked transitions. - Generics and Operator Overloading: monomorphized generics, the overloadable operators, indexing operators.
- Arrays: fixed-size arrays,
T[]parameters and slicing, bounds checking.
Memory and systems programming
- Memory and Safety: the two heaps,
heap(expr),&T/&?T, escape rules, runtime checks, what safe code guarantees. - FFI and unsafe:
extern fn, linking C libraries, raw pointers,unsafeblocks and modules, capabilities.
Beyond this section
- The standard library has its own pages: Standard library.
- Projects, the command line and diagnostics: Tooling.
- Step-by-step walkthroughs: Guides.
- How the compiler implements all this: How the compiler works.