Odin Lab Examples
How to use this page: click View to open a file in the code viewer, read it, download it, and run it with the Odin toolchain. Every demo is designed to be edited — change a value, re-run, and watch the output move.
odin run 01_hellope.odin -file # compile and run one file
odin check . # type-check a folder, no binary produced
odin test . # run the @(test) procedures in a package
odinfmt -w 01_hellope.odin # rewrite a file in the official style
Two notes about those commands. The -file flag is what tells the compiler to treat a single file as its own package — without it, odin expects a directory. And odin test works on a folder, which is why the testing demo asks you to copy it into a folder of its own first.
Foundations
PHASE 1 — the shape of a program, declarations, scope, and the defer habit that follows you through the whole track.
| # | Description | Link |
|---|---|---|
| 1 | Hello, odin! — the smallest complete program | View |
| 2 | Values and Scope — declarations, mutability, constants, defer | View |
Types & Control
PHASE 2 — the type families and their sizes, the operators including the bitwise family, decisions, and every form of for.
| # | Description | Link |
|---|---|---|
| 3 | Types — families, widths, conversions, casts, distinct types | View |
| 4 | Operators — arithmetic, comparison, logic, and the bits | View |
| 5 | Control and Loops — if, switch, four for shapes, labelled break | View |
Composition
PHASE 3 — procedures with several results, the four data shapes, and containers that copy, view or own their memory.
| # | Description | Link |
|---|---|---|
| 6 | Procedures — results, named returns, defaults, defer | View |
| 7 | Structs, Enums, Bit Sets and Unions — the four data shapes | View |
| 8 | Collections and Maps — array, slice, dynamic array, map | View |
Memory & Data
PHASE 4 — addresses and dereferencing, the allocator discipline that replaces a garbage collector, and the layout decisions that decide how fast a loop runs.
| # | Description | Link |
|---|---|---|
| 9 | Pointers — addresses, dereferencing, nil, and editing in place | View |
| 10 | Allocators — make, new, delete, free, and the temporary allocator | View |
| 11 | Data-Oriented Design — layout, cache-friendly loops, flags, timing | View |
Reliability & Metaprogramming
PHASE 5 — errors as values, one body for many types, decisions made while compiling, and the standard packages you reach for daily.
| # | Description | Link |
|---|---|---|
| 12 | Errors — the two-value shape, or_return, or_else | View |
| 13 | Generics — $T parameters, where clauses, a generic stack | View |
| 14 | Compile-time Programming — when, #assert, ODIN_OS, ODIN_DEBUG | View |
| 15 | Core Packages — imports, aliases, os.args, sorting, building strings | View |
Interop & Tooling
PHASE 6 — threads that run alongside the main one, and the tests that keep yesterday's answers true tomorrow.
| # | Description | Link |
|---|---|---|
| 16 | Threads — create, pass data through the handle, start, join | View |
| 17 | Testing — @(test) procedures, expect, expect_value, memory tracking | View |
How to Practise With These
A demo read once teaches very little, so here is a sequence that teaches more than the reading does. Take one file per sitting, in order.
defer delete, dereference a nil pointer, pass a float where an integer is expected. The compiler's messages are part of the lesson, and reading them is a skill of its own.
When a demo is too easy, edit it into something you actually want: a word counter, a rectangle checker, a tiny file inspector. The language only becomes yours when the program stops being an exercise.