Buz – Bun 的一个分支,使用现代 Zig 编写,支持 1 秒以内的增量构建
Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

原始链接: https://ziggit.dev/t/buz-a-drop-in-replacement-for-bun-using-modern-zig-with-sub-1s-incremental-builds/16891

本项目是 Bun 的一个在制品分支,基于其转向 Rust 之前的最后一次提交。其核心目标是通过专注于地道的 Zig 语言编写方式并减少技术债务,打造一个“去垃圾化”、可维护且能直接替代 Bun 1.4.0 的版本。 主要特性包括: * **构建优化:** 本项目采用了现代化的 `build.zig` 系统,实现了亚秒级的增量构建。 * **代码清理:** 已移除超过 11,000 行冗余代码,并持续利用 Zig 标准库对架构进行现代化改造。 * **测试:** 项目集成了来自 Rust 版本的新测试套件,以追踪功能对等性和错误修复情况。 开发者明确将当前的 Bun 代码库称为“AI 垃圾(AI slop)”,并计划广泛利用大语言模型(LLM)来梳理和重写该项目。由于当前代码尚处于混乱状态,目前暂不接受人工贡献。项目的长期目标是将其重构为一个简洁、舒适且高性能,并由人工监管维护的代码库。

“Buz”是 Bun JavaScript 运行时的一个新分支,它使用现代化的 Zig 语言进行了重写,实现了亚秒级的增量构建。该项目是对近期 Bun 迁移至 Rust(主要归因于构建性能问题)的一种反驳。 该项目在 Hacker News 上引发了关于几个主题的激烈讨论: * **构建性能:** 支持者认为 Buz 证明了 Bun 构建速度慢是开发实践而非语言限制所致,从而驳斥了近期重写为 Rust 的必要性。 * **关于“垃圾代码”(Slop)的争论:** 该项目的创建者实施了一项禁止人工贡献的严格政策,旨在利用人工智能来“清理”代码库。这引发了关于“AI 垃圾代码”兴起、大语言模型在重构大型项目中的效用,以及 AI 生成的代码是否具有可维护性的激烈讨论。 * **工程哲学:** 批评者质疑将复杂的运行时作为个人项目来维护是否具有长期可持续性;而支持者则将其视为对代码质量、管理和现代软件“去臃肿化”的必要推动。 归根结底,这场讨论凸显了开发者社区在人工智能在软件架构中的作用与传统人工主导维护之间存在的深刻文化鸿沟。
相关文章

原文

This is my WIP fork of Bun, based on the last commit before their Rust rewrite. It is still very early in its development and is nowhere near ready for production. I saw that a similar project had already been posted on Ziggit, so I am posting mine to avoid duplicating any development effort, though I have not looked at the other project as of this writing.

I have ported Bun to build with the current upstream Zig (with minor patches to get incremental rebuilds to work). The whole build graph is now in build.zig, including vendored sources of JavaScriptCore. This allows for sub-1s incremental builds, greatly improving the dev loop for the project.

The goal is to be a drop-in replacement for Bun, with a saner codebase. To that end, I have imported all the new tests from Rust Bun into the project, many of them covering new features and bug fixes. A lot of tests don’t pass yet, so this will be a treadmill of keeping up with upstream. But I am trying to deslop the codebase in the process, and keep reducing technical debt.

To that end, I’ve cut over 11,000 lines of completely dead code from Bun. I can’t think of another project whose codebase was so neglected as to reach 11K lines of dead code. I’ve also rewritten and modernized parts of the codebase, trying to rely more on Zig’s stdlib. In the process, countless bugs have also been fixed.

Supported Zig versions

The project has a slightly patched Zig master submodule, mostly regarding incremental builds. Upstream Zig at yesterday’s commit 2b1c663 should be able to build it just fine.

AI / LLM usage disclosure

Bun is the quintessential AI slop project at this point. Inheriting that is no easy task. I don’t think any human should sacrifice their sanity untangling this mess of 600K lines of slop code. For that reason, I will not be accepting any human-coded contributions until I deem the project to be in a sane enough shape. It will likely require most subsystems to be rewritten.

To this end, LLMs will be used extensively. But hopefully better development practices, with a human in the driver’s seat, and a focus on reducing technical debt and writing idiomatic Zig, mean that in a few weeks or months there will be a presentable codebase that serves as a drop-in replacement for Rust Bun 1.4.0. If you have access to Sol or Fable, you can help me get there faster.

Feel free to point out cases of the most egregious slop in the Bun codebase, and I’ll do my best to fix and modernize them. I am using this as a way to improve my own Zig skills. In the long term, I hope this becomes a codebase that is pleasant enough to maintain without LLM help.

联系我们 contact @ memedata.com