Skip to main content

Zig

Overview

Zig is a systems language focused on simplicity, explicit control, C interoperability, and no hidden control flow. It provides comptime execution, integrated build tooling (zig build), and a path to gradually replace C in native codebases.

Key concepts

  • Comptime: Run Zig code at compile time for generics and metaprogramming.
  • Error unions: !T types with try/catch ergonomics.
  • C interop: Import headers, translate-C, and link C libraries easily.
  • Allocator interface: Explicit memory allocation (no hidden global allocator).
  • Safety modes: Debug checks vs optimized builds.

Build + run

Sample: hello world

const std = @import("std");

pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("hello, world\n", .{});
}

References