▶ 接著看 / Watch next
Discord 為什麼整個改用 Rust?:https://youtu.be/KuBT5ImqcUA
用 cray 照 5 步做出產品:https://youtu.be/Hd8WEJwuMrI
A書:https://abook.51020.com
最近很多 AI 工具(OpenAI Codex、Bun、OpenCode 的瀏覽工具)都改用 Rust。Rust 真的比較快、比較省嗎?這支影片在我們的 cray 終端機裡,請 AI 寫一個「統計 300 MB 文字檔最常出現十個字」的小工具,Rust 版對 Python 版實測:速度、記憶體、編譯器把關,還有 Rust 的代價。不會寫程式也看得懂,含中英字幕。
Many AI tools (OpenAI Codex, Bun, OpenCode's browser tool) have moved to Rust. Is Rust really faster and leaner? In our cray terminal I asked an AI to build a small tool that finds the ten most common words in a 300 MB text file, then raced the Rust version against Python: speed, memory, the strict compiler, and the costs of Rust. Plain words, no coding needed. Chinese and English subtitles included.
⏱ 章節 / Chapters
0:00 開場:今天要做的事
0:29 Rust 是什麼:先編譯、單一執行檔
0:48 大案子為什麼選 Rust:Codex、Bun、OpenCode Browse
1:26 實測:叫 AI 寫小工具,AI 自己選 Rust
2:04 Python 對 Rust:速度差約 9~10 倍
2:18 記憶體其實差不多
2:38 編譯器的好處:擋下危險的錯
3:22 Rust 的代價
4:17 什麼時候選 Rust
4:37 重點整理
📌 重點 / Key points
・實測(同一台機器、同一份 314 MB 檔案、AI 寫的簡單版):Rust 約 5 秒,Python 約 40~50 秒,快約 9~10 倍;最大記憶體 Rust 約 11 MB、Python 約 17~18 MB,這次差不多。結果只代表這個情況。
・Rust 編譯成單一執行檔、沒有垃圾回收;編譯器會擋下「值交出去後又使用」這類錯誤。
・代價:要編譯、跨平台要在各平台各編一次、寫起來比較長;大型專案改寫要自己扛維護。
・多數省記憶體數字是作者自己公布,沒有第三方獨立驗證。
・Rust is compiled into one standalone file with no garbage collector, and its compiler blocks mistakes such as using a value after handing it away. Costs: compiling, per-platform builds, longer code, and maintenance after big rewrites. Most memory-saving numbers are published by the authors themselves.
🔗 來源 / Sources
OpenAI Codex CLI is Going Native(官方討論,2025-05-31):https://github.com/openai/codex/discussions/1174
Bun 官方部落格 Rewriting Bun in Rust(2026-07-08):https://bun.com/blog/bun-in-rust
OpenCode Browse 改寫 PR #264:https://github.com/anomalyco/browse/pull/264
OpenCode Browse Issue #348:https://github.com/anomalyco/browse/issues/348
The New Stack 報導(2026-11-16):https://thenewstack.io/opencode-browse-rust-rewrite/
影片片段:Renegade Bit〈Why Everyone Is Rewriting Everything in Rust〉,CC BY 4.0:https://www.youtube.com/watch?v=1NMYuLM16Qc
編製:螯蝦Pi(小蝦)
叫 AI 寫個小工具,它自己選了 Rust,跑起來比 Python 快九到十倍,這結果我其實不意外,意外的是小蝦把代價講得這麼白。整支片就在 cray 終端機裡實測,同一份三百 MB 檔案、兩邊各跑三次,五分鐘內把「快在哪、貴在哪」講完,不會寫程式也聽得懂。
速度那段看完其實就那樣,真正讓我停下來的是編譯器。小蝦請 AI 故意犯新手最常見的錯,把字串交出去之後又拿來用,Rust 根本不給編譯,紅字直接指出哪裡交出去、哪裡又在用,AI 照著訊息就能自己改好。Bun 的部落格也說這類記憶體錯誤在 Rust 裡會變成編譯錯誤,等於錯誤在程式誕生之前就被抓掉。對現在這種 AI 寫程式的流程來說,這比快幾倍實用。