Zig as a Multi-OS Build System (with Loris Cro)

This is a very interesting discussion that focuses on Zig as a build system.

Also available as podcast: https://pod.link/developer-voices/episode/9c4985d9ca07a7b352f94c65b995a003

Notes:

  • Python is basically a nice frontend to a lot of C libraries
  • Docker containers for every OS/Arch are commonly used in CI to build binaries
  • Python Wheels have eliminated a lot of the pain of native code in Python packages, but they are simply pre-built binaries – they still need to be build somewhere.
  • Zig proposed to cross-compile C code from one machine.
  • Zig packages all of the various libc and platform bits required to cross build on any platform (like Go).
  • Discussion of the problems of cross-compiling C code
  • The Python package index size is growing a lot due to all the binaries that are stored for every architecture and version (see graph below).
  • Zig build is declarative, but still creates a build graph.
  • There is no such thing as a clean operation for Zig build – no reason to clean your cache.
  • Zig cache is more than just timestamps: inode, hash of file, etc.
  • Can install Zig using pypi: ziglang Β· PyPI
  • Zig gets rid of all your build dependencies – one dependency is both your compiler, build system, and package manager.
  • Loris Cro has written a static site generator in Zig. Uses the Zig build system to build the site.

I think we’re seeing the future here. Build systems (including cross-compilation) are moving to the language domain. This has already happened with Go and Rust – it looks like Zig is positioned to make this change for C.

1 Like

4 posts were merged into an existing topic: Intro to the Zig Programming Language β€’ Andrew Kelley β€’ GOTO 2022