Skip to content
Search

Zig

lastmod 2026-05-13created 2022-05-267 edits

Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

Categories

  • zero-native - Build desktop + mobile apps with Zig and a web UI

How Uber uses Zig

Uber compiles C/C++ code with zig cc (bazel-zig-cc)

    • Currently only in the Go Monorepo. Plans to expand to other languages that use the C/C++ toolchain
    • Because it allows choosing the glibc version and cross-compiling for macOS
  • However, no plans to use the Zig language itself. That is, only Zig's C toolchain is used
  • Uber donates to the Zig Software Foundation (ZSF) and signed a bug-fix priority contract ($52800)
  • Strengths of zig cc
    • A fully hermetic C/C++ compiler only 40MB in size. Just 1/10 of standard CLang
    • Can link against the glibc version given as a command-line argument
    • Host and Target are decoupled. Configuration for linux-aarch64 and darwin-x86_64 is identical regardless of host
    • Linking with musl is just like choosing another libc version -target x86_64-linux-musl

Things Zig's comptime won't do

  • Things Zig's comptime won't do | GeekNews
  • Zig's comptime provides very powerful compile-time evaluation but is intentionally limited
  • Host information is inaccessible during compile-time code execution, a design suited to cross-compilation
  • Dynamic code generation, DSLs, RTTI, I/O, etc. are not supported; explicit type-based code specialization is used instead
  • RTTI can be implemented manually, but type information that exists only at compile time can be reconstructed for use at runtime
  • comptime can create new types but cannot extend APIs; adding user-defined methods is impossible

See also

Favorite site

author Zer0 sitemap