返回正常中文阅读

金牌译作 《大教堂与市集》第二章 邮件必达

1822个读者 翻译: Angelo  08/25/2007 原文 引用 双语对照及眉批

删除:
把眉批拖到这里

The Mail Must Get Through

Since 1993 I'd been running the technical side of a small free-access Internet service provider called Chester County InterLink (CCIL) in West Chester, Pennsylvania. I co-founded CCIL and wrote our unique multiuser bulletin-board software—you can check it out by telnetting to locke.ccil.org. Today it supports almost three thousand users on thirty lines. The job allowed me 24-hour-a-day access to the net through CCIL's 56K line—in fact, the job practically demanded it!

I had gotten quite used to instant Internet email. I found having to periodically telnet over to locke to check my mail annoying. What I wanted was for my mail to be delivered on snark (my home system) so that I would be notified when it arrived and could handle it using all my local tools.

The Internet's native mail forwarding protocol, SMTP (Simple Mail Transfer Protocol), wouldn't suit, because it works best when machines are connected full-time, while my personal machine isn't always on the Internet, and doesn't have a static IP address. What I needed was a program that would reach out over my intermittent dialup connection and pull across my mail to be delivered locally. I knew such things existed, and that most of them used a simple application protocol called POP (Post Office Protocol). POP is now widely supported by most common mail clients, but at the time, it wasn't built in to the mail reader I was using.

I needed a POP3 client. So I went out on the Internet and found one. Actually, I found three or four. I used one of them for a while, but it was missing what seemed an obvious feature, the ability to hack the addresses on fetched mail so replies would work properly.

The problem was this: suppose someone named `joe' on locke sent me mail. If I fetched the mail to snark and then tried to reply to it, my mailer would cheerfully try to ship it to a nonexistent `joe' on snark. Hand-editing reply addresses to tack on <@ccil.org> quickly got to be a serious pain.

This was clearly something the computer ought to be doing for me. But none of the existing POP clients knew how! And this brings us to the first lesson:

1. Every good work of software starts by scratching a developer's personal itch.

Perhaps this should have been obvious (it's long been proverbial that ``Necessity is the mother of invention'') but too often software developers spend their days grinding away for pay at programs they neither need nor love. But not in the Linux world—which may explain why the average quality of software originated in the Linux community is so high.

So, did I immediately launch into a furious whirl of coding up a brand-new POP3 client to compete with the existing ones? Not on your life! I looked carefully at the POP utilities I had in hand, asking myself ``Which one is closest to what I want?'' Because:

2. Good programmers know what to write. Great ones know what to rewrite (and reuse).

While I don't claim to be a great programmer, I try to imitate one. An important trait of the great ones is constructive laziness. They know that you get an A not for effort but for results, and that it's almost always easier to start from a good partial solution than from nothing at all.

Linus Torvalds, for example, didn't actually try to write Linux from scratch. Instead, he started by reusing code and ideas from Minix, a tiny Unix-like operating system for PC clones. Eventually all the Minix code went away or was completely rewritten—but while it was there, it provided scaffolding for the infant that would eventually become Linux.

In the same spirit, I went looking for an existing POP utility that was reasonably well coded, to use as a development base.

The source-sharing tradition of the Unix world has always been friendly to code reuse (this is why the GNU project chose Unix as a base OS, in spite of serious reservations about the OS itself). The Linux world has taken this tradition nearly to its technological limit; it has terabytes of open sources generally available. So spending time looking for some else's almost-good-enough is more likely to give you good results in the Linux world than anywhere else.

And it did for me. With those I'd found earlier, my second search made up a total of nine candidates—fetchpop, PopTart, get-mail, gwpop, pimp, pop-perl, popc, popmail and upop. The one I first settled on was `fetchpop' by Seung-Hong Oh. I put my header-rewrite feature in it, and made various other improvements which the author accepted into his 1.9 release.

A few weeks later, though, I stumbled across the code for popclient by Carl Harris, and found I had a problem. Though fetchpop had some good original ideas in it (such as its background-daemon mode), it could only handle POP3 and was rather amateurishly coded (Seung-Hong was at that time a bright but inexperienced programmer, and both traits showed). Carl's code was better, quite professional and solid, but his program lacked several important and rather tricky-to-implement fetchpop features (including those I'd coded myself).

Stay or switch? If I switched, I'd be throwing away the coding I'd already done in exchange for a better development base.

A practical motive to switch was the presence of multiple-protocol support. POP3 is the most commonly used of the post-office server protocols, but not the only one. Fetchpop and the other competition didn't do POP2, RPOP, or APOP, and I was already having vague thoughts of perhaps adding IMAP (Internet Message Access Protocol, the most recently designed and most powerful post-office protocol) just for fun.

But I had a more theoretical reason to think switching might be as good an idea as well, something I learned long before Linux.

3. ``Plan to throw one away; you will, anyhow.'' (Fred Brooks, The Mythical Man-Month, Chapter 11)

Or, to put it another way, you often don't really understand the problem until after the first time you implement a solution. The second time, maybe you know enough to do it right. So if you want to get it right, be ready to start over at least once [JB].

Well (I told myself) the changes to fetchpop had been my first try. So I switched.

After I sent my first set of popclient patches to Carl Harris on 25 June 1996, I found out that he had basically lost interest in popclient some time before. The code was a bit dusty, with minor bugs hanging out. I had many changes to make, and we quickly agreed that the logical thing for me to do was take over the program.

Without my actually noticing, the project had escalated. No longer was I just contemplating minor patches to an existing POP client. I took on maintaining an entire one, and there were ideas bubbling in my head that I knew would probably lead to major changes.

In a software culture that encourages code-sharing, this is a natural way for a project to evolve. I was acting out this principle:

4. If you have the right attitude, interesting problems will find you.

But Carl Harris's attitude was even more important. He understood that

5. When you lose interest in a program, your last duty to it is to hand it off to a competent successor.

Without ever having to discuss it, Carl and I knew we had a common goal of having the best solution out there. The only question for either of us was whether I could establish that I was a safe pair of hands. Once I did that, he acted with grace and dispatch. I hope I will do as well when it comes my turn.

1993年起,我就在宾州西切斯特的一家提供免费网络服务的小公司CCILChester County InterLink)负责技术工作。我协同创建了公司并编写了一个专用的多用户论坛程序——你可以通过telnet连接locke.ccil.org一探究竟。如今它在三十条线路上支持着近三千名用户。这使我可以每天二十四小时的通过CCIL56K专线上网——其实,这是工作需要。

我已经惯于使用网络邮件了,但不时地登录locke检查邮件实在很烦人。我所希望的是有办法能将邮件转送到我家的机器(snark)上,并在到达的时候通知我,而且可以用本地工具进行处理。

互联网默认的邮件传输协议SMTP显然不能满足我的要求,STMP是为全时在线的机器设计的,而我家的机器不可能全天在线——况且它也没有一个固定的IP。我需要一个程序,让我能在拨号之后链接到服务器上把邮件下载到本地。我知道有这种工具存在,它们大都使用一种称为POP的简单协议,现在常用的邮件客户端软件都支持这个协议,但那时,我的邮件阅读软件并不支持它。

我在网上找到了三四个这样的POP3客户端软件。其中一个我用了一段时间,可是他明显缺少一个功能:抽取正确的邮件地址。

事情是这样的,如果locke上一个叫乔的人发给我一封邮件,我将其下载到snark上。可是在回复的时候我的邮件程序会高高兴兴的把信投寄给一个在snark上并不存在的乔。手工修正地址是件痛苦的事。

显然这是一件应该由电脑来完成的事情,可是没有一个现存的POP软件知道如何解决。这给我们上了第一课:

1.好软件都源自解决开发者的切身之痛。

Every good work of software starts by scratching a developer's personal itch.

或许这是众所周知的(不是有句名谚叫做“需要是发明之母”吗?),可是有那么多软件开发者为了薪水把时间都消耗在他们及不喜欢又不需要的程序上了。然而这却不会发生在Linux世界,或许这就是Linux社区产品平均质量很高的原因吧?

那么我是否应该疯狂的投入战斗,编写一套新的POP软件来和它们一较高下呢?打死都不干!相反,我仔细地检视我手中的东西,看看哪个最接近需求。因为:

2.优秀的程序员知道要写什么,而伟大的程序员知道要改写(和重用)什么。

Good programmers know what to write. Great ones know what to rewrite (and reuse).

我不敢自诩伟大,但是我努力效法那些伟大的程序员。他们都有一个重要的特点——建设性的懒惰,因为我们要的是结果而不是过程。从一个优质的部分接手总比你白手起家要容易的多。

以李纳斯为例,他并没有从零开始编写Linux。相反他借重了Minix的代码和理念。(Minix是一个用于个人电脑的小型类Unix操作系统)虽然Minix的全部代码最终被全部摘除或重写了,但是它毕竟为Linux充当了学步车。

出于同样的考虑,我开始寻找一个现存的有最有条理的POP程序来作为开发基础。

Unix世界共享源代码的传统让我们很容易的对它们并重新加以利用。(这也是为什么尽管GNUUnix成见很深,却依然采用Unix为基础开发操作系统的原因)而Linux世界更是把这种传统发挥到了技术的极限。在浩如烟海的Linux开放代码中花点时间来寻找一个不错的程序,总比去别处要强的多。

加上我之前用到的,第二次的搜索让我有了九个候选对象:fetchpopPopTartget-mailgwpoppimppop-perlpopcpopmailupop。首先选用的是肖恩[1]fetchpop,我对其做了一些改动并将改写邮件地址的功能加了进去。后来他把这些改动加入到了自己的1.9版本中。

几周之后,我偶然接触到了卡尔·哈里斯popclient代码时,问题出现了。尽管fetchpop有那么多优秀的原创功能(比如他的后台程序),但是却只能支持POP3协议,而且代码不够老练(肖恩很聪明,但是缺少经验)。卡尔的代码则更好,专业而稳固。但是却缺少很多重要的功能——那些fetchpop中的妙作(包括我加入的部分)。

是继续使用fetchpop还是改用popclinent?如果转换的话,就意味着我不得不放弃已经完成的代码来换取一个更好的开发基础。

一个实际的转换动机是去支持更多协议。POP3使用最广,却不是唯一。Fetchpop和那个竞争对手同样不支持POP2RPOPAPOP。出于好玩,我那时已经有了在其中加入IMAP(最新设计的,最强大的POP协议)的模糊想法。

其实我还有一个更正式的理由支持我更换软件,这是我在玩Linux之前就学到的:

3.为舍弃而计划,无论如何,你都要这样做。”(弗雷德里克·布鲁克斯,《人月神话》第十一章,)[2]

Plan to throw one away; you will, anyhow. (Fred Brooks, The Mythical Man-Month, Chapter 11)

换言之,当你开始尝试解决一个问题的之后,你通常并不知道症结所在。再次着手,或许能够技经肯綮。所以想把事情做好,你得准备“至少重来一次”。【注】

好吧,(我对自己说)对fetchpop的修改就算是我的第一次吧。于是,放弃了它。

1996625,我给卡尔寄去了第一批程序补丁。才发现他对这个程序基本失去了兴趣。代码已经乏人照料很久了,小错误流连不去,有很多改动要做。我们一拍即合,由我接手。

不经意间,工作的规模扩大了。我不再只是真对一个POP客户端进行修补,而是要负责维护整个程序。一些可能会引发变革的想法在我脑海中浮现。

在鼓励代码共享的软件文化里,这样的演进方式是自然而然的。我只是将这些原理付诸实践:

4.只要你态度正确,有趣的问题就会找上门来。

If you have the right attitude, interesting problems will find you.

卡尔的态度更加重要,他懂得:

5.对一个项目失去兴趣的时候,你的最后责任就是找一个称职的接班人。

When you lose interest in a program, your last duty to it is to hand it off to a competent successor.

为了创造一个最佳的解决方案,我和卡尔不谋而合。唯一的问题是,我是否能证明我的能力。一旦我做到了,卡尔便优雅而迅速的交托给我。希望有一天轮到我这么做的时候,我能同样的出色。

 

 

注:
著名的计算机学家乔·本特利Jon Bentley)在其著作《编程珠玑》(Programing Pearls)对其做了如下评注:“如果你舍弃了一个,你还会舍弃第二个”。他的话完全正确,布鲁克斯本特利指出:不要期望一蹴而就,以一个好主意重头来过通常要比梳理一团乱麻要好的多。

 

译者按:

1.肖恩Sean Ohfetchpop的作者,书中出现的名称是Seung-Hong OhSean是其英文名。有译者将其音译作“欧松宏”,我认为这个译音有失精当。因为Oh Seung Hong这三个拼写在韩英互译时是很常见的。与其对应的韩文大致是“오승홍”,译成汉语则大致是“吴承弘”。在没有办法联系到作者本人的情况下,为了行文不出差错,我选用了其英文名。

2.The Mythical Man-MonthFrederick P. Brooks。《人月神话》,作者弗雷德里克·布鲁克斯。计算机学家,被称作“IBM 360之父”,曾获得图灵奖和美国国家技术奖——两个计算机界举足轻重的奖项。《人月神话》是其随笔集,其在书中对繁复的工程管理做了洞见的观察。在第十一章《未雨绸缪》(Plan to Throw One Away)中其提出了舍弃型原型的概念。本文引言是强调“为舍弃而计划”,“one”用来指代一个计划或者原型,我认为不能直接译为“一个”所以用了代词“它”放宽其概念。

 

http://www.angeloliu.org/read-39.html


继续阅读

标签:

内容有问题?请与我们联络。

译作评分

  • Currently 4.00/5
  • 1
  • 2
  • 3
  • 4
  • 5
 4.0  |  2 个评分