每日一句 · 技术圈趣话
“Premature optimization is the root of all evil.”
过早优化是万恶之源。
— Donald Knuth(高德纳)
背后的故事
这句话出自计算机科学家、《计算机程序设计艺术》作者高德纳(Donald Knuth)在1974年发表的论文《Structured Programming with go to Statements》中。他原文写道:“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” 意即我们应当忘记微小的效率提升,在97%的情况下,过早优化是万恶之源。技术圈流传甚广,因为它提醒程序员不要在没有充分分析和性能瓶颈证据的情况下,盲目地优化代码,这往往会导致代码复杂化、难以维护,甚至引入更多bug。这句话成为软件工程中的经典原则,告诫开发者先写清晰正确的代码,再考虑优化。
小测
1. What does Donald Knuth mean by 'premature optimization is the root of all evil'?
2. In which paper did Donald Knuth first use this phrase?