译:Vibe code 就是遗留代码
原文: https://blog.val.town/vibe-code
作者: Steve Krouse
译者: Gemini 2.5 Pro
尽管存在普遍的 困惑,Andrej Karpathy 创造“vibe coding”这个词时,指的是一种 AI 辅助编程,在这种状态下你 “甚至都忘了代码的存在”。
遗留代码
We already have a phrase for code that nobody understands: legacy code.
对于谁也看不懂的代码,我们已经有了一个词:legacy code (遗留代码)。
Legacy code is universally despised, and for good reason. But why? You have the code, right? Can’t you figure it out from there?
遗留代码是人见人嫌的东西,这不无道理。但为什么呢?代码不就在那儿吗?你不能从代码本身搞懂它吗?
Wrong. Code that nobody understands is tech debt. It takes a lot of time to understand unfamiliar code enough to debug it, let alone introduce new features without also introducing bugs.
错了。没人能看懂的代码就是技术债。要花大量时间去理解陌生的代码,才能进行调试,更别提在不引入新 bug 的前提下增加功能了。
Programming is fundamentally theory building, not producing lines of code. We know this. This is why we make fun of business people who try to measure developer productivity in lines of code.
编程的本质是理论构建,而不是产出代码行。我们都懂这个道理。所以我们才会嘲笑那些试图用代码行数来衡量开发者生产力的商业人士。
When you vibe code, you are incurring tech debt as fast as the LLM can spit it out. Which is why vibe coding is perfect for prototypes and throwaway projects: It’s only legacy code if you have to maintain it!
当你进行 vibe code 时,你积累技术债的速度,和 LLM 输出代码的速度一样快。这也正是为什么 vibe code 完美适用于原型和一次性项目:只有当你需要维护它时,它才算是遗留代码!
原型和一次性代码
I’ve happily vibe coded apps to:
我愉快地用 vibe code 写过一些应用,用来:
- Calculate weekly growth rates
- 计算周增长率
- Rate NYT Connections
- 给纽约时报 Connections 游戏评分
- Propose to my fiance
- 向我的未婚妻求婚
I don’t needed to continue developing those apps, so it hasn’t been a problem that I don’t understand their code. These apps are also very small, which means that I haven’t incurred that much debt if I need to jump in and read the code at some point. I was able to vibe code these apps way faster than I could’ve built them, and it was a blast.
我不需要持续开发这些应用,所以看不懂它们的代码也没什么问题。这些应用也很小,这意味着即便我将来需要回头读代码,欠下的债也不多。用 vibe code 的方式构建这些应用,比我自己动手快得多,而且乐趣无穷。
Vibe code 是一个光谱
Vibe coding is on a spectrum of how much you understand the code. The more you understand, the less you are vibing.
Vibe code 存在于一个光谱之上,取决于你对代码的理解程度。你理解得越多,vibe 的成分就越少。
Simply by being an engineer and asking for a web app with a persistent database, you are already vibing less than than a non-programmer who asks for an “app” without understanding the distinction between a web app and a native app, or how persistent data storage works.
仅仅因为你是一名工程师,在要求一个带持久化数据库的 Web 应用时,你的 vibe 程度就已经低于一个非程序员了。那个非程序员可能只是想要一个“app”,却不明白 Web 应用和原生应用的差别,也不知道持久化数据存储是怎么回事。
把信用卡给一个孩子
The worst possible situation is to have a non-programmer vibe code a large project that they intend to maintain. This would be the equivalent of giving a credit card to a child without first explaining the concept of debt.
最糟糕的情况,莫过于让一个非程序员用 vibe code 的方式来做一个他们打算长期维护的大项目。这就好比把信用卡交给一个孩子,却没先向他解释什么是债务。
As you can imagine, the first phase is ecstatic. I can wave this little piece of plastic in stores and take whatever I want!
你可以想象,第一阶段是欣喜若狂的。我可以在商店里挥舞这张小塑料片,想要什么拿什么!
Which is a lot like AI can build anything now! Nobody needs to learn how to code! Look at what it just made for me!
这很像——AI 现在什么都能做了!谁都不用学编程了!快看它刚给我做的东西!
But if you wait a month, you’ll get the credit card bill. Did I actually need to buy all those things? How will I get myself out of this hole?
但等上一个月,信用卡账单就来了。我真的需要买那些东西吗?我该怎么把自己从这个坑里拉出来?
It’s similar for the vibe coder. My code broken. What do all these files and folders even do? How will I ever get this fixed? Can I get a refund for the $400 I spent vibe coding?
Vibe coder 的情况也类似。我的代码坏了。这些文件和文件夹到底是干什么的?我怎么才能修好它?我 vibe code 花掉的 400 美元能退款吗?
If you don’t understand the code, your only recourse is to ask AI to fix it for you, which is like paying off credit card debt with another credit card.
如果你看不懂代码,唯一的办法就是让 AI 帮你修复,这就像用一张信用卡去还另一张信用卡的债。
2025 年用 AI 进行严肃编程
If you’re building something serious that you intend to maintain in 2025, Andrej has the right of it:
如果你在 2025 年要构建一个需要长期维护的严肃项目,Andrej 的看法是对的:
[Keep] a very tight leash on this new over-eager junior intern savant with encyclopedic knowledge of software, but who also bullshits you all the time, has an over-abundance of courage and shows little to no taste for good code. And emphasis on being slow, defensive, careful, paranoid, and on always taking the inline learning opportunity, not delegating.
— Andrej Karpathy, twitter
你得紧紧牵住这个新来的实习生,他过分积极,是个天才,拥有百科全书般的软件知识,但同时又总是对你胡说八道,勇气过剩,而且对好代码几乎毫无品味。重点是要慢下来,采取防御姿态,小心、多疑,并且总是抓住机会在实践中学习,而不是把任务全权委托出去。
— Andrej Karpathy, twitter
我们如何为 AI 进行构建
At Val Town, we’ve built AI into our product in dozens of ways. Townie is our AI asisstant that agentically reads & writes code, runs it, views the logs, and keeps iterating until it’s done.
在 Val Town,我们以几十种方式将 AI 融入了我们的产品。Townie 是我们的 AI 助手,它能像一个智能体一样读取和编写代码、运行代码、查看日志,并不断迭代直到任务完成。
Townie is an awesome tool for vibe coding. I heartily recommend it to folks who understand these tradeoffs. I use it to vibe code sometimes. Other times I keep in on a tight leash as it makes surgical edits to a project I care about. Both are fun and useful.
Townie 是一个很棒的 vibe code 工具。我衷心向那些理解其中利弊的人推荐它。我有时用它来 vibe code。其他时候,我会紧紧地控制它,让它对我关心的项目进行外科手术式的精确修改。这两种用法都很有趣,也很有用。
Coding with AI is changing so quickly that it’s hard to know what tomorrow will bring, but I’m confident that theory building will remain central to the activity of building complex software. Our technical expertise will still be relevant! And I’m optimistic that AI will continue to make programming better in suprising ways.
用 AI 编程这个领域变化太快,很难说未来会怎样,但我相信,理论构建依然会是构建复杂软件的核心活动。我们的技术专长仍然至关重要!而且我乐观地认为,AI 将继续以令人惊喜的方式让编程变得更好。
But if you know any non-programmers spending thousands of dollars vibe coding their billion dollar app idea today, please send them this post. Vibe coding is not going to get them where they want to go. They’re going to have to learn to use their human eyes to read the code 😱, and learn that sometimes it’s easier to start over with building a well-written code base from scratch than to fix a legacy one that nobody understands.
但是,如果你认识哪个非程序员,今天正花着成千上万美金,用 vibe code 的方式实现他们价值十亿美金的应用想法,请把这篇文章发给他们。Vibe code 并不能带他们到达想去的地方。他们将不得不学会用自己的肉眼去读代码 😱,并且要明白,有时候,从头开始构建一个编写良好的代码库,要比修复一个谁也看不懂的遗留系统更容易。
This essay is a distillation of a talk I gave last month, The Role of the Human Brain in Programming. Thanks to my fiance Emily for listening to me rant about these topics for months, and for filming my talk. Thanks Malte and Rippling for hosting the talk.
这篇文章是我上个月一次演讲的精炼版本,演讲题目是“编程中人脑的角色”。感谢我的未婚妻 Emily 几个月来听我喋喋不休地谈论这些话题,并为我拍摄了演讲视频。感谢 Malte 和 Rippling 主办了这次演讲。
Thanks Geoffrey Litt, Jimmy Koppel, Max McDonnell, Tom MacWright, Charmaine Lee, Brent Jackson, and Dan Shipper for feedback on this post. Thanks Simon Willison and Andrej Karpathy for being voices of reason amidst all the AI hype and naysayers.
感谢 Geoffrey Litt, Jimmy Koppel, Max McDonnell, Tom MacWright, Charmaine Lee, Brent Jackson, 和 Dan Shipper 对本文的反馈。感谢 Simon Willison 和 Andrej Karpathy 在所有 AI 的炒作和唱衰声中,成为理性的声音。