David Thomas:程序员要快乐的思考

原创
开发
程序员的工作似乎是无比苦闷的,整天泡在枯燥的代码堆里。51CTO在2010年终选题上有幸专访了敏捷宣言创始人之一,《程序员修炼之道》与《Programming Ruby》的作者David Thomas,请他谈谈他的快乐编程之道。

【51CTO独家特稿】一个国外的技术大牛,一开始其实只是为了解决具体的技术问题而钻研技术。但是经历了一段时间的钻研,程序员就有可能从中体会到乐趣,真正做到快乐的写代码,快乐的思考。David Thomas就是这样一位快乐的程序员。

人物简介

[[18319]]

Dave Thomas,敏捷宣言创始人之一,《程序员修炼之道》与《Programming Ruby》的作者。他有着三十余年的编程经验,现在主要经营Pragmatic Programmer出版社,阅书无数。同时,Dave每天都仍然在编写代码。

1、你最开始从事开发的时候,有什么技术理想么?这个技术理想在之后的年岁中有过改变么?

我最开始编程的时候,我认为那时的自己还谈不上有什么技术理想——这是很久之后才有的。

我在16岁的时候,准备在高中学习数学。我当时还在英国念初中,我们一群孩子提前一年完成了学业。学校想找点事情给我们做,就建议我们去一个本地的技术学校(类似中专)上一门计算机编程的课程。在那个时候,你通过300波特调制解调器、电传打字机和纸带机和计算机进行交互。在这门课上了一个月左右的时候,我忽然发现了我真正喜爱的东西。每天下课之后,我用好几个小时在纸带上编写Basic程序,再上传到大型主机上。我甚至进行了我的第一次元编程——由于我们被限制只能在主机上保存5个程序,我于是编写了一个可以储存其他程序的Basic程序,就好象一个迷你的文件系统。

经历过这些之后,我意识到了我对编程的渴望。我在接下来的大学选科过程中没有再看任何的数学课,而是搜索有没有计算机科学的课程。幸运的是,帝国理工学院刚刚开办了一门计算机科学的课程,我就这么进去了。这门课程可能是这个领域最好的入门指导了:课程本身相当深入,课外练习都十分实用,而且十分具有挑战性。基本上,我在学校期间靠编程打工的钱就把我的学费全付清了。

毕业之后我计划读博士,不过一个初创企业把我拐走了。我觉得这其实是挺幸运的,因为借助这次创业的机会,我认识到了软件业务的另一面:客户,项目,以及正确的做事。公司很小,但都是非常聪明的人,所以只要是能找到的活儿,我们什么都做。在短短数年间,我在各个方面积累了大量的经验。

所有这一切都是由热情推动的,而谈不上什么技术理想。我只是做我喜欢做的事情。

不过,久而久之,我开始意识到工作中的“模式”(patterns)——在软件开发工艺的深层隐藏的那些真理。最终,我和Andy Hunt将其中的一些模式描述成文字,记录在我们的《程序员修炼之道》当中。

不过,这仍然算不上什么“技术理想”。你这个问题很好,它引发了我的思考。思考的结果就是,如果“技术理想”的含义是“我想要做这个或那个”,那么我并没有任何技术理想。我的理想很简单:做我高兴做的事。我想要继续写代码,我想要用代码解决人们的问题。我想要继续磨练我的手艺,我想要在软件开发的新领域中测试和体验。我知道这有点自私,不过我想要继续“寻欢作乐”:)

2、你有没有感到某个时刻,你忽然“顿悟”了编程?如果有的话,能描述一下当时发生的事情吗?

当然有过忽然灵光一现的时候。有些时候,只是比较低层次的。我还记得当我在PDP-11计算机上编程的时候,遇到了一个将二进制数字转化为八进制ASCII码的库子程序。很明显,这是任何一个程序员都能够写出来的功能。不过,我遇到的这个程序被编写的十分“优雅”:这位程序员使用了PDP标志寄存器(flag registers)和旋转运算(rotate operations)的一些深层知识,用短短四、五行汇编就完成了这个功能。这并非是我印象中最短小的代码,但我当时领悟到了:想要变得优雅,必须深入理解你编程的环境。大多数开发者只是对他们使用的工具有一个表层的理解,所以他们生产的代码四平八稳。只有那些愿意花费时间深入学习,去了解底层都在做什么的开发者们,才能生产出优雅的、革命性的代码。

此外,也有一些技术之外的“顿悟”。在我职业生涯的早期,我有一次和我们创业的老大一起去见一个客户。这位客户是一个很大的软件公司的拥有人,是我们这个产业中一个重要的人物——更重要的是,他手上有我们需要的项目。在商谈的过程中,我发现客户想要我们做的东西根本做不成,因为他漏掉了一些技术问题。当时的我很傻很天真,就直接跟他说这个不行。一时之间,屋子里陷入寂静,而这次商谈也很快结束了。回到办公室,我想,我肯定要被炒鱿鱼了,因为我顶撞了客户。不过没想到的是,我的老板教了我一件事,这使我终身受益。老板说,我道出事实这件事没有错。如果我们发现有一个问题将会导致项目无法进行,那么如果我们仍然接下这个项目,就是没有职业道德。不过,问题在于我提出意见的方式:如果一个人的想法有错误,不要直接跟他说“这是错的”。你应该做的是想办法引导他自己发现问题所在。

其实这些事请我现在仍然不是特别擅长。我仍然会因为项目的技术挑战而挠头,也经常会忘记了人的因素。不过,那些“顿悟”的瞬间的确存在。

3、你的编程生涯中,最令你印象深刻的事情是什么?如果你能够给那时的自己提供一些建议,你会说些什么?

在西方,我们有这样一条谚语:“祝你生活在有趣的时代(May you live in interesting times)”(译注:据传这是一句古老的中国诅咒,由一位英国驻中国的外交官传回西方,后变成西方的祝词。中文原文已不可考,有说法是“宁为太平犬,不做乱世人”)。这是一条温柔的诅咒,因为有趣的时代同时也意味着艰难的时代。我觉得我们现在正生活在这条诅咒当中。没有任何一个时代比我们现在所处的时代更加有趣,同时也更加令人混乱。新的技术,新的技巧,新的语言,新的期待。所以我最大的希望是,我编程生涯中最美好的事情还没有到来。我希望最令我印象深刻的事情发生在未来。我的工作,我的热情,都在尽可能的经历更多的事情,所以最令我印象深刻的事情一定会发生在未来。

以下为51CTO采访英文原文

1. Aspiration

When you first started programming, what was your technical aspiration? Has your aspiration changed over the years?

I don't think I had a technical aspiration when I first started programming—that kind of thing came a lot later.

When I was 16, I was planning to study mathematics at college. I was still in secondary school in England, and a group of us had finished all our required classes a year early. The school was looking for things for us to do, and suggested we might be interested in attended a class on computer programming at the local technical college (a vocational school). This was back when you interacted with computers using 300 baud modems, teletypes, and paper tape. And sometime during the first month of that class, I realized that I'd found something I truly loved. I spent hours after school slowly typing Basic programs on to paper tape before uploading them to a mainframe. I even did my first metaprogramming—we were only allowed to store 5 programs up on the mainframe, so I wrote a Basic program that stored my other Basic programs inside itself, a kind of mini filesystem.

After that experience, I knew I wanted to write code. I stopped looking at university mathematics courses and instead looked for computer science. And I was lucky—Imperial College in London had just started a course, and I got in. It really was the best possible introduction to the field—the course itself was deep, and the work outside the course was practical and challenging. I ended up paying my way through school with programming jobs.

After I graduated, I started working on a PhD, but got tempted away by a start-up. I think this was also a very lucky move, because I suddenly learned the other side of the software business—clients, projects, and doing things right. The company was very small and full of very smart people, so we'd do just about any work we could find. I got an incredible amount of experience in a very broad range of topics in just a few years.

All of this was driven by a passion, not by any kind of technical aspiration. I was just doing what I enjoyed doing.

But, over time,I also started to realize that there were patterns in the work—underlying realities in the craft of developing software. Eventually, Andy Hunt and I captured some of these in our book The Pragmatic Programmer.

But I still don't think these count as "technical aspirations." You question was a good one, and it made me think. In the end, I don't think I have a technical aspiration, if the phrase means "I hope I do this or that technical thing." Instead, my aspiration is simple—I want to continue to do what I enjoy doing. I want to continue to write code, and to solve people's problems using code. I want to continue to improve at my craft, and to experiment with and experience new areas of software development. I know it's selfish, but I want to continue to have fun!

2. Insight

Have you ever experienced the change from "have no insight" to "have insight" in programming? Has there been a day on which you suddenly realised "oh, this IS the right way to programming"? If so, can you describe what grabbed you on that day?

I have definitely had those moments where suddenly something snaps into place. Sometimes these are really low-level technical moments. I remember when I was programming PDP-11 computers, I came across a library subroutine that converted a binary number into its ASCII octal representation. Of course, this would have been a function that any programmer could write. But this particular developer had done it *elegantly*, using a deep knowledge of the PDP's various flag registers and rotate operations to do the whole thing in just four or five lines of assembler. It wasn't the small size of the code that I remember—the insight was that you had to really understand the environment you were using if you wanted to be elegant. Most people have a surface understanding of the tools they use, and they produce solid, average code as a result. But the people who spend the time to dig deep, and to learn what's really going on—those are the people who produce elegant and revolutionary answers.

I also experienced nontechnical insights. I remember early on in my career I was at a client meeting with the owner of the startup I worked for. The client was the owner of a large software company; an important person in our industry, and, more importantly, someone with a project that we really needed :)  During the meeting, it became clear that what he wanted us to write wouldn't work—he'd overlooked some technical problems. Being very young and very naive, I told him this. The room went silent, and the meeting ended very quickly after that. On our way back to our office, I expected to get fired for disagreeing with a client. But, instead, my boss taught me a lesson that I still use. He said that I was right to speak up. He said that if there was a problem that would stop the project working, we'd be unethical if we went ahead. But then he said that I was wrong to speak up the way I did—if there's a problem with a someone's ideas, don't just say "that's wrong." Instead, try to guide them to find the problem for themselves.

I'm not very good at this—I still get caught up in the technical challenges of projects, and I too often forget the human side, But the lesson—the insight—is still valid.

3. Back to the past

What is the most memorable thing in your programming career? If you can give suggestions to yourself at that time, what would you say?

In the West, we're told that there is a saying: "May you live in interesting times."  it's meant as a mild curse—interesting times are difficult times. And I think we're all living with that curse right now. Times have never been more interesting, or more confusing. New technologies, new techniques, new languages, and new expectations surround us. So I very much hope that the best part of my programming career has not yet happened. I hope that the most memorable thing I'll do lies in the future. My job, my passion, is to experience as much as I can so that I maximize the chances that this will happen.
 

【编辑推荐】

  1. 程序员的十个层次 你属于哪一层?
  2. 成为完美程序员的10种品质
  3. 钟胜辉谈PHP发展的现状和前景
  4. 程序员,你适合做一个项目经理吗?
  5. 是什么成就了一名“高级”程序员?
责任编辑:彭凡 来源: 51CTO
相关推荐

2014-07-22 10:12:33

程序员

2013-07-25 09:47:40

程序员职业发展

2013-07-09 09:11:50

程序员

2016-03-02 10:49:08

程序员快乐

2015-11-24 16:33:05

程序员思考分享

2020-09-26 21:23:26

程序员代码编程

2012-11-08 11:19:38

2013-08-01 10:03:41

程序员

2020-07-10 09:55:15

程序员技能开发者

2011-12-23 09:16:19

2015-07-27 10:51:55

程序员快乐

2015-04-30 10:51:37

程序员高效快乐

2015-04-30 08:41:04

程序员高效健康

2011-05-31 10:50:36

程序员

2012-11-12 10:46:37

2013-08-20 09:33:59

程序员

2009-05-13 11:40:19

编程语言开发语言Perl

2011-12-20 10:02:01

ASP.NET

2023-11-27 09:25:42

程序员思维

2011-05-13 14:34:02

程序员
点赞
收藏

51CTO技术栈公众号