原文链接:The 10:1 rule of writing and programming

作者对自己写的两本书和一些开源项目的代码库进行了数据统计,发现编码和写作类似,「原料」和「成品」的比例在 10:1 左右。

根据读者的反馈,这个法则同样适用于电影、新闻、音乐和摄影行业。

作者进而提出问题:

**注:**Code churn 指软件开发过程中添加、修改、删除的代码数量,是一个用于衡量代码演化的指标。此处保留原文不翻译。

以下为摘录:


Hofstadter’s Law: It always takes longer than you expect, even when you take into account Hofstadter’s Law.

Hofstadter 法则:花费的时间总是比你估计的要长,即使你考虑了本法则。

— Douglas Hofstadter, Gödel, Escher, Bach (《哥德尔、埃舍尔、巴赫》)

Writing prose and writing code have a lot in common, but perhaps the biggest similarity is that neither writers nor programmers can get things done on time. Writers are notorious for missing deadlines. Programmers are notorious for being wildly off with estimates. The question is, why?

写文章和写代码有很多共同点,但也许最大的相似之处就是作家和程序员都不能按时完事。作家错过最后期限众人皆知,程序员也因为罔顾估算而臭名昭著。问题是,为什么?

……

The 10:1 rule of writing and programming

Give that my data set is limited, I can only draw a few preliminary conclusions:

根据我有限的数据,我只能得出一些初步结论:

  1. The ratio of “raw materials” to “finished product” in a book is roughly 10:1. Keep this in mind the next time an editor asks you for a timeline! If you want to write a 300 page book, you’ll probably have to write around 3,000 pages.

    一本书里「原材料」和「完成品」的比例大概是十比一。如果你想写一本 300 页的书,你可能需要写约 3,000 页的内容,下次编辑问你要一个期限时记得这一点。

  2. Similarly, the ratio of “code churn” to “lines of code” in mature and non-trivial software is also at least 10:1. Keep this in mind the next time a manager or customer asks you for a time estimate! To build a 10,000 line app, expect to write roughly 100,000 lines.

    相似的,成熟且有价值的软件里「code churn」和「代码行数」的比例也至少是十比一。开发一个 10,000 行代码的 app,得准备写大概 100,000 行代码,下次经理或客户问你工时估算时记住这一点。

These can be summarized as what I shall dub the 10:1 rule of writing and programming:

这些能被总结为我命名的「写作和编程十比一法则」

Good software and good writing requires that every line has been rewritten, on average, at least 10 times.

好的软件和好的文章,每一行都需要被重写平均至少十遍。