现在的位置: 首页 > 综合 > 正文

潜心十年,修炼成编程高手

2018年04月03日 ⁄ 综合 ⁄ 共 14672字 ⁄ 字号 评论关闭

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 book
    Cognition
    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 Bullet
identified 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

抱歉!评论已关闭.