2026-09-16
每日一句 · 技术圈趣话
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
调试的难度是编写代码的两倍。因此,如果你尽可能地把代码写得“巧妙”,那么按定义,你就不够聪明去调试它。
— Brian Kernighan(出自《The Elements of Programming Style》,1974年)
背后的故事
这句话出自 Brian Kernighan 与 P.J. Plauger 合著的经典编程书籍《The Elements of Programming Style》。该书旨在教会程序员写出清晰、可维护的代码,深受早期 C 语言和 UNIX 社区推崇。这句话的核心在于告诫程序员:不要为了炫耀技巧而编写晦涩的“聪明”代码,因为后期调试会让你付出双倍代价。它强调代码的可读性和简单性优先,这一理念后来被无数技术领袖(如 Linus Torvalds、Robert C. Martin)反复倡导。在技术圈,这句话常被用来调侃那些喜欢玩“花活”的代码——比如一行写出复杂指针运算的 C 代码,或是用满屏高阶函数和递归的 JavaScript。它已成为衡量代码质量的金句之一。
小测
1. According to Brian Kernighan's quote, what is the main reason to avoid writing overly clever code?
2. Which of the following best captures the underlying philosophy of this quote?