Tutorials
Getting started
- Setup and prerequisites
- Download the Mox compiler, install clang on Linux or Windows, and check that everything works.
- Hello world
- Write, build and run your first Mox program.
- Compiler options
- Pick a backend, turn on optimizations and debug info, and set output paths.
- Linking
- How Mox calls the linker, how to use your own linker, and how to link libraries from code.
Language basics
- Variables and types
- Declare variables, use the basic types, structs, enums, arrays, slices and strings.
- Operators
- Math, comparison, bit operations, casts, vector math with swizzling and the pipe operator.
- Pointers
- Take an address, read through a pointer, access fields and move pointers by bytes.
- Control flow
- if, while, for, switch and defer.
- Functions
- Declare functions, use default arguments, overloading, function pointers and C functions.
- Modules
- Import other files, name imports, and re-export from a module.
- Generics
- Write functions and structs that work for many types, using compile time parameters.
Memory
- Zero is initialization
- Design types so that all-zero memory is a valid, ready to use value. No constructors needed.
- Allocators
- Allocate and free memory with allocators, and swap the allocator for code you call.
- Arenas
- Use arenas and temp buffers for fast short-lived memory.
C libraries
- A window with raylib
- Open a window and draw with raylib, then run the same window at compile time.
- A window with SDL3
- Create an SDL3 window and renderer, handle events, and use a macro for error handling.
Modules
- Animation curves
- Move values from one to another with easing curves using game/animate.mox.
- Immediate state
- Keep state between frames in immediate mode UI and animations with game/immediate_state.mox.
- Texture atlas
- Pack many small images into a few big pages with game/atlas.mox.
- Struct of arrays
- Turn a struct into a struct of arrays with