Cookbook
17 chapters.
- Recipe: Word FrequenciesCount occurrences with a hash map, then rank them with a sort.
- Recipe: Loading a JSON ConfigDefaults for what's missing, validation for what's wrong, clean errors for the rest.
- Recipe: A Binary Wire FormatSerialize a struct to explicit bytes and back, safely.
- Recipe: Catching Memory LeaksMake the test suite prove that every allocation is freed.
- Recipe: Printing Any StructComptime reflection builds a debug printer that works for every struct type.
- Recipe: Overflow Without PanicsHandling arithmetic that might not fit, without undefined behavior and without crashing.
- Recipe: A SIMD Dot ProductUsing @Vector to process four elements per operation, tail included.
- Recipe: SIMD Byte ScanningThe five-step pattern that turns a byte-at-a-time loop into a register-wide scan.
- Recipe: Keeping the Last N ItemsA generic fixed-capacity ring buffer built with a type function.
- Recipe: Set Operations on the CheapStaticBitSet turns membership, intersection, and union into single instructions.
- Recipe: Reproducible RandomnessSeeded generators make random worlds, tests, and replays repeatable.
- Recipe: Splitting Work Across ThreadsDivide a slice among threads with no locks and one join.
- Recipe: An Atomic Work IndexDynamic load balancing with fetchAdd instead of locks or chunking.
- Recipe: A Producer/Consumer Queuestd.Io.Queue as a bounded channel, with close() as the shutdown protocol.
- Recipe: A TCP Round TripListen, connect, and echo through std.Io.net, all in one process.
- Recipe: UDP DatagramsBound sockets and discrete messages, no connection anywhere.
- Recipe: An HTTP Round TripA std.http.Server on a thread, a std.http.Client fetching from it, no dependencies.