Introduction
Zig++ is to Zig what TypeScript is to JavaScript: a superset that adds the
features people kept asking for. Every valid Zig program is a valid Zig++
program, unless it names something priv (write @"priv" instead).
Like Zig, Zig++ is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software. Unlike Zig, it has private fields, it will never drop LLVM, it welcomes AI, and its BDFL is Matthew Neel. Zig++ is a fork of Zig, and nearly all of the compiler was written by upstream Zig contributors.
The source is at github.com/mattneel/zigpp,
where this book’s sources live as doc/book/.
What Zig++ adds
- Private fields. A struct or union field marked
privcan only be named from the file that declares its type. See Private fields. - LLVM forever, and a blessed path to GPUs:
std.gpuruns Zig++ and its standard library on NVIDIA, AMD, and Apple GPUs. See LLVM is forever and GPU Programming. - AI in the toolchain. See AI Policy and Governance.
- Any Zig version, automatically. A project’s
build.zig.zoncan pin the exact compiler version it is built with, andzigruns that version instead of itself, downloading it on first use. See Any Zig Version. - A BDFL and one rule: talk about code. See Governance.
Questions people ask
Does Zig++ compile to Zig, the way TypeScript compiles to JavaScript? No. It compiles to machine code, C, WebAssembly, PTX, AMD GPU code objects, and Metal libraries.
Is Zig++ stable? Zig++ follows semantic versioning exactly as closely as
TypeScript does. The compiler is at 0.17.0-dev, every push to master is a
release, and Versions and Releases explains what the version
string means.
What version is Zig++? None. Every push to master is a release, and every
release is kept forever: you pin the build you use. A build is named for the
upstream version it tracks, its commit height, and its commit, as in
0.17.0-dev.2469+zigpp.04926fc36. See Live at Head.
When is 1.0? 1.0 is a milestone, not a version. The milestone closes when Zig++ gets its borrow checker, and the build that closes it ships like every other build. There is no Zig++ 1.0.
Can upstream Zig build Zig++? No. Zig++ changed std.lang.Type, and an
upstream Zig binary cannot compile against it. Use the CMake build,
bootstrap.c, or an existing Zig++ binary; see
Building from Source.
Which LLVM does Zig++ use? LLVM, Clang, and LLD 23.1.2.
Where is the standard library documentation? At /std/,
generated from the newest release, and the language reference is at
/langref.html. Both are also served for the version you
installed: doc/langref.html is in every release archive, and zig std serves
the autodocs and opens a browser tab.
Where to start
- Installing — download a release, check its SHA256SUMS, and
run
zig. - What Zig++ Adds — private fields, LLVM,
std.gpu. - GPU Programming — kernels, the CUDA, HIP, and Metal host APIs, and the standalone test that runs them.
- Building from Source — the CMake build, the bootstrap compiler, and the devkits that CI uses.