前幾天,系里排課,有教師講“語言課(C++、JAVA等)隨便找個老師就能上”。我啞然,如果計算機專業的老師都這樣,我不知,會教出什么樣的學生來。

今天瀏覽互聯網,無意看到下面的文章,大家看后可以點評。以下是譯文與原文。

用十年學習編程
為什么每個人都急不可耐?

走進任何一家書店,你會看見《Teach Yourself Java in 7 Days》(7天Java無師自通)的旁邊是一長排看不到盡頭的類似書籍,它們要教會你Visual Basic、Windows、Internet等等,而只需要幾天甚至幾小時。我在Amazon.com上進行了如下搜索:
    pubdate: after 1992 and title: days and (title: learn or title: teach yourself)
    (出版日期:1992年后 and 書名:天 and (書名:學會 or 書名:無師自通))
我一共得到了248個搜索結果。前面的78個是計算機書籍(第79個是《Learn Bengali in 30 days》,30天學會孟加拉語)。我把關鍵詞“days”換成“hours”,得到了非常相似的結果:這次有253本書,頭77本是計算機書籍,第78本是《Teach Yourself Grammar and Style in 24 Hours》(24小時學會文法和文體)。頭200本書中,有96%是計算機書籍。
結論是,要么是人們非常急于學會計算機,要么就是不知道為什么計算機驚人地簡單,比任何東西都容易學會。沒有一本書是要在幾天里教會人們欣賞貝多芬或者量子物理學,甚至怎樣給狗打扮。
讓我們來分析一下像《Learn Pascal in Three Days》(3天學會Pascal)這樣的題目到底是什么意思:

學會:在3天時間里,你不夠時間寫一些有意義的程序,并從它們的失敗與成功中學習。你不夠時間跟一些有經驗的程序員一起工作,你不會知道在那樣的環境中是什么滋味。簡而言之,沒有足夠的時間讓你學到很多東西。所以這些書談論的只是表面上的精通,而非深入的理解。如Alexander Pope(英國詩人、作家,1688-1744)所言,一知半解是危險的(a little learning is a dangerous thing)

Pascal:在3天時間里你可以學會Pascal的語法(如果你已經會一門類似的語言),但你無法學到多少如何運用這些語法。簡而言之,如果你是,比如說一個Basic程序員,你可以學會用Pascal語法寫出Basic風格的程序,但你學不到Pascal真正的優點(和缺點)。那關鍵在哪里?Alan Perlis(ACM第一任主席,圖靈獎得主,1922-1990)曾經說過:“如果一門語言不能影響你對編程的想法,那它就不值得去學”。另一種觀點是,有時候你不得不學一點Pascal(更可能是Visual Basic和javascript之類)的皮毛,因為你需要接觸現有的工具,用來完成特定的任務。但此時你不是在學習如何編程,你是在學習如何完成任務。

3天:不幸的是,這是不夠的,正如下一節所言。

10年編程無師自通

一些研究者(Hayes、Bloom)的研究表明,在許多領域,都需要大約10 年時間才能培養出專業技能,包括國際象棋、作曲、繪畫、鋼琴、游泳、網球,以及神經心理學和拓撲學的研究。似乎并不存在真正的捷徑:即使是莫扎特,他4 歲就顯露出音樂天才,在他寫出世界級的音樂之前仍然用了超過13年時間。再看另一種音樂類型的披頭士,他們似乎是在1964年的Ed Sullivan節目中突然冒頭的。但其實他們從1957年就開始表演了,即使他們很早就顯示出了巨大的吸引力,他們第一次真正的成功——Sgt. Peppers——也要到1967年才發行。Samuel Johnson(英國詩人)認為10 年還是不夠的:“任何領域的卓越成就都只能通過一生的努力來獲得;稍低一點的代價也換不來。”(Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price.) 喬叟(Chaucer,英國詩人,1340-1400)也抱怨說:“生命如此短暫,掌握技藝卻要如此長久。”(the lyf so short, the craft so long to lerne.)
下面是我在編程這個行當里獲得成功的處方:


對編程感興趣,因為樂趣而去編程。確定始終都能保持足夠的樂趣,以致你能夠將10年時間投入其中。

跟其他程序員交談;閱讀其他程序。這比任何書籍或訓練課程都更重要。

編程。最好的學習是從實踐中學習。用更加技術性的語言來講,“個體在特定領域最高水平的表現不是作為長期的經驗的結果而自動獲得的,但即使是非常富有經驗的個體也可以通過刻意的努力而提高其表現水平。”(p. 366),而且“最有效的學習要求為特定個體制定適當難度的任務,有意義的反饋,以及重復及改正錯誤的機會?!保╬. 20-21)《Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life》(在實踐中認知:心智、數學和日常生活的文化)是關于這個觀點的一本有趣的參考書。

如果你愿意,在大學里花上4年時間(或者再花幾年讀研究生)。這能讓你獲得一些工作的入門資格,還能讓你對此領域有更深入的理解,但如果你不喜歡進學校,(作出一點犧牲)你在工作中也同樣能獲得類似的經驗。在任何情況下,單從書本上學習都是不夠的?!坝嬎銠C科學的教育不會讓任何人成為內行的程序員,正如研究畫筆和顏料不會讓任何人成為內行的畫家”, Eric Raymond,《The New Hacker's Dictionary》(新黑客字典)的作者如是說。我曾經雇用過的最優秀的程序員之一僅有高中學歷;但他創造出了許多偉大的軟件,甚至有討論他本人的新聞組,而且股票期權讓他達到我無法企及的富有程度(譯注:指Jamie Zawinski,Xemacs和Netscape的作者)。

跟別的程序員一起完成項目。在一些項目中成為最好的程序員;在其他一些項目中當最差的一個。當你是最好的程序員時,你要測試自己領導項目的能力,并通過你的洞見鼓舞其他人。當你是最差的時候,你學習高手們在做些什么,以及他們不喜歡做什么(因為他們讓你幫他們做那些事)。

接手別的程序員完成項目。用心理解別人編寫的程序??纯丛跊]有最初的程序員在場的時候理解和修改程序需要些什么。想一想怎樣設計你的程序才能讓別人接手維護你的程序時更容易一些。

學會至少半打編程語言。包括一門支持類抽象(class abstraction)的語言(如Java或C++),一門支持函數抽象(functional abstraction)的語言(如Lisp或ML),一門支持句法抽象(syntactic abstraction)的語言(如Lisp),一門支持說明性規約(declarative specification)的語言(如Prolog或C++模版),一門支持協程(coroutine)的語言(如Icon或Scheme),以及一門支持并行處理(parallelism)的語言(如Sisal)。

記住在“計算機科學”這個詞組里包含“計算機”這個詞。了解你的計算機執行一條指令要多長時間,從內存中取一個word要多長時間(包括緩存命中和未命中的情況),從磁盤上讀取連續的數據要多長時間,定位到磁盤上的新位置又要多長時間。(答案在這里。)

嘗試參與到一項語言標準化工作中??梢允茿NSI C++委員會,也可以是決定自己團隊的編碼風格到底采用2個空格的縮進還是4個。不論是哪一種,你都可以學到在這門語言中到底人們喜歡些什么,他們有多喜歡,甚至有可能稍微了解為什么他們會有這樣的感覺。

擁有盡快從語言標準化工作中抽身的良好判斷力。


抱著這些想法,我很懷疑從書上到底能學到多少東西。在我第一個孩子出生前,我讀完了所有“怎樣……”的書,卻仍然感到自己是個茫無頭緒的新手。30個月后,我第二個孩子出生的時候,我重新拿起那些書來復習了嗎?不。相反,我依靠我自己的經驗,結果比專家寫的幾千頁東西更有用更靠得住。
Fred Brooks在他的短文《No Silver Bullets》(沒有銀彈)中確立了如何發現杰出的軟件設計者的三步規劃:



盡早系統地識別出最好的設計者群體。

指派一個事業上的導師負責有潛質的對象的發展,小心地幫他保持職業生涯的履歷。

讓成長中的設計師們有機會互相影響,互相激勵。


這實際上是假定了有些人本身就具有成為杰出設計師的必要潛質;要做的只是引導他們前進。Alan Perlis說得更簡潔:“每個人都可以被教授如何雕塑;而對米開朗基羅來說,能教給他的倒是怎樣能夠不去雕塑。杰出的程序員也一樣”。
所以盡管去買那些Java書;你很可能會從中找到些用處。但你的生活,或者你作為程序員的真正的專業技術,并不會因此在24小時、24天甚至24個月內發生真正的變化。
Teach Yourself Programming in Ten Years
Why is everyone in such a rush?
Walk into any bookstore, and you'll see how to Teach Yourself Java in 7 Days alongside endless variations offering to teach Visual Basic, Windows, the Internet, and so on in a few days or hours. I did the following power search at Amazon.com:
pubdate: after 1992 and title: days and
(title: learn or title: teach yourself)
and got back 248 hits. The first 78 were computer books (number 79 was Learn Bengali in 30 days). I replaced "days" with "hours" and got remarkably similar results: 253 more books, with 77 computer books followed by Teach Yourself Grammar and Style in 24 Hours at number 78. Out of the top 200 total, 96% were computer books.
The conclusion is that either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days.

Let's analyze what a title like Learn Pascal in Three Days could mean:

Learn: In 3 days you won't have time to write several significant programs, and learn from your successes and failures with them. You won't have time to work with an experienced programmer and understand what it is like to live in that environment. In short, you won't have time to learn much. So they can only be talking about a superficial familiarity, not a deep understanding. As Alexander Pope said, a little learning is a dangerous thing.

Pascal: In 3 days you might be able to learn the syntax of Pascal (if you already knew a similar language), but you couldn't learn much about how to use the syntax. In short, if you were, say, a Basic programmer, you could learn to write programs in the style of Basic using Pascal syntax, but you couldn't learn what Pascal is actually good (and bad) for. So what's the point? Alan Perlis once said: "A language that doesn't affect the way you think about programming, is not worth knowing". One possible point is that you have to learn a tiny bit of Pascal (or more likely, something like Visual Basic or javascript) because you need to interface with an existing tool to accomplish a specific task. But then you're not learning how to program; you're learning to accomplish that task.

in Three Days: Unfortunately, this is not enough, as the next section shows.
Teach Yourself Programming in Ten Years
Researchers (Hayes, Bloom) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. There appear to be no real shortcuts: even Mozart, who was a musical prodigy at age 4, took 13 more years before he began to produce world-class music. In another genre, the Beatles seemed to burst onto the scene, appearing on the Ed Sullivan show in 1964. But they had been playing since 1957, and while they had mass appeal early on, their first great critical success, Sgt. Peppers, was released in 1967. Samuel Johnson thought it took longer than ten years: "Excellence in any department can be attained only by the labor of a lifetime; it is not to be purchased at a lesser price." And Chaucer complained "the lyf so short, the craft so long to lerne."
Here's my recipe for programming success:

Get interested in programming, and do some because it is fun. Make sure that it keeps being enough fun so that you will be willing to put in ten years.

Talk to other programmers; read other programs. This is more important than any book or training course.

Program. The best kind of learning is learning by doing. To put it more technically, "the maximal level of performance for individuals in a given domain is not attained automatically as a function of extended experience, but the level of performance can be increased even by highly experienced individuals as a result of deliberate efforts to improve." (p. 366) and "the most effective learning requires a well-defined task with an appropriate difficulty level for the particular individual, informative feedback, and opportunities for repetition and corrections of errors." (p. 20-21) The book Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life is an interesting reference for this viewpoint.

If you want, put in four years at a college (or more at a graduate school). This will give you access to some jobs that require credentials, and it will give you a deeper understanding of the field, but if you don't enjoy school, you can (with some dedication) get similar experience on the job. In any case, book learning alone won't be enough. "Computer science education cannot make anybody an expert programmer any more than studying brushes and pigment can make somebody an expert painter" says Eric Raymond, author of The New Hacker's Dictionary. One of the best programmers I ever hired had only a High School degree; he's produced a lot of great software, has his own news group, and through stock options is no doubt much richer than I'll ever be.

Work on projects with other programmers. Be the best programmer on some projects; be the worst on some others. When you're the best, you get to test your abilities to lead a project, and to inspire others with your vision. When you're the worst, you learn what the masters do, and you learn what they don't like to do (because they make you do it for them).

Work on projects after other programmers. Be involved in understanding a program written by someone else. See what it takes to understand and fix it when the original programmers are not around. Think about how to design your programs to make it easier for those who will maintain it after you.

Learn at least a half dozen programming languages. Include one language that supports class abstractions (like Java or C++), one that supports functional abstraction (like Lisp or ML), one that supports syntactic abstraction (like Lisp), one that supports declarative specifications (like Prolog or C++ templates), one that supports coroutines (like Icon or Scheme), and one that supports parallelism (like Sisal).

Remember that there is a "computer" in "computer science". Know how long it takes your computer to execute an instruction, fetch a word from memory (with and without a cache miss), read consecutive words from disk, and seek to a new location on disk. (Answers here.)

Get involved in a language standardization effort. It could be the ANSI C++ committee, or it could be deciding if your local coding style will have 2 or 4 space indentation levels. Either way, you learn about what other people like in a language, how deeply they feel so, and perhaps even a little about why they feel so.

Have the good sense to get off the language standardization effort as quickly as possible.
With all that in mind, its questionable how far you can get just by book learning. Before my first child was born, I read all the How To books, and still felt like a clueless novice. 30 Months later, when my second child was due, did I go back to the books for a refresher? No. Instead, I relied on my personal experience, which turned out to be far more useful and reassuring to me than the thousands of pages written by experts.
Fred Brooks, in his essay No Silver Bullets identified a three-part plan for finding great software designers:

Systematically identify top designers as early as possible.

Assign a career mentor to be responsible for the development of the prospect and carefully keep a career file.

Provide opportunities for growing designers to interact and stimulate each other.

This assumes that some people already have the qualities necessary for being a great designer; the job is to properly coax them along. Alan Perlis put it more succinctly: "Everyone can be taught to sculpt: Michelangelo would have had to be taught how not to. So it is with the great programmers".
So go ahead and buy that Java book; you'll probably get some use out of it. But you won't change your life, or your real overall expertise as a programmer in 24 hours, days, or even months.


References
Bloom, Benjamin (ed.) Developing Talent in Young People, Ballantine, 1985.

Brooks, Fred, No Silver Bullets, IEEE Computer, vol. 20, no. 4, 1987, p. 10-19.

Hayes, John R., Complete Problem Solver Lawrence Erlbaum, 1989.

Lave, Jean, Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life, Cambridge University Press, 1988.
http://www.norvig.com/