潛心十年,修煉成編程高手

richardcao 於 2013-01-03 00:00 翻譯 |來源:金譯通網·譯文

Eeach Yourself Programming in Ten Years

潛心十年,修煉成編程高手

Peter Norvig

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.

瀏覽任何一家書店,人們都會發現諸如《花7天自學JAVA》這類書,以及無數的在幾天之內或者幾小時之內學會Visual BasicWindowInternet及其他課題的速成計算機教程。我在Amazon.com網站做了一次快速檢索,出版日期是:“1992年以後;主題詞是:幾天學會或者自學,結果得到了248項鍊接。前78項是計算機書籍,第79項是《39天學會孟加拉語》。如果把主題詞幾天換成幾小時,返回幾乎相同的結果:大約250多本書,其中有77本是計算機書籍,第78本是《24小時學會語法和文體》。在前200項檢索結果中,96%是計算機書籍。

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. Felleisen et al. give a nod to this trend in their book How to Design Programs, when they say "Bad programming is easy. Idiots can learn it in 21 days, even if they are dummies.

這個結果要麼說明人們學習計算機的心情多麼迫不及待,要麼說明沒有什麼東西比計算機更容易掌握的啦。沒有教人們在幾天之內學會貝多芬、量子物理或者飼養寵物狗的速成教材。Felleisen 等人的著作《如何編寫程序》中批判這種潮流,他們說編寫蹩腳的程序確實不難。白癡也可以在21天學會編寫這種程序,即便他是蠢材也不成問題。

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

讓我們看看所謂《3天學會C++編程》的教程都有些什麼內容:

  • 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 a C++ environment. In short, you won't have time to learn much. So the book can only be talking about a superficial familiarity, not a deep understanding. As Alexander Pope said, a little learning is a dangerous thing.

  • 學會:3天時間裏沒有機會寫出幾個有意義的程序,也沒有機會從失敗和成功中總結經驗和教訓。你不會有機會和熟練的程序員一起工作,不會理解C++編程環境的真正含義。簡言之,你根本沒學會什麼。所以這種教材只能誇誇其談膚淺的表層的東西,根本無法深入談C++的本質。如同 Alexander Pope 批評過的,淺嘗即止誇誇其談其實比不學無術更可怕。

  • C++: In 3 days you might be able to learn some of the syntax of C++ (if you already know another language), but you couldn't learn much about how to use the language. In short, if you were, say, a Basic programmer, you could learn to write programs in the style of Basic using C++ syntax, but you couldn't learn what C++ 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 C++ (or more likely, something like JavaScript or Flash's Flex) 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.

  • C++語言:要是你以前有編程基礎,在3天之內確實可以學些C++語法知識,但是還無法掌握C++ 全部語法,無法使用 C++ 編寫程序。簡單講,如果您曾經是 Basic程序員,您只能寫出貌似 Basic  C++ 程序,根本不知道 C++語言最擅長處理什麼問題,也不知道 C++ 語言最不擅長處理什麼問題,無法掌握 C++ 語言的編程思想。所以關鍵在哪裏?Alan Perlis曾經一語道破玄機:如果一門編程語言不能改變您的編程思想,那它就無足輕重。一種情況可能是您並不想學 C++ ,大多數情況下是諸如JavaScript 或者 Flash's Flex 的這類東西,只是爲了應付一時之需,爲實現一個現成工具的接口完成一個特定編程任務。但是這只是學會完成一項特定編程任務,離 C++ 編程思想相去甚遠。

  • in Three Days: Unfortunately, this is not enough, as the next section shows.

  • 3天之內:很不幸, 3 天時間根本不夠用,正如下文所述,所謂欲速則不達。

Teach Yourself Programming in Ten Years

花十年時間潛心修煉成編程高手

Researchers (Bloom (1985), Bryan & Harter (1899), Hayes (1989), Simmon & Chase (1973)) have shown it takes about ten years to develop expertise in any of a wide variety of areas, including chess playing, music composition, telegraph operation, painting, piano playing, swimming, tennis, and research in neuropsychology and topology. The key isdeliberative practice: not just doing it again and again, but challenging yourself with a task that is just beyond your current ability, trying it, analyzing your performance while and after doing it, and correcting any mistakes. Then repeat. And repeat again. 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 with a string of #1 hits and an appearance on the Ed Sullivan show in 1964. But they had been playing small clubs in Liverpool and Hamburg since 1957, and while they had mass appeal early on, their first great critical success, Sgt. Peppers, was released in 1967. Malcolm Gladwell reports that a study of students at the Berlin Academy of Music compared the top, middle, and bottom third of the class and asked them how much they had practiced:

歷史上有許多研究者,如Bloom (1985), Bryan & Harter (1899), Hayes (1989), Simmon & Chase (1973),他們已經證明在大多數領域培養一名專家級的高手通常要花10年時間:比如象棋手、作曲家、電報員、畫家、鋼琴手、游泳運動員、網球手、以及神經心理學和拓撲學研究者。關鍵是要先經過慎思而後再實踐:不是簡單的機械重複,而是要在通往更高水平的道路上不斷挑戰自己,要不斷嘗試,不管是嘗試過程中還是嘗試以後都要不斷分析得與失,不斷修正謬誤。然後再次重複,反覆實踐。這條路確實沒有捷徑可走,就算是4歲音樂神童Mozart,也要花10多年時間實踐才能最終創作出世界級的音樂作品。另外一個例子是,披頭士樂隊似乎是突然取得了一連串的第一名,並於 1964年在Ed Sullivan 的演出中一舉成名。其實早在1957年他們就在 Liverpool  Hamburg 的小型俱樂部開始不斷演出,而且就在早期大量演出之後,他們第一首偉大作品Sgt. Peppers1967年出版了。Malcolm Gladwell的報告說明了針對柏林音樂學院一流、二流和三流學生的學習過程的一項研究,比較了他們在音樂練習上所花的時間長短對音樂才能的影響。

Everyone, from all three groups, started playing at roughly the same time - around the age of five. In those first few years, everyone practised roughly the same amount - about two or three hours a week. But around the age of eight real differences started to emerge. The students who would end up as the best in their class began to practise more than everyone else: six hours a week by age nine, eight by age 12, 16 a week by age 14, and up and up, until by the age of 20 they were practising well over 30 hours a week. By the age of 20, the elite performers had all totalled 10,000 hours of practice over the course of their lives. The merely good students had totalled, by contrast, 8,000 hours, and the future music teachers just over 4,000 hours.

所有這三類學生在從 5 歲起的開始階段中所花的練習時間差不多相同。在這個階段,所有人差不多每週都花 2  3 小時練習音樂。但是在 8 歲的階段,練習音樂時間出現明顯差異。最終進入一流水平行列的學生比任何其他學生花的時間都多: 9 歲時每週 6 小時, 12 歲時每週 8 小時, 14 歲時每週 16小時,而且逐漸增多,到 20 歲時已經超過每週 30 小時。到 20 歲時,一流選手的練習時間量已經累積達到 10 000 小時。好學生的練習時間總量只達到 8 000 小時,未來的音樂教師練習量勉強超過 4 000 小時。

So it may be that 10,000 hours, not 10 years, is the magic number. (Henri Cartier-Bresson (1908-2004) said "Your first 10,000 photographs are your worst," but he shot more than one an hour.) Samuel Johnson (1709-1784) thought it took even longer: "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 (1340-1400) complained "the lyf so short, the craft so long to lerne." Hippocrates (c. 400BC) is known for the excerpt "ars longa, vita brevis", which is part of the longer quotation "Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile", which in English renders as "Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgment difficult." Although in Latin, ars can mean either art or craft, in the original Greek the word "techne" can only mean "skill", not "art".

所以,不是10年時間而可能是這 10 000 小時發揮了魔力。Henri Cartier-Bresson(1908-2004) 曾經說過,您的前 10 000 張照片是垃圾,但是就算成名後的他也要花將近一小時才能拍攝一張照片。Samuel Johnson (1709-1784)認爲這個過程需要更長時間;任何領域的頂尖高手需要窮盡畢生的精力刻苦鑽研,這條路上沒有任何捷徑可走。而且文學大師喬叟也曾感嘆道生命苦短,技藝流長。 古希臘名醫希波克拉底(Hippocrates大約在公元 400 年前說過名言 “ars longa, vita brevis” 爲世人稱道,其完整的語錄是 “Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile”, 這句話英語解釋是生命短暫,技藝流長,機遇轉瞬即逝,實驗結果小心求證,結論判斷力求謹慎。儘管拉丁語 “ars” 既可以指藝術或者技藝,但句話的希臘原文中 “techne” 只能指技藝,而不是藝術

So You Want to be a Programmer

如果您要想成爲程序員

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 your ten years/10,000 hours.

  • 請您培養對編程的興趣,自己編寫一些有趣的程序。如果編程確實能使你着迷,那你就會願意花十年或者10 000小時的時間潛心鑽研編程。

  • 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 bookCognition in Practice: Mind, Mathematics, and Culture in Everyday Life is an interesting reference for this viewpoint.

  • 編程。真才實學源於實踐。這句話說得更明確一些,在任何領域裏要達到頂尖高手的水平,不能只靠反覆實踐,這無法自動提高水平,而是要靠在積累豐富經驗的基礎上處心積慮不斷提高編程技能的那份毅力才能最終實現。 ( 366)而且最有效的學習方法是採用目標明確難度適中的編程任務挑戰自己,全面反饋評估,不斷總結經驗教訓,不斷嘗試新的挑戰,最終水到渠成。” ( 20-21)這本書《Cognition in Practice: Mind, Mathematics, and Culture in Everyday Life》中對學習持有相同觀點。

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

  • 請與其他程序員一起交流心得;請閱讀其他程序員的程序。這比學習任何教程和參加任何培訓課程更高效。

  • 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 your own or 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 ofThe New Hacker's Dictionary. One of the best programmers I ever hired had only a High School degree; he's produced a lot of greatsoftware, has his own news group, and made enough in stock options to buy his own nightclub.

  • 如果您願意,花4年時間進入大學(或者更進一步,參加研究生院)學習。這可以讓您獲得正式工作職位需要的資格,也可以讓您深入瞭解這一領域,但是如果您覺得學校學習不適合您,您也可以通過參加實際工作或者自學成才。不管哪種情況,僅靠書本知識是不夠用的。計算機科學教育不能把任何人造就成程序設計高手,就像學會使用畫刷和顏料不能成爲繪畫大師蘊含的道理一樣。《新編黑客詞典》的作者 Eric Raymond 就這樣評價書本知識的作用。我曾經聘用過的一個只有高中學歷的程序高手;他編寫了許多優秀的軟件,他有自己的新聞組,而且賺夠了股權收益開了一家夜總會。

  • 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. Understand 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 them 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).

  • 請至少學會 1 打的編程語言。您要會一門支持類抽象(比如JAVA或者C++)的語言,會一門支持函數抽象(比如Lisp或者ML)的語言,會一門支持語法抽象(比如Lisp)的語言,會一門支持聲明規範抽象(比如Prologic 或者C++)的語言,會一門支持協同編程(比如Icon或者Scheme)的語言,會一門支持並行編程(比如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.

  • 請參與語言標準化工作。這些工作可以是像ANSI C++標準委員會的工作,也可以是您的本地化編程風格定義工作,決定到底使用2個空格縮進或者是4個空格縮進。不管怎麼樣,您會知道其他人對這門編程語言的喜好,他們的喜好有多深,也可能還知道一些他們之所以偏愛這門語言的原因。

  • Have the good sense toget 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.

請把這些建議時刻牢記在心裏,僅靠書本學習能達到什麼層次,這還是不確定。在我的第一個孩子出生之前,我閱讀了所有的《如何做一個合格父親》之類的指南,但是我還是像個菜鳥。 2 年半之後,當我的第二個孩子出生時,我還要去看這些書嗎?不要。相反,我依靠我的個人經驗,結果證明這些經驗遠比專家寫的幾千頁書更有用,更使我放心。

Fred Brooks, in his essay No Silver Bulletidentified a three-part plan for finding great software designers:

Fred Brooks 在他的文章《沒有萬全之策》中發現了選拔優秀程序員的3步法則:

  1. Systematically identify top designers as early as possible.

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

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

  1. 請有計劃地儘早選拔高手;

  2. 爲了對職業選手發展和程序員職業生涯負責,請爲該選手指派一名職業導師。

  3. 請爲成長期的選手提供相互切磋相互激勵的機會。

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". Perlis is saying that the greats have some internal quality that transcends their training. But where does the quality come from? Is it innate? or do they develop it through diligence? As Auguste Gusteau (the fictional chef in Ratatouille) puts it, "anyone can cook, but only the fearless can be great." I think of it more as willingness to devote a large portion of one's life to deliberative practice. But maybefearless is a way to summarize that. Or, as Gusteau's critic, Anton Ego, says: "Not everyone can become a great artist, but a great artist can come from anywhere."

當然,這有一個假設前提,即這些選手擁有成爲優秀程序員的必備的潛質;剩下的問題是合理引導他們不斷進步。Alan Perlis描述的更加清楚:任何人都能學會怎麼雕刻:只有米開朗琪羅才懂得雕刻之外的東西。所以這就是鑄就大師的必備潛質。” Perlis 的意思是說大師的有些潛質不是靠後天訓練得來的。但是,這些潛質是從何而來,是與生俱來的嗎?莫非它是通過後天勤奮執着獲得的?就像廚神Auguste Gusteau (皮克斯動畫電影《美食總動員》(Ratatouille)中虛構的大廚)的名言一樣,任何人都能成爲大廚,但是隻有那些無畏的人才能成爲廚神。我認爲這更多的是源自內心的一種奉獻一生執着不悔刻苦實踐的決心。但是,無畏或許是表達其核心思想的一種方式。或者,如同 Gusteau的評論家 Anton Ego闡明的那樣:並非人人都能成爲藝術大師,但是成爲藝術大師之前人人都是藝術大師。

So go ahead and buy that Java/Ruby/Javascript/PHP 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 weeks. How about working hard to continually improve over 24 months? Well, now you're starting to get somewhere...

所以勇往直前吧,您可以大膽去買幾本JAVARubyJavascriptPHP教課書,這些書可能會對您有用處。但是,在24小時、幾天、甚至幾個星期以內您的生活都不會因此而發生多少變化,也無助於您提升編程專業技能。那麼,要是持之以恆連續研究2年多時間的話結果會如何?很好,如果能這樣思考問題,您就開始有點入門了….

 

翻譯:richardcao

閱讀原文地址:http://norvig.com/21-days.html

 

答案

典型PC系統各種操作指令的大概時間

execute typical instruction

執行基本指令                                               1/1,000,000,000 sec = 1 nanosec

fetch from L1 cache memory

從一級緩存中讀取數據                               0.5 nanosec

branch misprediction

分支預測失敗                                               5 nanosec

fetch from L2 cache memory

從二級緩存讀取數據                                   7 nanosec

Mutex lock/unlock

互斥加鎖/解鎖                                              25 nanosec

fetch from main memory

從主內存讀取數據                                       100 nanosec

send 2K bytes over 1Gbps network

通過1G bps 的網絡發送2K字節數據     20,000 nanosec

read 1MB sequentially from memory

從內存中順序讀取1MB數據                     250,000 nanosec

fetch from new disk location (seek)

從新的磁盤位置讀取數據(隨機讀取)   8,000,000 nanosec

read 1MB sequentially from disk

從磁盤中順序讀取1MB數據                     20,000,000 nanosec

send packet US to Europe and back

從美國發送一個報文包到歐洲再返回       150 milliseconds = 150,000,000 nanosec

發佈了25 篇原創文章 · 獲贊 46 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章