编写代码现在很便宜。
Writing code is cheap now

原始链接: https://simonwillison.net/guides/agentic-engineering-patterns/code-is-cheap/

## 代理工程:思维模式的转变 编码代理的兴起带来了一个重大挑战:适应一个代码*廉价*生产的世界。 历史上,软件开发受限于编写代码的高成本,影响着从项目规划到微观层面的决策,例如重构和文档编写。 现在,代理大大降低了这种成本,打破了关于有价值权衡的既定认知。 虽然生成代码几乎是免费的,但交付*高质量*代码——即功能完善、经过测试、有文档记录且易于维护的代码——仍然昂贵。 成功采用代理工程需要新的习惯。 我们必须克服根深蒂固的本能,避免以前被认为“耗时过长”的任务,并*试验*代理,即使是对于看似微小的改进。 关键在于认识到代理加速了实现,但开发者仍然承担确保质量和使解决方案与实际需求保持一致的责任。 行业仍在定义这些最佳实践,强调需要持续评估和调整。

## 代码廉价,价值不菲 最近一则Hacker News上的帖子引发了讨论,探讨代码生成变得“廉价”是否真的会改变软件开发。 大家的共识大多是**否**——虽然*编写*代码比以往任何时候都容易,但创造*有价值*的软件仍然困难且昂贵。 许多评论员指出,现在的技能在于**引导人工智能产生有用的结果**,而不仅仅是生成代码行。 核心挑战不是打字,而是设计性能良好、安全的应用。 人们对维护代码质量表示担忧,尤其是在大量人工智能生成代码涌入的情况下,以及潜在的技术债务增加。 有几点强调,现有的软件工程问题——例如糟糕的设计和仓促的开发——会被廉价的代码生成所加剧,而不是解决。 存在关于提高编码速度是否需要对开发流程、责任制甚至编程语言进行系统性变化的争论。 最终,讨论表明,虽然人工智能降低了*生成*代码的门槛,但它并没有降低对熟练工程师的需求,以确保代码是*高质量的*。
相关文章

原文

The biggest challenge in adopting agentic engineering practices is getting comfortable with the consequences of the fact that writing code is cheap now.

Code has always been expensive. Producing a few hundred lines of clean, tested code takes most software developers a full day or more. Many of our engineering habits, at both the macro and micro level, are built around this core constraint.

At the macro level we spend a great deal of time designing, estimating and planning out projects, to ensure that our expensive coding time is spent as efficiently as possible. Product feature ideas are evaluated in terms of how much value they can provide in exchange for that time - a feature needs to earn its development costs many times over to be worthwhile!

At the micro level we make hundreds of decisions a day predicated on available time and anticipated tradeoffs. Should I refactor that function to be slightly more elegant if it adds an extra hour of coding time? How about writing documentation? Is it worth adding a test for this edge case? Can I justify building a debug interface for this?

Coding agents dramatically drop the cost of typing code into the computer, which disrupts so many of our existing personal and organizational intuitions about which trade-offs make sense.

The ability to run parallel agents makes this even harder to evaluate, since one human engineer can now be implementing, refactoring, testing and documenting code in multiple places at the same time.

Good code still has a cost

Delivering new code has dropped in price to almost free... but delivering good code remains significantly more expensive than that.

Here's what I mean by "good code":

  • The code works. It does what it's meant to do, without bugs.
  • We know the code works. We've taken steps to confirm to ourselves and to others that the code is fit for purpose.
  • It solves the right problem.
  • It handles error cases gracefully and predictably: it doesn't just consider the happy path. Errors should provide enough information to help future maintainers understand what went wrong.
  • It’s simple and minimal - it does only what’s needed, in a way that both humans and machines can understand now and maintain in the future.
  • It's protected by tests. The tests show that it works now and act as a regression suite to avoid it quietly breaking in the future.
  • It's documented at an appropriate level, and that documentation reflects the current state of the system - if the code changes an existing behavior the existing documentation needs to be updated to match.
  • The design affords future changes. It's important to maintain YAGNI - code with added complexity to anticipate future changes that may never come is often bad code - but it's also important not to write code that makes future changes much harder than they should be.
  • All of the other relevant "ilities" - accessibility, testability, reliability, security, maintainability, observability, scalability, usability - the non-functional quality measures that are appropriate for the particular class of software being developed.

Coding agent tools can help with most of this, but there is still a substantial burden on the developer driving those tools to ensure that the produced code is good code for the subset of good that's needed for the current project.

We need to build new habits

The challenge is to develop new personal and organizational habits that respond to the affordances and opportunities of agentic engineering.

These best practices are still being figured out across our industry. I'm still figuring them out myself.

For now I think the best we can do is to second guess ourselves: any time our instinct says "don't build that, it's not worth the time" fire off a prompt anyway, in an asynchronous agent session where the worst that can happen is you check ten minutes later and find that it wasn't worth the tokens.

联系我们 contact @ memedata.com