一本书和阅读代码

来源:互联网 发布:简单课堂听课软件 编辑:程序博客网 时间:2024/04/29 09:18
很难想象钢琴家不用聆听大师的作品;诗人不用揣摩传世的经典;画家不用体会前辈的佳作;拳手不用参详高人的示范。那我们怎么能想象程序员不用仔细学习性感的代码?可惜的是,美妙的代码往往有如像Shrek,乍一看也就是面目丑陋的庞然大物。没有Fionna的聪慧,我们也难欣赏Shrek洋葱一般层次丰富的心灵。再说,代码一旦写成,我们看到的也就是一段神来之笔。再难体会到作者在难题前内心有如困兽般地冲撞,面临多种选择时精神的激荡。我们也再难追溯每个数据结构背后的理念,每段算法成型过程中每一步的由来(顺便说一句。这也是为什么Knuth的书引人入胜的原因。每段算法怎么从无到有,自粗而细,由慢转快,通通脉络清晰)。就算是理解代码本身,想来每人的体会也有深有浅。不知道多少老大因为这些困难没能体会到阅读代码时心头肿胀(乱用冯唐语)的快感?除非,除非有高手引领我们入门,给我们细述经典代码如何玲珑浮屠,如何眼波婉转。

IBMGrady Booch也强力推荐程序员大量阅读代码,认为这是从新手到高手的必要手段。如果喜欢软件开发老大还没有订阅Grady Booch的博客的话,现在是时候了。G老大的私人项目Architecture Handbook想必更是每位对软件架构有兴趣的老大的必读材料吧?他在这本公开的手册将归类整理历史上各式架构。虽然这些工作开始还不到四年,但上面已经有不少高质量的资料。比如以前提到过的Eclipse架构考古。也许用G老大自己的话最能雄辩地道出软件考古的意义:经典科学通过在定量观察和理论构建间曼舞取得进展。前者细致而刻意,后者富于创新且能经受检验。计算机科学充满了经验的观察和理论的构造,但软件世界里,我们往往把所有时间用于搭建实物,却疏于科学研究。我们有自己关于流程和工具的理论,但它们大部分都基于坊间传闻和个人经验,而不是基于反映了可靠经验研究的确凿且中立的数据(classical science advances via the dance between quantitative observation and theoretical construction." The former is deliberate and intentional; the latter is creative and testable. Computer science is full of empirical observation and the construction of theories, but in the world of software we often spend all of time building artifacts and not enough time doing science. We have our share of theories, about process and tools, but much of that work is based on anecdote and personal experience, not the hard, dispassionate data that reflects good empirical work
 
 
G老大的架构手册有一栏read list,目前推荐的两个条目都是代码阅读。一是C++STL设计源代码)。二是qmail设计源代码)。今年的SIGCSE年会上,G老大做了主题演讲。不,我没去。我也是看别人的博客写的,现在就等Podcast出来了。里面提到计算机系不仅要交给学生知识,也要让学生领会“激情,美丽,快乐,和敬畏”,真是深得我心啊。在演讲里,G老大频繁用“正确和高尚”来描述计算机业界众人的努力,说从事软硬件研发的工作既是特权也是义务。它是特权,因为我们从根本上多方面深刻地改变这个世界。基于同样的原因,这也是我们的义务。我们应当牢记这点,并让我们的学生同样明白。不知道G老大和蜘蛛人有什么瓜葛。

 
又跑题了。还是说回来。


大家都熟悉的Code Reading: The Open Source Perspective是本不错的入门书。不过作者着眼于零散的代码,注重局部细节的实现(比如第三章第四章),很少分析一段完整程序:这段程序的动机是什么?解决了什么好玩儿的问题?哪些地方体现了作者的天才?代码的设计理念是什么?面临选择,怎么做出取舍。。。

令人欣慰的是,人见人耐的老牌geek,资深出版人,Tim O’Reilly终于按耐不住出手了。今年6月,O’Reilly将推出新书Beautiful Code: Leading Programmers Explain How They Think。瞧这书名取的,多诱人啊。“Explain How They Think”,啧啧,这不引诱俺体验一下当Craig Schwartz的经验么?

 
再看看目录,禁不住口水滴滴答答地流哈。Enough showed. Pre-ordered.
  1. Greg Wilson: Foreword
  2. Brian Kernighan: Beautiful Brevity: Rob Pike’s Regular Expression Matcher
  3. Karl Fogel: Subversion’s Delta Editor: Interface as Ontology
  4. Jon Bentley: The Most Beautiful Code I Never Wrote
  5. Tim Bray: Finding Things
  6. Elliotte Rusty Harold: Correct, Beautiful, Fast (In That Order): Lessons From Designing XML Validators
  7. Michael Feathers: The Framework for Integrated Test: Beauty through Fragility
  8. Alberto Savoia: Beautiful Tests
  9. Charles Petzold: On-the-Fly Code Generation for Image Processing
  10. Douglas Crockford: Top Down Operator Precedence
  11. Henry Warren: Accelerating Population Count
  12. Ashish Gulhati: Secure Communication: The Technology of Freedom
  13. Lincoln Stein: Growing Beautiful Code in BioPerl
  14. Jim Kent: The Design of the Gene Sorter
  15. Jack Dongarra and Piotr Luszczek: How Elegant Code Evolves With Hardware: The Case Of Gaussian Elimination
  16. Adam Kolawa: Beautiful Numerics
  17. Greg Kroah-Hartman: The Linux Kernel Driver Model
  18. Diomidis Spinellis: Another Level of Indirection
  19. Andrew Kuchling: An Examination of Python’s Dictionary Implementation
  20. Travis Oliphant: Multi-Dimensional Iterators in NumPy
  21. Ronald Mak: A Highly Reliable Enterprise System for NASA’s Mars Rover Mission
  22. Rogerio Atem de Carvalho and Rafael Monnerat: ERP5: Designing for Maximum Adaptability
  23. Bryan Cantrill: A Spoonful of Sewage
  24. Jeff Dean and Sanjay Ghemawat: Distributed Programming with MapReduce
  25. Simon Peyton Jones: Beautiful Concurrency
  26. Kent Dybvig: Syntactic Abstraction: The syntax-case expander
  27. William Otte and Doug Schmidt: Object-Oriented Patterns and a Framework for Networked Software
  28. Andrew Patzer: Integrating Business Partners the RESTful Way
  29. Andreas Zeller: Beautiful Debugging
  30. Yukihiro Matsumoto: Code That’s Like an Essay
  31. Arun Mehta: Designing Interfaces Under Extreme Constraints: the Stephen Hawking Editor
  32. TV Raman: Emacspeak: The Complete Audio Desktop
  33. Christopher Seiwald and Laura Wingerd: Code in Motion
  34. Brian Hayes: Writing Programs for “The Book”
  35. Andy Oram: Afterword
原创粉丝点击