
Master Zig from scratch, learning syntax, types, functions, loops, error handling, pointers, and memory management through practical projects, a compiled, statically typed language ideal for system programming and embedded contexts.
Beginner's guide to Zig promotes a two-pass approach, hands-on practice, and debugging with print statements and documentation, plus seeking help when needed.
Install Zig on your machine and set up the VSCode Zig Language extension and ZLS, then verify by running zig version and compiling hello_world.zig with zig build-exe.
Explore defining functions with fn, using pub, var, and const, importing the standard library with @import, and printing formatted output with placeholders.
Explore Zig's standard library, including print with format strings and specifiers. Use the log module for debug, info, warn, and error, and mem.eql() to compare arrays by memory addresses.
Learn how Zig handles variables with var and const, type inference, and mutability; explore proper usage, unused-variable workarounds with underscores, memory addresses, identifiers, and shadowing.
Understand Zig's type system: unsigned and signed integers with u8 and i16, floats f16 to f128, void, noreturn, and type concepts like anytype and anyerror.
Explore how integer types define ranges for signed and unsigned values by bit width, with 8-bit examples and overflow handling via wrapping and saturating operations.
Learn how Zig represents characters as ascii numbers and strings as arrays, using single quotes for chars, double quotes for strings, and display with 'd' and 's' specs.
Understand boolean logic by working with true or false values, performing equality and inequality checks across numeric types, and composing conditions with and, or, not, while managing precedence with brackets.
Explore how optional types in Zig hold null values and print them. Learn default unwrap with orelse, the ? unwrap syntax, and when null causes errors.
Explore comptime in zig, contrasting compile time and runtime, and how comptime known expressions, comptime variables, and comptime types enable compile time optimization.
Learn how blocks limit variable scope, support nesting, and serve as expressions that can return values using labeled blocks and the break keyword.
Explore how if expressions conditionally execute code with boolean, optional, and error union conditions, including else if, else branches, and unwrapping strategies.
Explore defining and calling functions in Zig with fn, parameters, and return types. Learn passing functions as arguments, using anytype, and importing public resources with @import.
Define a Zig Point struct with x, y, z fields, explore struct literals, default values, dot notation, and associated functions for mutation and printing.
Explore generic programming in Zig by using comptime types to create reusable data structures like a generic Point and a linked list, with type parameters and optional pointers to instantiate.
Learn how Zig enums define finite values, use dot notation for directions and statuses, infer types, assign underlying values, and convert between enums and integers with intFromEnum and enumFromInt.
Master how unions define a set of possible types using the union keyword, with a single active field, and learn simple versus tagged unions and active field behavior.
Learn how Zig's switch expression replaces if/else chains by matching a single value, with ranges and comptime expressions, and supports enums and tagged unions.
Explore Zig errors: understand error sets, error unions, try and default unwrap, anyerror, and how to print and handle errors across functions.
Explore Zig arrays: fixed length, type inference, and literals. Index, mutate, slice, concatenate, and repeat arrays; work with u8 printing using print specifiers and multi-dimensional arrays.
Explore how while loops in Zig repeat code while a boolean, optional, or error union condition holds, using break, continue, labeled loops, and an else block.
Explore how the for loop iterates over arrays and ranges, combines multiple arrays or ranges, handles pointers for mutable elements, and uses else, break, and continue for control flow.
Explore how vectors hold homogeneous values and enable elementwise operations like add and mul. Use splat to convert scalars, and typeInfo to determine length, with vector and array conversions supported.
In Zig, defer and errdefer execute expressions at scope exit, with defer always running, errdefer only on errors, and resources or connections freed in reverse order.
Discover memory's byte organization and how variables are stored, then master Zig pointers, including address retrieval, unwrapping, and single- and many-item pointers.
Discover how Zig slices, a many-item pointer with a length, are created by slicing arrays, require a runtime-bound to become a slice, and support element access, mutation, and iteration.
Explore how Zig allocators manage memory for pointers and nodes, using allocator.create to allocate, and allocator.destroy or free to deallocate, preventing memory leaks.
Welcome to Beginner's Guide to Zig.
Jump-start your Zig learning journey with this course.
This course will start at the basics of Zig: how to run your first Zig program, language syntax, different types the language offers, and more. Separate attention will be given to the data structures (like structs, unions, enums, and arrays), and control flow statements (such as if and switch expressions, while and for loops). We will also learn memory management (pointers, slices, Allocators), and Zig's comptime concept.
After the lectures, we will solidify our understanding of the language with various projects.
This course is a work in progress, and it will be updated with new lectures and projects.
Topics learned in this course will carry over to other of your programming endeavors, and will make you a more rounded developer. As Zig is a lower level language than most popular languages today (such as JavaScript, Python, C#), you will experience first hand how these languages operate under the hood. Learning Zig will make you more comfortable with using other lower level languages, and will teach you to appreciate the work done for you by the higher level languages.
Basic programming experience is required for this course. If you can write basic scripts in any programming language, know what are and how to use functions, you are ready for this course.
Disclaimer on the use of AI:
No AI assistance was used to create any content used in this course. The entirety of this course, with all of its warts and flaws, was generated by a person.