烂代码如葛藤
Bad code is kudzu

原始链接: https://vickiboykis.com/2026/09/01/bad-code-is-kudzu/

作者将软件功能比作葛藤——一种会大肆侵占生存环境的入侵植物。正如葛藤一样,一旦功能被添加到代码库中,它就会变得“粘滞”:团队会在其基础上构建各种依赖,导致后续想要移除它变得愈发困难且吃力不讨好。 在如今人工智能辅助开发的时代,生成代码变得比以往任何时候都更容易,“代码库葛藤”的风险已达到临界点。如果不进行有意的精简,项目中就会堆积大量未被使用且复杂的功能,从而阻碍维护工作。 作者认为,开发者必须转变思维模式:将添加功能视为一种临时实验,而非永久性的固定配置。通过监测实际使用情况(正如作者追踪“标签气泡”功能的失败案例一样),开发者应主动删除那些无法提供明确价值的功能。归根结底,删除代码的能力与编写代码的能力同样重要;如果你能轻易添加一项功能,也必须准备好同样迅速地将其剔除,以保持代码库的健康。

这篇 Hacker News 帖子讨论了文章《糟糕的代码如同葛藤》(Bad Code Is Kudzu),以这种入侵性藤蔓植物比喻难以驾驭的软件。 评论者强调了该植物的历史与技术债务之间的相似之处。虽然葛藤最初是作为防治水土流失的手段被引入的,但用户指出,它也曾因美观原因被种植,且有关其蔓延的各种历史数据很可能是因粗糙的航空测算方法而被夸大了。 在编程语境下,参与者将其与项目的“重置按钮”进行了对比。一位用户指出,虽然他以前总是等到技术债务带来的痛苦变得无法忍受时才进行重构,但在大语言模型(LLM)的辅助下,清理“糟糕代码”变得容易多了。最终,该讨论将入侵物种和混乱的代码库都定性为需要主动管理的、持续蔓延的问题。
相关文章

原文
Cultivation of the Vines, Henri Martin

Cultivation of the Vines, Henri Martin

Kudzu is a plant that was once introduced from East Asia to the eastern United States as a way to combat soil erosion.

But, kudzu, once introduced, grows aggressively and can overtake sidewalks, houses, foundations, and even trees.

The only way to kill kudzu is to prune it aggressively, as a concentrated strategy enacted together by all the people who live near where the kudzu grows.

You know where I’m going with this. An app feature, once added to a codebase, can be extremely hard to remove.

Even simple features become very sticky because not only do you have to remove the code, but what’s worse is that people start writing code on top of your code, and before you know it, you are two years deep into an implemented feature no one wants.

Deleting code is hard, particularly because it’s a thankless task that usually doesn’t go on promo packets, which is why we end up shipping hundreds of thousands of lines of sparkle emoji magic wand AI features, but deleting code is silent.

But in this new era, we must delete code even harder, because if we don’t constantly remove complexity, we are going to drown in generated kudzu slop that overtakes codebases.

In the era where it’s easy to add stuff, leave yourself a plan to remove the features you added, particularly since it’s much easier than before, too.

For example, in May, I added a feature to add hashtag bubbles to my blog. I’m a millennial, social hashtags are my love language. I thought I would use them all the time, I thought my site visitors would use them all the time to beautifully navigate my sage writings. I used a combination of elegant machine learning techniques.

I left it alone for a few months to see if users actually used it in production, and the answer was a resounding no.

In my Plausible analytics, they didn’t make the top 30 visited pages for the past 3 months.

It’s possible a few folks got something out of them, but it’s not worth maintaining, especially when it’s so easy to put them back in. (This data is since May 1.)

So, it’s time to prune the kudzu, in much the same way it was so easy to create.

 Commit history for this feature is now:                                                             
 - 77e2c5a — Changelog entry                                                    
 - 85000e2 — Move search bar back to the header                                               
 - 91b6fde — Remove tag sidebar and tag bubbles  

💆‍♀️

联系我们 contact @ memedata.com