Returning to Zig
Returning to Zig: From Zig to Rust to Zig again
Returning to Zig: From Zig to Rust to Zig again 重返 Zig:从 Zig 到 Rust,再回到 Zig
2026-06-10 · 9 min · #computing 2026年6月10日 · 9分钟 · #计算
Zig is rising in popularity. It hasn’t yet seized the space occupied by even Rust or Go, much less C, but it has been adopted by a few major projects and countless smaller ones. As such, it’s becoming an important language for the future. Having been interested in Zig for several years, I decided to check back in on the language and see how I feel about it today. Zig 的人气正在上升。虽然它尚未占据 Rust 或 Go 甚至 C 语言所拥有的市场份额,但它已被一些大型项目和无数小型项目所采用。因此,它正成为未来一门重要的编程语言。由于我对 Zig 感兴趣已有数年,我决定重新审视这门语言,看看我今天对它的感受如何。
Why I Loved Zig
我为何热爱 Zig
I was first introduced to Zig in 2020 by a programming mentor. They were passionate about this little new language with compile-time code execution and beautiful yet simple forms of abstraction. I decided to check it out as well. At the time, I was still deep in learning C. I enjoyed the power over my computer, but was frustrated by the dated abstractions and worse tooling. Zig, while new and unstable, was promised as a replacement for C. That hooked me. Why learn C when I could learn the next language? 2020 年,一位编程导师向我介绍了 Zig。他们对这门拥有编译时代码执行能力、抽象形式既美观又简洁的新语言充满热情。我也决定尝试一下。当时,我正深陷于 C 语言的学习中。我享受它赋予我对计算机的掌控力,但对其过时的抽象和糟糕的工具链感到沮丧。Zig 虽然新且不稳定,但被承诺为 C 语言的替代品。这吸引了我。既然可以学习下一代语言,为什么要学 C 呢?
I watched more of Andrew Kelley’s talks. Software Should Be Perfect was formative. It shaped what I viewed what a programming language—and software in general—should look like. In that talk, Andrew emphasized the importance of fallible, explicit memory allocations, no hidden control flow, and universal reusability. Those were all values I began to look for in any programming language. So I switched to Zig. I wrote toy programming languages, experimented with literate programming tooling, and played with Web servers. I enjoyed working with Zig. It felt nicer than C but without the footguns. 我观看了更多 Andrew Kelley 的演讲。《软件应该是完美的》(Software Should Be Perfect)对我影响深远。它塑造了我对编程语言乃至整个软件应有样子的看法。在那次演讲中,Andrew 强调了易错且显式的内存分配、无隐藏控制流以及通用可重用性的重要性。这些都是我开始在任何编程语言中寻找的价值。于是我转向了 Zig。我编写了一些玩具编程语言,尝试了文学编程工具,并玩转了 Web 服务器。我喜欢使用 Zig。它感觉比 C 更好,且没有那些容易让人“自残”的陷阱。
Leaving for Rust
转向 Rust
Zig kept breaking my code. I grew tired of the churn. I was a student without much time to keep my code updated to work with the latest version of the language. This was before anyzig made it trivial to handle multiple versions of Zig on the same system. I often went months between working on particular projects. When I returned I would have to make major refactors I didn’t understand to get them working again. The Zig ecosystem was also immature. As a new programmer, I didn’t have the skills to implement everything on my own. There were few libraries for anything and few examples to teach me. The standard library kept changing. Every time I thought I understood the way its abstractions worked, they would change. It didn’t help that the default documentation was unstable. So I left for Rust.
Zig 不断破坏我的代码。我厌倦了这种变动。当时我还是个学生,没有太多时间去更新代码以适配语言的最新版本。那是在 anyzig 让在同一系统上管理多个 Zig 版本变得简单之前。我经常隔几个月才处理特定的项目。当我回来时,我不得不进行我不理解的重大重构才能让它们重新运行。Zig 的生态系统也不成熟。作为一个新手程序员,我没有能力自己实现所有东西。几乎没有什么库可用,也没有多少示例可以教我。标准库一直在变。每当我以为自己理解了它的抽象工作方式时,它们就变了。默认文档的不稳定也无济于事。所以我转向了 Rust。
At that point, Rust had been stable for years, with a strong ecosystem behind it. Learning it was a pain—I wanted to give up several times—but once I learned it, it worked. That was invaluable for me. A fast, lower-level programming language with the expressiveness I needed without the cost of instability. It also forced me to develop a mental memory model that served me well for languages with fewer built-in checks. As a benefit, given the code didn’t panic, I was able to write reusable code without hidden control flow or a garbage collector. While it did hide memory allocations and made working with C difficult, it brought me almost full circle to why Zig was appealing. I love Rust. I enjoy working in it to this day. The abstractions bring me joy. Unfortunately, I’m concerned by some of the directions the project is going. 那时,Rust 已经稳定多年,背后有着强大的生态系统。学习它很痛苦——我好几次想放弃——但一旦学会,它确实好用。这对我很宝贵。一门快速、底层且具备我所需表达能力的编程语言,且没有不稳定的代价。它还迫使我建立了一个心理内存模型,这对我使用那些内置检查较少的语言非常有帮助。作为一个好处,只要代码不发生 panic,我就能编写出没有隐藏控制流或垃圾回收器的可重用代码。虽然它确实隐藏了内存分配并使与 C 的交互变得困难,但它让我几乎回到了最初被 Zig 吸引的原因。我热爱 Rust。直到今天,我依然喜欢用它工作。它的抽象带给我快乐。不幸的是,我对该项目的一些发展方向感到担忧。
Why I’m Returning
我为何回归
Rust still isn’t perfect. While it provides many of the things I was looking for in a programming language, it isn’t the most ideal for making the reusable programs I want to make. FFI is difficult. Cross-compilation is irritating. Hidden, infallible memory allocations haunt me. Being shackled to LLVM it will be a long time, if ever, until it supports as many platforms as C. Additionally, its governance still irks me. It has several giant corporate foundation members which almost certainly influence the way Rust is developed. When the biggest companies in the world are each giving you hundreds of thousands of dollars per year, you probably don’t want to upset them. Rust 仍然不完美。虽然它提供了我在编程语言中寻找的许多东西,但它并不是制作我想要的可重用程序的理想选择。FFI(外部函数接口)很困难。交叉编译很烦人。隐藏的、不可失败的内存分配困扰着我。由于被束缚在 LLVM 上,它可能需要很长时间(如果能实现的话)才能支持像 C 那样多的平台。此外,它的治理方式仍然让我感到困扰。它有几个巨型企业基金会成员,这几乎肯定会影响 Rust 的开发方式。当世界上最强大的公司每年给你几十万美元时,你可能不想惹恼他们。
Regardless of these, I was willing to accept these until the scourge of vibecoding hit the open source community. To my horror, many software projects were accepting LLM-generated code. I had thought LLMs were unpopular among developers. I figured the only people who used them were forced to by their employers. When this happened, maintainers and users alike wrote or demanded LLM policies. Zig banned them from the project entirely. Meanwhile, Rust took its time. They did some polling and the general sentiment in the community was anti-LLM, but they weren’t ready to make an official policy quite yet. When they finally made a proposal, it included the notorious moderation policy: 尽管如此,我原本愿意接受这些,直到“vibecoding”(指依赖 AI 生成代码)的祸害席卷了开源社区。令我震惊的是,许多软件项目开始接受 LLM 生成的代码。我原以为 LLM 在开发者中并不受欢迎。我以为只有那些被雇主强迫的人才会使用它们。当这种情况发生时,维护者和用户都开始撰写或要求制定 LLM 政策。Zig 完全禁止了项目中使用它们。与此同时,Rust 却不紧不慢。他们进行了一些民意调查,社区的普遍情绪是反 LLM 的,但他们还没有准备好制定正式政策。当他们最终提出提案时,其中包含了臭名昭著的审核政策:
- No comment on this PR may mention the following topics:
- Long-term social or economic impact of LLMs
- The environmental impact of LLMs
- Anything to do with the copyright status of LLM output
- Moral judgements about people who use LLMs
- 此 PR 的任何评论不得提及以下主题:
- LLM 的长期社会或经济影响
- LLM 的环境影响
- 任何与 LLM 输出版权状态相关的内容
- 对使用 LLM 的人的道德评判
It has since been removed after backlash, but the fact that this was the case at all caused me to lose trust in the Rust project going forward. I love the language, but am frustrated with the governance. The policy itself is fine. It almost entirely restricts LLMs. It cuts down on most of the slop. It’s not nearly as severe as Zig’s policy, but it’s workable. But this whole experience got me to explore Zig as a programming language seriously for the first time in a few years. 在遭到强烈反对后,该政策已被删除,但它曾经存在的事实让我对 Rust 项目的未来失去了信任。我热爱这门语言,但对它的治理感到沮丧。政策本身还可以。它几乎完全限制了 LLM,减少了大部分垃圾内容。它不像 Zig 的政策那么严厉,但它是可行的。但整个经历促使我几年来第一次认真地将 Zig 作为一门编程语言进行探索。
Zig in 2026
2026 年的 Zig
The first thing I noticed is that the language is still unstable. When I tried to get started with examples I found on the Web for 0.16.0, I learned they were outdated. I learned that the best way to be productive in Zig is to keep a copy of the standard library source available and get familiar with it. I am of no illusions as to Zig’s stability. Zig 0.17.0 will be released soon. It will break the build system of every project. I understand that the maintainers intend to shift towards stabilization and these breakages are part of that. Thankfully, the language hasn’t changed too much since 2020. I found that most of my instincts still held true. A few things in the… 我注意到的第一件事是这门语言仍然不稳定。当我尝试使用在网上找到的 0.16.0 版本的示例入门时,发现它们已经过时了。我了解到,在 Zig 中保持高效的最佳方法是保留一份标准库源代码并熟悉它。我对 Zig 的稳定性没有任何幻想。Zig 0.17.0 即将发布。它会破坏每个项目的构建系统。我理解维护者打算转向稳定,而这些破坏是其中的一部分。值得庆幸的是,自 2020 年以来,这门语言并没有发生太大变化。我发现我的大部分直觉依然适用。其中一些……