What agents mean for Rust (and vice versa)
https://smallcultfollowing.com/babysteps/blog/2026/10/14/agentic-dev-and-rust/📌 Rust為何在agent時代逆勢爆紅?一位語言設計者的觀察
TL;DR:資深語言設計者分析,Rust的型別系統正成為agent寫程式碼時不可或缺的護欄。
當AI agent寫出的前幾個測試一路綠燈通過,接下來某個測試卻冒出一個你完全無法想像來源的詭異bug——這正是型別系統該站出來擋一道的時刻。
🤔 LLM讓他對程式語言設計產生existential dread
作者從五年級就開始在一臺5MHz、硬碟容量約5MB、記憶體512K的x86電腦上寫程式。硬體雖然天差地遠,但「把程式碼打進檔案」這件事本身,數十年來出乎意料地穩定,直到近幾年LLM出現才徹底翻轉。這讓他一度對自己身為程式設計者、語言設計者的技能是否還有價值感到存在性的焦慮。他在這篇文章給出的結論是:人類在程式設計中仍有角色,程式語言設計仍然重要,而Rust恰好特別適合agentic開發——雖然還能做得更好。
📊 Rust正夯:Meta今年寫的Rust比過去九年總和還多
文章引用的語言成長圖表顯示,TypeScript是成長最快的「breakout language」,年成長率達1200%;Rust則是成長第二快的語言。David Tolnay的說法被引用:Meta工程師今年寫的第一方Rust程式碼量,已經是過去九年加總的兩倍。作者認為原因之一是agent讓嘗試新語言的門檻變低,加上Rust效能的口碑,但他更傾向認為,Rust本身的特性恰好適合agentic coding。
🧩 軟體工廠的三支柱:設計、構建、最佳化
作者提出,一套有效的「軟體工廠」仰賴三個環節:設計(明確定義程式該做什麼)、構建(寫出符合規格的程式碼)、最佳化(讓程式碼高效運作)。這三者都還沒被完全解決,但各自的進展程度不同。
🧩 agent正在讓效能調校的黑魔法變簡單
Rust的設計哲學是「預設就有好效能」,符合慣例的寫法通常也就是最快的寫法,同時保留手動調校的空間:可以控制變數是配置在堆疊還是heap、指標間接層發生在哪裡、強制struct的記憶體排列方式,甚至決定async堆疊框架中何時進行boxing,極限情況下還能寫inline組合語言。過去學習「調這些效能旋鈕」帶點黑魔法色彩,作者觀察到agent正在讓這件事變得容易許多:原本靠手工調校組合語言做高效能密碼學演算法的工程師,現在也開始改用agent完成同樣工作;許多打造網路服務的工程師搭配像dial9這類profiler,讓agent有效診斷出async效能陷阱,例如長時間polling或blocking的問題。
💡 編譯過幾乎就是對的:型別系統是agent的護欄
作者認為,效能口碑吸引人們接觸Rust,但真正讓人留下來的,是「用起來感覺比較不容易出錯」。他引用Greg Brockman的說法:「Rust對agent來說是完美的語言,因為只要能編譯過,幾乎就是對的。」作者認同Rust、OCaml、Haskell這類具備「編譯過就能動」特性的語言,會讓agent明顯受益。他也引用Dijkstra的名言「測試只能證明bug存在,不能證明bug不存在」,並根據自身經驗描述:用agent寫程式碼時,最初幾個測試常常看起來很棒,但下一個測試卻會冒出完全無法理解來龍去脈的詭異bug,深入追查後往往發現agent根本誤解了想表達的邏輯。這正是型別系統能發揮作用的地方——Rust的guardrails不只檢查欄位名稱是否正確這類基本錯誤,還能保證像「socket一定會被關閉」這樣的性質。
⚠️ 型別系統能證明沒bug,不能證明程式正確
作者也自嘲提出一句話:型別系統能證明bug不存在,卻不能證明程式正確。型別系統終究只是一套簡單規則,遵守它能避免特定種類的錯誤,但不保證你做了對的事。若要進一步驗證更豐富的性質,需要證明系統,他點出Rust生態中已有Verus、Creusot、Aeneas、Kani等證明工具,舉例來說可以用來證明程式碼panic-free,但他也提醒,這仍是一種類似型別檢查器的性質保證,而非完整的正確性證明。
🎯 給正在評估agent大量產碼的團隊
如果團隊正考慮讓agent大量產出程式碼,這篇文章給出一個明確方向:選用型別系統嚴謹的語言,讓編譯器成為agent即時的回饋迴圈與安全網,而不是只靠測試把關;若追求效能,搭配profiler與agent的組合,正在取代過去仰賴手工調校的黑魔法技藝;同時Verus、Creusot等形式驗證工具,值得留意作為型別系統之外更進一步的正確性保障。
🔗 來源
- 標題:What agents mean for Rust (and vice versa)
- 作者/機構:mfrw(Hacker News)
- 連結:https://smallcultfollowing.com/babysteps/blog/2026/10/14/agentic-dev-and-rust/
#Rust #AgenticCoding #ProgrammingLanguages #TypeSystems #AIAgents #SoftwareEngineering #FormalVerification #LanguageDesign #DeveloperTools #CodeGeneration
原始資料 Hacker News · 收集於 2026-10-14
摘要原文
Me, calmly assessing the implications of LLMs for programming language design(ers). As someone who has made a career of programming language design, I definitely have moments of existential dread about the rise of LLMs. I started coding in 5th grade on an x86 1 that ran at 5MHz, had something like a 5MB hard-disk and 512K of RAM 2 . Computers were really, really different back then. But honestly, programming wasn’t. For all the advances in IDEs and programming languages and so forth, the basic act of entering code into a file has remained surprisingly constant 3 – right up until a few years ago, when everything kinda turned on its head. That’s been exciting and empowering at times 4 but also scary and disorienting. Will my skills in programming matter? What about my skills in programming language design (such as they are)? This blog post is my attempt to answer those questions. So as not to keep you in suspense, let me just give you the conclusion. In short, yes, I believe there will still be a role for humans in programming . And yes, I think that programming language design is still relevant . And, naturally, I also happen to think Rust is a really good fit for agentic development – but that’s not to say we can’t make it a better fit . And that’s what this post is ultimately about: what makes Rust and agentic development work well, and where we could double down on those strengths. This is a kind of “blog post companion version” of a talk I gave this week at REBASE, part of SPLASH . You might also enjoy the slides from the talk I gave at IWACO, IWACO and Rust: hidden links revealed , which was a bit more of a retrospective (no soundtrack for those, though). In any case, this turned out to be a great conference! Jack Huey presented on the Rust Vision Doc and, quite to my surprise, Steve Klabnik and Dorian Scheidt presented “LLMs as Collaborators in Language Specification and Design” , talking about their process in building out Rue . It was fun to see Steve again. On top of that, there was a ton of great research presented at IWACO in particular. I was particularly taken by the work on Reachability Types and Information Borrowing . I also really liked learning about Hylo Lang , particularly their approach to projections. Clever and cool. Rust is popular in the agentic era From the most important Slack channel at Amazon, #aws-memes. Rust is popular right now. Very popular: Stratospheric among the breakout languages is TypeScript, cropped from the chart and sitting currently at +1200% growth from the prior year. [..] The second most rapid recent growth is in Rust. Meta engineers have written twice as much first-party Rust code so far this year than in the previous 9 years combined. — David Tolnay (emphasis mine) Some of that is because agents make it very easy to try out new things. And some of that is because Rust has a reputation for being performant and, if it’s just as easy to pick any language, why not pick one that will yield faster execution times? But I think Rust is popular for another reason: because Rust happens to be a really good fit for agentic coding 6 . Of course, I would, wouldn’t I? The point of this post is (1) to argue for why that is and then (2) to discuss what we might change about Rust to make it work even better. Foundational Software construction with agents It seems to me that an effective “software factory” will have three pillars: Design: figure out and specify clearly what the code is supposed to do. Construction: author code that does what it is supposed to do. Optimization: optimize the code so that it runs efficiently. None of these pillars are solved, but some have made more progress than others. Rust and optimization: fast by default, knobs when you need ’em Rust is designed to give “good performance by default”, making the idiomatic thing typically also be the fastest thing. But another key part of Rust is that you have the knobs to eke out better performance when you need it. You control when something is stack- or heap-allocated and where pointer indirection occurs. If you want to, you can force the layout of your structs to be done in a particular way, or decide where to introduce boxing into your async stack frames. In the limit, you can put in inline assembly. In the past, learning how to “tune the performance knobs” could be a bit of a black art: but agents are making that much easier. 7 It turns out that agents are really good at fine-tuning the performance of existing code. For example, people who work on super high-performance cryptographic algorithms used to do so by hand-tuning assembly code. But those people tell me that they are now turning to agents for that same job. More prosaicly, a lot of people building network services are finding that, using a profiler like dial9 , agents can quite effectively diagnose async performance pitfalls, like long polls or blocking. Therefore, I think the task for Rust is clear. We keep on with our goal of “low-level enough for a kernel, high level enough for a GUI” . If anything, I think the shift around agents means we can tolerate a bit more “noise” in the form of explicit calls to clone() or share() – but not too much, since we still want the “happy path” of the code to be clear and evident 8 , even as we surface details that are important in specific scenarios (like tracking precisely how many clones you have of a channel endpoint). Combined with a profiler, you get an effective feedback loop to get your code running fast: flowchart LR Code -- Benchmark --> Profile Profile -- Analyzed by --> Agent Agent -- Propose --> PR PR -- Improve --> Code Reliability is king, as always As usual though, while a reputation for good performance is what brings people to Rust, what makes them want to stay is a sense that using Rust “just seems to work better”. The basic theory is that Rust’s type system and guardrails help keep agents on track : rust is a perfect language for agents, given that if it compiles it's ~correct — Greg Brockman (@gdb) January 2, 2026 I think there’s truth in that: languages like Rust, Ocaml, or Haskell all share this “if it compiles, it works” feeling, and I think that agents will benefit from that. Testing is not enough, type systems help Testing can show the presence of bugs, but not their absence. — Edsger W. Dijkstra, 1970 Agents presenting their work. Writing tests has never been enough to show that your program is correct – but, with agents, it’s not even close. It happens so often that my first few tests seem great and then the next one goes completely bonkers. Usually bonkers in a way where I cannot even imagine how that bug could have come about. Then I dig in and I realize the agent completely missed the boat on the logic I was trying to express. 9 This is where a type systems really shines – particularly an advanced one like Rust. Type systems give you some guardrails that keep the agent on track. In Rust, those guardrails extend beyond simple stuff like “do all fields have the correct names” and to stuff like never having to close a socket . Type systems are not enough either Type systems can show the absence of bugs, but not the presence of correctness. — Me, failing to coin a phrase of equal eloquence 10 , 2026 So yeah, type systems are helpful! But they have inherent limits. A type system is a simple set of rules that, if you follow them, make sure that you avoid (certain kinds of) mistakes. But they don’t tell you that you do the right thing – only that you don’t do (certain kinds of) wrong things . If you want to go further, you need a proof system – something that will let you show that richer properties are actively true, not just that you’re avoiding bugs. As it happens, there are a lot of interesting proof tools for Rust, like Verus , Creusot , Aeneas , and Kani . As a starting point, you can prove that your code is panic-free, which will eliminate a lot of bugs, though it is still fundamentally a “type-checker-like” property (i.e. (62 points, 53 comments on Hacker News)
由 claude-code/sonnet 自動生成