Bun 项目从 Zig 重写为 Rust:借助 AI 代理的 11 天工程奇迹
评分
78本文公开了大型软件重写结合AI代理的详细成本、流程和挑战,信息增量极高。
描述详实,包含具体数字和思考过程,质量上乘。
对从事AI辅助编程或大型重构的团队具有直接参考价值。
2026年7月的最新文章,时效性很好。
来源为Simon Willison博客,作者本人是知名开发者,且引用了Jarred Sumner的原始博客,可信度高。
基础分 86.5 × T2 信源权重 ×0.9 = 78
精选线 70已入选精选
精选理由
内容详细展示了 AI 代理在复杂工程任务中的实际能力,具有极高的信息密度和启发性。
AI 点评
「这篇博客是AI代理工程能力的里程碑式展示。它不仅打破了“不要从头重写”的经典教条,还公开了惊人的成本数据和实操细节。对于任何在大型代码库上尝试AI辅助重构的团队来说,都是必读材料。Jarred对Zig的诚实评价也值得学习。」
速览
Bun 的创建者 Jarred Sumner 发布博客,详细描述了他如何利用 AI 编码代理(基于 Anthropic 的 Mythos/Fable 模型)在短短 11 天内将整个 Bun 运行时从 Zig 重写为 Rust。重写过程中,AI 生成了超过 100 万行代码,消耗了约 165,000 美元的 token 费用,并依赖 TypeScript 编写的测试套件作为符合性标准。通过对抗性代码审查和流程修复,团队成功合并了这次大规模重写。新版本已在 Claude Code 中上线,启动速度提升 10%。这一案例展示了 AI 代理在大型软件工程中的潜力。
- Bun 的创建者 Jarred Sumner 使用 AI 编码代理在 11 天内将 Bun 从 Zig 重写为 Rust,消耗约 16.5 万美元 token 费用。
- 重写过程依赖 TypeScript 测试套件作为符合性标准,通过对抗性审查和流程修复确保代码质量。
- 重写原因:Zig 的手动内存管理导致大量 use-after-free、double-free 等 bug;Rust 的安全保证能消除此类问题。
- 新版本已在 Claude Code 中上线,启动速度提升 10%,用户几乎未察觉变化。
正文
以下为原文,中文全文翻译生成中
Honestly, it was worth the wait. This is a detailed description of an extremely sophisticated piece of agentic engineering, featuring dynamic workflows, trial runs, adversarial review and all sorts of other interesting tricks.
Jarred spends the first half of the post praising Zig for getting Bun this far. Then we get to a core idea in the piece, emphasis mine:
Our bugfix list felt bad and I was tired of going to sleep worrying about crashes in Bun. I don't blame Zig for that - other users of Zig don't have the bugs we had, and mixing GC with manually-managed memory is an uncommon enough thing for software to need that no language really designs for it. We wouldn't have gotten this far if not for Zig, and I'll always be grateful. Until very recently, programming language choice was a one-way decision for a project like Bun.
Everyone knows you should never stop the world and rewrite a large piece of software from the ground up. Joel Spolsky highlighted that in Things You Should Never Do, Part I back in April 2000!
Coding agents powered by today's frontier models change that equation.
Why pick Rust? It all came down to those challenges with memory management:
A large percentage of bugs from that list are use-after-free, double-free, and "forgot to free" in an error path. In safe Rust, these are compiler errors and RAII-like automatic cleanup with
Drop.
A crucial enabling factor for the rewrite was that the Bun test suite was written in TypeScript, which meant it could act as a conformance suite. This allowed an agent harness to automate much of the initial port from Bun to Rust, initially as an experiment to try out an earlier version of the model we now have access to as Mythos/Fable.
At first, I didn't expect it to work. A few days in, a high % of the test suite started passing and I saw how much the new Rust code matched up with the original Zig codebase. My opinion went from "this is worth trying" to "I'm going to merge this". [...]
For most of those 11 days (and after), I monitored workflows - manually reading the outputs to check for issues and bugs, and prompting Claude to edit the loop to fix things.
How do you review a PR with +1 million lines added? How do you start to build the confidence needed to responsibly merge large quantities of LLM-authored code?
A language-independent test suite with a million assertions, adversarial code review and when something does go wrong, fixing the process that generates the code instead of hand-fixing the code.
The new implementation of Bun has been live in Claude Code for nearly a month now:
Claude Code v2.1.181 (released June 17th) and later use the Rust port of Bun. Startup got 10% faster on Linux but otherwise, barely anyone noticed. Boring is good.
A perk of working at Anthropic is that you don't have to pay for your tokens - handy when the estimated cost is $165,000!
Pre-merge, this took 5.9 billion uncached input tokens, 690 million output tokens, and 72 billion cached input token reads — around $165,000 at API pricing.
This whole thing is a fascinating case study in taking on wildly ambitious projects with the help of coordinated parallel agents.
Via Hacker News
Tags: ai, rust, zig, generative-ai, llms, ai-assisted-programming, anthropic, bun, conformance-suites, agentic-engineering, claude-mythos-fable
相关条目
89
精选OpenAI研究:AI正在重新定义工作边界
如果你关心AI对实际工作的影响,这篇研究不容错过。它不讨论理论,而是用数据展示ChatGPT用户如何使用AI扩展自己的任务范围,这对HR、管理者以及每个希望提升技能的职场人都有直接启发。
87
精选OpenAI CFO 分享构建 AI 原生财务职能的五大经验
作为编辑,我认为这篇文章的价值在于它来自 AI 领军企业的财务一把手,而非外部咨询机构,因此更具实践参考性。推荐给财务数字化负责人、CFO 以及对 AI 转型感兴趣的从业者阅读。
87
精选智能体AI时代下的科学计算:OpenAI发布新领域报告
这份报告是当前AI agent热潮中最务实的应用分析之一,尤其适合计算生物学和药物研发领域的从业者阅读。它回答了“AI agent除了写代码还能干什么”这个关键问题,直接展示了在复杂科学计算中的生产力提升。
87
精选Real World VoiceEQ:量化语音AI的人类自然度
值得关注的是,这个基准真正聚焦'人类自然度'这个软指标,而不是传统的语音识别率或MOS评分。对从事语音合成、语音克隆或语音交互的团队来说,这是一个非常实用的参考工具,可以快速定位模型在情感、韵律等层面上的不足。不过目前支持语言有限,期待后续扩展。
85
精选OpenAI 推出AI时代记分卡:衡量投资回报的新方法
这篇博文直击当前AI行业的软肋——如何量化投入产出。对于正在或计划大规模部署AI的企业决策者而言,它能帮助避免盲目跟风。我个人建议结合自身业务场景尝试定义“有用工作”,避免指标设计流于形式。
85
精选代理时代如何管理AI投资:聚焦每美元有用功与高价值工作流
这篇文章对正在大规模部署AI代理的企业尤为重要。它提醒我们:单纯盯着API价格下降会陷入误区,真正要管理的是每单位工作的投资回报率。建议CTO和CFO联合阅读,并在内部建立量化评估机制。
85
精选设计能跟上AI的组织:组织延迟成为最大障碍
这篇文章真正值得关注的是提出了一个被忽视的瓶颈:技术再强,组织跟不上也是白搭。对CTO、CIO和转型负责人来说,这是比技术选型更重要的思考框架。
84
精选Ruff v0.16.0 发布:默认规则从59条激增至413条,CI工作流需关注
对于 Python 开发者来说,这是一个不容错过的更新信号。Ruff 的默认规则大幅增加意味着我们不能再忽视代码中潜在的问题,而 AI 修复工具正好可以降低升级成本。尤其值得关注的是 Astral(OpenAI)正在将 AI 编码能力与静态分析工具深度整合,这可能是未来工程实践的常态。