Buz – A fork of Bun using modern Zig, with sub-1s incremental builds
Buz – A fork of Bun using modern Zig, with sub-1s incremental builds
Buz – 基于现代 Zig 的 Bun 分支,支持亚秒级增量构建
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.
这是我正在开发中的 Bun 分支,基于 Bun 转向 Rust 重写之前的最后一个提交。该项目目前处于早期开发阶段,远未达到生产就绪状态。我看到类似的项目已经发布在 Ziggit 上,所以我发布我的项目是为了避免重复开发工作,尽管在撰写本文时我尚未查看过那个项目。
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.
我已经将 Bun 移植到使用当前的 Zig 上游版本进行构建(并打了一些补丁以实现增量重构)。整个构建图现在位于 build.zig 中,包括 JavaScriptCore 的供应商源代码。这使得增量构建时间缩短至 1 秒以内,极大地改善了项目的开发循环。
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.
该项目的目标是成为 Bun 的直接替代品,并拥有更合理的代码库。为此,我已将 Rust 版 Bun 的所有新测试导入到项目中,其中许多测试涵盖了新功能和错误修复。目前仍有许多测试无法通过,因此这将是一个持续跟进上游的漫长过程。但在这一过程中,我正努力清理代码库中的冗余,并不断减少技术债务。
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.
为此,我从 Bun 中删除了超过 11,000 行完全无用的死代码。我想不出还有哪个项目的代码库会被忽视到积累了 1.1 万行死代码的地步。我还重写并现代化了部分代码库,尝试更多地依赖 Zig 的标准库。在此过程中,无数的 Bug 也得到了修复。
Supported Zig versions
支持的 Zig 版本
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.
该项目包含一个经过轻微修补的 Zig master 子模块,主要涉及增量构建。使用昨天提交的 2b1c663 版本上游 Zig 应该可以顺利构建该项目。
AI / LLM usage disclosure
AI / LLM 使用披露
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.
目前的 Bun 可以说是 AI 生成垃圾代码的典型代表。继承这样一个项目绝非易事。我不认为有人应该为了理清这 60 万行混乱的代码而牺牲自己的理智。因此,在我觉得项目达到足够合理的形态之前,我不会接受任何人工编写的贡献。这很可能需要重写大部分子系统。
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.
为此,我将大量使用 LLM。但希望通过更好的开发实践——由人类把控方向,专注于减少技术债务并编写地道的 Zig 代码——在几周或几个月内,能够呈现出一个可用的代码库,作为 Rust 版 Bun 1.4.0 的直接替代品。如果你有 Sol 或 Fable 的使用权限,欢迎协助我更快地达成目标。
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.
欢迎指出 Bun 代码库中最严重的垃圾代码案例,我会尽力修复并将其现代化。我正以此作为提升自身能力的方式。