前端前線 2026 年 7 月 20 日

2026-07-20 — Bun 執行環境完成 Rust 全面改寫並隨 Claude Code 內建版本升級,WHATWG 同步清理九年懸案的 HTML 字元參照剖析規格

primary=https://bun.com/blog/bun-in-rust primary=https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md primary=https://github.com/whatwg/html/commit/85b40db7c40436be8d459e8f4ca2120e823c34f0 primary=https://github.com/whatwg/html/pull/12707 primary=https://github.com/whatwg/html/issues/2733

Bun 執行環境完成 Zig 到 Rust 全面改寫,Claude Code 內建版本隨之升級

Bun Blog · 2026-07-08

背景

Bun 是一款以 Zig 撰寫的 JavaScript/TypeScript 執行環境,涵蓋 transpiler、bundler、套件管理器與 Node.js 相容層。Bun 作者 Jarred Sumner 在 Rewriting Bun in Rust 一文中揭露,團隊於 2026 年 5 月 3 日至 14 日間以 11 天完成整個 Zig 程式庫改寫為 Rust,總計約 535,496 行、1,448 個檔案,過程中大量借助 Claude 模型進行對抗式程式碼審查。作者表示,JavaScript 的垃圾回收與手動記憶體管理混用是穩定性問題根源,改用 Rust 借用檢查器與 Drop trait 後,可在編譯期而非人工審查階段擋下 use-after-free、double-free 與記憶體洩漏。

核心改動

Bun v1.3.14 是最後一個 Zig 版本,v1.4.0 則是首個 Rust 版本,目前先於 canary 通道釋出。以「Claude Code 改用 Rust 版 Bun」為題的多篇報導(含 Simon Willison 的觀察)需要釐清一點:被改寫的是 Bun 這個執行環境本身,並非 Claude Code CLI 的實作語言。Anthropic 官方 claude-code CHANGELOG.md 顯示,內建的 Bun 版本是在 v2.1.186 更新為「Upgraded the bundled Bun runtime to 1.4」;更早的 v2.1.181(6 月 17 日發布)條目中並未提及 Bun 或 Rust。Willison 進一步反解 Claude Code 安裝檔中的字串,找到 563 個 Rust 原始檔名,佐證其內嵌的 Bun 確為 Rust 版本而非舊 Zig 版。

影響範圍

根據 Bun 官方文章在 Linux x64 的測試,改寫後 HTTP 吞吐量提升 2.8%–4.8%,TypeScript 編譯與打包快 2.2%–4.7%,執行檔體積縮小約兩成(Windows 版 94MB 降至 76MB)。對前端開發者而言,實際影響侷限於 Bun 生態系與依賴其打包工具鏈的效能表現,Claude Code 只是眾多內嵌 Bun 作為執行環境的專案之一,隨上游版本更新而受惠,並非自身改用 Rust 開發。

原始來源:Bun Blog:Rewriting Bun in Rustanthropics/claude-code CHANGELOG.md


WHATWG HTML 規格清理九年懸案:十進位字元參照少一個多餘狀態

WHATWG HTML Commits · 2026-07-19

背景

HTML 剖析器的 tokenizer 在處理 A 這類數值字元參照時,會先進入「numeric character reference state」,再依下一個字元分岔至十六進位或十進位分支。Issue #2733 早在 2017 年 6 月由 inikulin 提出:規格額外設了一個獨立的「decimal character reference start state」,但它遇到 ASCII 數字時的行為,其實與 numeric character reference state 完全重複,形同一個永遠只做同一件事的中繼跳板,閒置了九年才被處理。

規格細節

WHATWG 編輯 annevkcommit 85b40db7PR #12707)將該狀態併入 numeric character reference state:遇到 ASCII 數字時直接 reconsume 並跳轉至 decimal character reference state,省去中間跳板;原本的 absence-of-digits-in-numeric-character-reference parse error、flush 與 reconsume-in-return-state 行為完全保留。異動僅涉及 index.htmlparsing.html 兩份規格原始檔(+6/-20 行),並刻意保留舊狀態的錨點 ID,避免外部文件連結失效。

影響範圍

這純粹是編輯性(editorial)修訂,不改變任何瀏覽器可觀察的剖析行為,Chrome、Firefox、Safari 均不需調整既有 tokenizer 實作。其價值在於讓規格文字更精簡、少一個容易被誤讀為獨立分支的狀態節點,方便日後撰寫剖析器或教材的人正確理解字元參照狀態機的實際流程。

原始來源:whatwg/html commit 85b40db7PR #12707Issue #2733


End of article
0
Would love your thoughts, please comment.x
()
x