Zig
Learn Zig: explicit control flow, slices and pointers, errors and optionals, allocators, comptime generics, C interop, cross-compiling, build.zig and tests.
What you'll learn
- Explain Zig's design principles and use the zig toolchain, build modes and project layout.
- Write Zig with explicit types and casts, control-flow expressions, arrays, slices, strings and pointers.
- Model data with structs, enums and tagged unions, and handle failures with error unions and optionals.
- Manage memory with allocators, defer and errdefer, and use standard containers safely.
- Use comptime for constants, generics and reflection, and understand safety checks and integer semantics.
- Interoperate with C, cross-compile, build and test with build.zig, and write concurrent, efficient code.
Syllabus
Getting Started with Zig
Control Flow, Arrays, Slices and Pointers
Structs, Unions and Error Handling
- Structs, Methods and Namespaces
- Enums, Tagged Unions and Exhaustive switch
- Errors, Optionals, try, catch and errdefer
Memory and Allocators
- Allocators: Explicit Memory Management
- defer, errdefer and Ownership
- ArrayList, HashMap and Other Containers
Compile-Time Programming
Safety, C Interop and Cross-Compilation
- Integer Semantics, Safety Checks and Undefined Behaviour
- Interoperating with C
- Cross-Compilation and zig cc