什么是 Zig?
Zig is a general-purpose programming language and toolchain designed for maintaining robust, optimal, and reusable software. Created by Andrew Kelley, Zig aims to be a better alternative to C, offering modern language features while maintaining the simplicity and performance that systems programmers need.
🔥 Key Features of Zig
⚡ Simple & Fast
No hidden control flow, no hidden memory allocations, no preprocessor. Focus on debugging your application, not your language knowledge.
🔧 Comptime Magic
Compile-time code execution and lazy evaluation. Call any function at compile-time and manipulate types as values without runtime overhead.
🌐 Cross-Compilation
Built-in cross-compilation support for dozens of targets. No external dependencies needed for most platforms.
🔄 C/C++ Interop
Use Zig as a drop-in C/C++ compiler with better cross-compilation. Incrementally adopt Zig in existing codebases.
🆕 Zig 0.16.0 新特性
- I/O 作为接口:所有 I/O 现在需要传入
Io实例,支持线程、事件驱动和异步后端 - 异步与取消:内置任务并发(Futures 和 Groups),以及跨所有 I/O 操作的标准化取消机制
- 新元编程内置函数:
@Type被专用内置函数替代(@Int、@Struct、@Union、@Enum等),泛型代码更简洁 - 原生 Deflate 压缩:内置 deflate 压缩,性能与 zlib 相当,解压 API 更简洁
- 更好的堆栈追踪:几乎所有平台均支持安全的栈展开,调试信息更完整,支持内联调用者
- 扩展目标平台支持:CI 新增 8+ 架构,包括 aarch64-freebsd、loongarch64、powerpc64le 和 s390x
📦 从 debian.griffo.io 安装
步骤 1:添加仓库
This repository uses reprepro, which is configured to keep only the latest version of each package. This means older builds are replaced when a new release ships — you cannot pin a specific version with
apt install zig=0.15.2 after 0.16.0 has been published.To let users keep a previous release installed alongside the current one, packages are now named by stability tier:
zig— meta-package, always pulls inzig-stablezig-stable— current stable release (e.g. 0.16.0)zig-oldstable— previous stable release (e.g. 0.15.2), installable alongsidezig-stablezig-0— deprecated, installzig-stableinstead
zig-stable and zig-oldstable register with update-alternatives
so you can switch the active /usr/bin/zig at any time.⬆️ 升级到 0.16.0:如果您已安装旧包结构中的
zig-0,必须先将其删除:步骤 2:安装 Zig
🎯 基本使用示例
Create a new project:
Compile a single file:
Use as C compiler:
🚀 为什么选择 debian.griffo.io?
- ✅ Always Latest: Get Zig 0.15.2 immediately, not months later
- ✅ Nightly Builds: Access cutting-edge features with zig-master package
- ✅ Automatic Updates: Packages updated within hours of upstream releases
- ✅ Proper Dependencies: Correctly packaged with all required dependencies
- ✅ Multi-Distribution: Works on Bookworm, Trixie, and Sid
- ✅ Zero Hassle: No manual compilation or complex setup required
📦 软件包构建仓库
Debian 软件包在这些 GitHub 仓库中自动构建和维护:
- 🇿 zig-debian (stable) - Stable release builds
- 🇿 zig-master-debian (nightly) - Nightly development builds
🔗 相关软件包
也可从 debian.griffo.io 获取:
- ZLS Language Server - IDE support for Zig
- Ghostty Terminal - Fast terminal emulator
- Yazi File Manager - Terminal file manager