在啃枯燥的,尤其是大部头,或虽然不是大部头,但内容比较深刻的 technical books 的时候,如果偶遇令人莞尔之处,不禁欣欣然,为作者举手加额。
这本薄薄的小册子《Code Simplicity》,开篇第一段就不同凡响:
The difference between a bad programmer and a good programmer is understanding. That is, bad programmers don't understand what they are doing, and good programmers do. Believe it or not, it really is that simple.
短短一段话,蕴含了很多内容:bad programmer, good programmer, understanding, and the most important, simple. simple 这个字,在这里用得非常到位,一语双关,既说明了道理就这么简单,又暗指书名中的 simplicity。
全书都是围绕 simple 和 simplicity 来展开论述的。为什么要强调 simple (simplicity)?是因为复杂的系统容易出错!使系统更为 robust 的方法就是降低系统的复杂度,使系统简化,代码简单。道理就这么简单(it really is that simple)。
除了这种大手笔之外,作者在行文中,偶尔还幽默一下,给枯燥的技术行文涂上一层情感色彩,让人忍俊不禁。
在第七章讲一致性的时候,为了使读者更深刻地理解一致性(consistency)这个概念,在反复说明程序中保持一致性如何重要之后,笔锋一转:
There are somple examples of consistency in the real world. In much of Asia, people use chopsticks to eat. In the Americas and Europe, peoiple use forks. Okay, that's two different methods of eating, but overall it's pretty consistent, in any given area. Now imagine if every time you went to somebody's house, you had to learn some whole new way of eating. Maybe at Bob's house they eat with scissors, and at Mary's house they eat with flat pieces of cardboard. Eating would get pretty complex, wouldn't it?
it's the same in programming -- without consistency, things get very complex.
看到这里,再顽固的(stubborn)程序员也会为自己的死硬而羞愧!这就是幽默的力量!