从切斯特顿之围栏到切斯特顿之鸿沟
From Chesterton's fence to Chesterton's gap

原始链接: https://stephantul.github.io/blog/unfence/

G.K. 切斯特顿提出的原则——“切斯特顿栅栏”——建议在拆除看似无用的结构之前,必须先弄清当初为何建造它。在软件工程中,这是一条至关重要的准则:开发人员如果冲动地重构自己不理解的代码,往往会导致生产环境崩溃,事后才发现原有的设计其实承载着某种隐藏且必要的用途。 作者提出了一个现代推论:“切斯特顿间隙”。如果说“栅栏”是警告人们不要鲁莽拆除,那么“间隙”则是针对那种不必要建设的冲动。在开源世界里,代码的产出成本很低,开发人员经常会贡献出许多维护者从未要求过的大型且精良的功能。即使这些新增内容在技术上是合理的,它们也会带来不必要的维护负担并导致臃肿。 归根结底,这两个概念都提倡谦逊与沟通。无论是决定拆除旧系统还是构建新系统,开发人员都应优先理解原作者的意图。不要想当然地认为自己的方案一定更优,而应“先问再做”。通过尊重现有的环境背景,程序员能够促进更好的协作,并避免因解决不存在的问题而造成的浪费。

这篇 Hacker News 的讨论探讨了开源贡献带来的负担,对比了“切斯特顿栅栏”(Chesterton’s Fence)这一哲学概念——即在未理解某机制的作用前不应将其移除——与现代软件维护的现实情况。 参与者认为,合并请求(PR)并非零成本的“栅栏”或改进,而更像是 SQLite 作者 Richard Hipp 所说的“免费的幼犬”(free puppies)。正如领养幼犬一样,接受一个 PR 意味着维护者必须承担长期的文档、测试和维护工作。 讨论强调了维护者与贡献者之间日益紧张的关系。一些观点指出,人工智能生成的“打酱油式”PR 加剧了这一问题,因为这些贡献往往缺乏背景,也无意进行长期维护。尽管有人认为清晰的文档有助于识别必要的变更,但共识依然是:每一项贡献——无论是新功能还是代码重构——都会给维护者的时间和精力带来实质性的成本。归根结底,这一讨论提醒我们,软件是一项活生生的责任,而不仅仅是代码的集合。
相关文章

原文

The English Writer and Christian apologist G. K. Chesterton is, perhaps, most well known to programmers through a paragraph in which he introduces what is now known as “Chesterton’s fence”. It’s a very simple idea: You walk through a field and see a fence which, seemingly, has no purpose. Instead of tearing it down because it seemingly has no use, try to understand or ask why somebody put it there. () That’s it!

Paraphrasing: if you think somebody built something bad or in a bad way, try to understand why they did it that way before undoing their work. Being burned while ignoring Chesterton’s fence is a rite of passage for every programmer: you see a piece of code and think “who the hell wrote this”. Then, when rewriting it, you break production, and realize that there was a good reason somebody did the things they did. They weren’t stupid after all. Or, you rewrite it and it’s actually better, and you now know more about the person who wrote it, and maybe can teach them how to build better together.

Chesterton’s fence urges us to slow down, and retrace the thinking steps of the person who built before you, thus putting you in their shoes. Keeping Chesterton’s fence in mind does not only make you a better engineer, but it also makes you empathize more with the people around you, the ones that came before you. It shows you the limits of your own knowledge, but simultaneously shows you what you can teach others around you.

So having said that, I think there’s an interesting new dynamic at play in software land, which I will call Chesterton’s gap. It’s like Chesterton’s fence, except that people walk through the field and ask themselves why somebody hasn’t built a fence there yet, and then, without asking, build a fence.

To me, this is what it feels like to build open source libraries. The cost of creating lines of code has dropped to ~0, which causes people () to submit 10k line PRs without even opening an issue first. The thing is, these PRs make sense. They are not bad! They’re just not necessary. They add features to projects that nobody asked for, add tools that are marginally useful, add configuration scaffolding for IDEs that barely anyone uses. () To return to the parable: the fences are well built, they are sturdy, they may even serve a purpose. But I don’t need a fence in that specific location, even if it is free. I just don’t need it, and I don’t want it.

I can also write lines of code for free. I have the same superpowers you do, so if I didn’t add some feature to a project I own, there’s probably a good reason I didn’t add that specific feature. If you’re wondering why I didn’t add it myself, just ask. Don’t build the fence.

联系我们 contact @ memedata.com