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

今天瀏覽互聯(lián)網(wǎng),無意看到下面的文章,大家看后可以點(diǎn)評。以下是譯文與原文。

用十年學(xué)習(xí)編程
為什么每個人都急不可耐?

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

學(xué)會:在3天時間里,你不夠時間寫一些有意義的程序,并從它們的失敗與成功中學(xué)習(xí)。你不夠時間跟一些有經(jīng)驗(yàn)的程序員一起工作,你不會知道在那樣的環(huán)境中是什么滋味。簡而言之,沒有足夠的時間讓你學(xué)到很多東西。所以這些書談?wù)摰闹皇潜砻嫔系木ǎ巧钊氲睦斫狻H鏏lexander Pope(英國詩人、作家,1688-1744)所言,一知半解是危險的(a little learning is a dangerous thing)

Pascal:在3天時間里你可以學(xué)會Pascal的語法(如果你已經(jīng)會一門類似的語言),但你無法學(xué)到多少如何運(yùn)用這些語法。簡而言之,如果你是,比如說一個Basic程序員,你可以學(xué)會用Pascal語法寫出Basic風(fēng)格的程序,但你學(xué)不到Pascal真正的優(yōu)點(diǎn)(和缺點(diǎn))。那關(guān)鍵在哪里?Alan Perlis(ACM第一任主席,圖靈獎得主,1922-1990)曾經(jīng)說過:“如果一門語言不能影響你對編程的想法,那它就不值得去學(xué)”。另一種觀點(diǎn)是,有時候你不得不學(xué)一點(diǎn)Pascal(更可能是Visual Basic和javascript之類)的皮毛,因?yàn)槟阈枰佑|現(xiàn)有的工具,用來完成特定的任務(wù)。但此時你不是在學(xué)習(xí)如何編程,你是在學(xué)習(xí)如何完成任務(wù)。

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

10年編程無師自通

一些研究者(Hayes、Bloom)的研究表明,在許多領(lǐng)域,都需要大約10 年時間才能培養(yǎng)出專業(yè)技能,包括國際象棋、作曲、繪畫、鋼琴、游泳、網(wǎng)球,以及神經(jīng)心理學(xué)和拓?fù)鋵W(xué)的研究。似乎并不存在真正的捷徑:即使是莫扎特,他4 歲就顯露出音樂天才,在他寫出世界級的音樂之前仍然用了超過13年時間。再看另一種音樂類型的披頭士,他們似乎是在1964年的Ed Sullivan節(jié)目中突然冒頭的。但其實(shí)他們從1957年就開始表演了,即使他們很早就顯示出了巨大的吸引力,他們第一次真正的成功——Sgt. Peppers——也要到1967年才發(fā)行。Samuel Johnson(英國詩人)認(rèn)為10 年還是不夠的:“任何領(lǐng)域的卓越成就都只能通過一生的努力來獲得;稍低一點(diǎn)的代價也換不來。”(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.)
下面是我在編程這個行當(dāng)里獲得成功的處方:


對編程感興趣,因?yàn)闃啡ざゾ幊獭4_定始終都能保持足夠的樂趣,以致你能夠?qū)?0年時間投入其中。

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

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

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

跟別的程序員一起完成項(xiàng)目。在一些項(xiàng)目中成為最好的程序員;在其他一些項(xiàng)目中當(dāng)最差的一個。當(dāng)你是最好的程序員時,你要測試自己領(lǐng)導(dǎo)項(xiàng)目的能力,并通過你的洞見鼓舞其他人。當(dāng)你是最差的時候,你學(xué)習(xí)高手們在做些什么,以及他們不喜歡做什么(因?yàn)樗麄冏屇銕退麄冏瞿切┦拢?BR>
接手別的程序員完成項(xiàng)目。用心理解別人編寫的程序。看看在沒有最初的程序員在場的時候理解和修改程序需要些什么。想一想怎樣設(shè)計(jì)你的程序才能讓別人接手維護(hù)你的程序時更容易一些。

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

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

嘗試參與到一項(xiàng)語言標(biāo)準(zhǔn)化工作中。可以是ANSI C++委員會,也可以是決定自己團(tuán)隊(duì)的編碼風(fēng)格到底采用2個空格的縮進(jìn)還是4個。不論是哪一種,你都可以學(xué)到在這門語言中到底人們喜歡些什么,他們有多喜歡,甚至有可能稍微了解為什么他們會有這樣的感覺。

擁有盡快從語言標(biāo)準(zhǔn)化工作中抽身的良好判斷力。


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



盡早系統(tǒng)地識別出最好的設(shè)計(jì)者群體。

指派一個事業(yè)上的導(dǎo)師負(fù)責(zé)有潛質(zhì)的對象的發(fā)展,小心地幫他保持職業(yè)生涯的履歷。

讓成長中的設(shè)計(jì)師們有機(jī)會互相影響,互相激勵。


這實(shí)際上是假定了有些人本身就具有成為杰出設(shè)計(jì)師的必要潛質(zhì);要做的只是引導(dǎo)他們前進(jìn)。Alan Perlis說得更簡潔:“每個人都可以被教授如何雕塑;而對米開朗基羅來說,能教給他的倒是怎樣能夠不去雕塑。杰出的程序員也一樣”。
所以盡管去買那些Java書;你很可能會從中找到些用處。但你的生活,或者你作為程序員的真正的專業(yè)技術(shù),并不會因此在24小時、24天甚至24個月內(nèi)發(fā)生真正的變化。
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/