Skip to content

yikeke/tao-of-programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

《编程之道》 (Tao of Programming) 最新中英双语版

作者:Geoffrey James

译者:Coco

欢迎贡献、参与讨论

如有改进建议,欢迎提 Pull Request,为这版翻译作出贡献!

如有不解的点,欢迎提 Discussions 与大家一起讨论~

目前的 Discussions:

相关文章

微信公众号二维码:阿狍杂谈

五次登上国外程序员圈“新闻联播”,编程界《道德经》有何魔力?最新双语版,速看速收藏!

欢迎扫码关注我的微信公众号『阿狍杂谈』👉

介绍:我在互联网/IT/开源世界玩大冒险,在英语/心理/哲学世界学真心话。我所有的输赢得失,都在这儿讲给你听 :-)


以下为《编程之道》目录及全文。

目录

1. The Silent Void 寂静的虚空

Thus spake the Master Programmer:

编程大师如是说:

"When you have learned to snatch the error code from the trap frame, it will be time for you to leave."

“待你能一眼看出代码框架中的错误,就是你学成离开的那天。”

1.1

Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming.

寂静虚空中,某种神秘的东西诞生了。它独自等待着,似一动不动,却作用恒久。它是所有程序的源头。我不知道它的名字,姑且称之为——“编程之道”。

If the Tao is great, then the operating system is great.

如果编程之道是伟大的,那么操作系统也是伟大的。

If the operating system is great, then the compiler is great.

如果操作系统是伟大的,那么编译器也是伟大的。

If the compiler is great, then the application is great.

如果编译器是伟大的,那么应用程序也是伟大的。

The user is pleased, and there is harmony in the world.

只有用户高兴,世界才能和谐。

The Tao of Programming flows far away and returns on the wind of morning.

编程之道流淌至远方,又乘着第一缕晨风回归。

【讨论】The Silent Void 这标题,感觉用中文很难翻译啊

1.2

The Tao gave birth to machine language. Machine language gave birth to the assembler.

编程之道孕育了机器语言,机器语言孕育了汇编器。

The assembler gave birth to the compiler. Now there are ten thousand languages.

汇编器孕育了编译器。如今,世上出现了一万种语言。

Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao.

每种语言都有自己的目的,哪怕微不足道。每种语言都表达了软件的阴阳两面。每种语言在道中都有一席之地。

But do not program in COBOL if you can avoid it.

但如果可能,尽量不要使用 COBOL 商业语言来编程。

【讨论】为何作者不鼓励使用 COBOL 商业语言编程?

1.3

In the beginning was the Tao. The Tao gave birth to Space and Time.

世间混沌之初只有道。道孕育了空间和时间。

Therefore Space and Time are the Yin and Yang of programming.

空间和时间,即是编程的阴和阳。

Programmers that do not comprehend the Tao are always running out of time and space for their programs. Programmers that comprehend the Tao always have enough time and space to accomplish their goals.

悟道前,程序员总是耗尽程序的时间和空间。悟道后,他们总有足够的时间和空间来达成程序的目的。

How could it be otherwise?

如何能反其道而行之?

1.4

The wise programmer is told about Tao and follows it. The average programmer is told about Tao and searches for it. The foolish programmer is told about Tao and laughs at it.

聪明的程序员一朝闻道,余生行道;普通的程序员一朝闻道,余生寻道。愚蠢的程序员一朝闻道,只哈哈笑道。

If it were not for laughter, there would be no Tao.

但若没有这笑,也不能称之为道。

The highest sounds are hardest to hear. Going forward is a way to retreat. Great talent shows itself late in life. Even a perfect program still has bugs.

人们总是最难听见最高处的声音。进是退的一种。大器总是晚成。没有完美的程序,任何程序都有漏洞。

2. The Ancient Masters 旧时代的大师

Thus spake the Master Programmer:

编程大师如是说:

"After three days without programming, life becomes meaningless."

“三日不编程,生命便了无意义。”

2.1

The programmers of old were mysterious and profound. We cannot fathom their thoughts, so all we do is describe their appearance.

旧时代的程序员神秘而深奥。我们无法理解他们的想法,只能描述他们的样子。

Aware, like a fox crossing the water.

觉察,如狐狸游过水面

Alert, like a general on the battlefield.

警惕,如将军坐镇战场

Kind, like a hostess greeting her guests.

亲切,如主人迎接客人

Simple, like uncarved blocks of wood.

简单,如木块未经雕刻

Opaque, like black pools in darkened caves.

隐晦,如穴中幽暗水池

Who can tell the secrets of their hearts and minds?

谁能窥探他们的内心,谁能看穿他们的想法?

The answer exists only in Tao.

答案尽在道中。

2.2

The Grand Master Turing once dreamed that he was a machine. When he awoke, he exclaimed:

昔日,图灵大师梦见自己变成了一台机器,他醒来后惊呼:

"I don't know whether I am Turing dreaming that I am a machine, or a machine dreaming that I am Turing!"

“我不确定我是图灵梦见自己变成了机器,还是我是机器梦见自己变成了图灵!”

2.3

A programmer from a very large computer company went to a software conference and then returned to report to his manager, saying: "What sort of programmers work for other companies? They behaved badly and were unconcerned with appearances. Their hair was long and unkempt and their clothes were wrinkled and old. They crashed our hospitality suite and they made rude noises during my presentation."

一位大型计算机公司的程序员去参加一个软件会议,回来后向他的老板汇报,说:“其他公司的程序员怎么是这个样子?他们不讲礼貌,不注重外表——头发又长又乱,衣服又皱又旧。不仅闯进我们的接待室,还在我演讲时随便说话。”

The manager said: "I should have never sent you to the conference. Those programmers live beyond the physical world. They consider life absurd, an accidental coincidence. They come and go without knowing limitations. Without a care, they live only for their programs. Why should they bother with social conventions?"

老板说:“我不该让你去参会的。那些程序员早已从现实世界超脱。他们认为生活是荒谬的,只是一场偶然的巧合。他们来去随心,不受限制。没有牵挂的他们,只为程序而活。社会习俗如何能左右他们?”

"They are alive within the Tao."

“他们活在道中。”

2.4

A novice asked the Master: "Here is a programmer that never designs, documents or tests his programs. Yet all who know him consider him one of the best programmers in the world. Why is this?"

弟子问大师:“有位程序员从来不提前设计自己的程序,也不写文档或进行测试。但所有认识他的人都视他为世上最好的程序员之一。为什么?”

The Master replied: "That programmer has mastered the Tao. He has gone beyond the need for design; he does not become angry when the system crashes, but accepts the universe without concern. He has gone beyond the need for documentation; he no longer cares if anyone else sees his code. He has gone beyond the need for testing; each of his programs are perfect within themselves, serene and elegant, their purpose self-evident. Truly, he has entered the mystery of Tao."

大师回答说:“因为他已得道。他不再需要设计:当系统崩溃时,他不会生气,而是毫不在意地接受现实;他不再需要文档:他不关心是否有人看到他的代码;他不再需要测试:他的每个程序都是完美的,平静而优雅,程序的目的不言而喻。他已经领悟了道的真意。”

3. Design 程序设计

Thus spake the Master Programmer:

编程大师如是说:

"When a program is being tested, it is too late to make design changes."

“待程序进入测试阶段,任何设计上的修改都太晚了。”

3.1

There once was a man who went to a computer trade show. Each day as he entered, the man told the guard at the door:

从前,有个人去参加计算机商展。每天他进门时,都会跟门口的保安说:

"I am a great thief, renowned for my feats of shoplifting. Be forewarned, for this trade show shall not escape unplundered."

“我是一名伟大的小偷,最擅长顺手牵羊,颇负盛名。提前警告你,这次展会也是我的目标之一。”

This speech disturbed the guard greatly, because there were millions of dollars of computer equipment inside, so he watched the man carefully. But the man merely wandered from booth to booth, humming quietly to himself.

这番话让保安大为不安,因为里面有价值数百万美元的计算机设备。因此他仔细注意着这个人。但这人只是从一个摊位走到另一个摊位,嘴里念念有词。

When the man left, the guard took him aside and searched his clothes, but nothing was to be found.

这人离开时,保安把他拉到一旁搜身,却什么也没有找到。

On the next day of the trade show, the man returned and chided the guard, saying: "I escaped with a vast booty yesterday, but today will be even better." So the guard watched him ever more closely, but to no avail.

展会第二天,这人又来了。他骂着保安,说:“我昨天掳走了一大笔战利品,今天的收获会更好。”于是保安更加密切地关注他,但没发现任何异常。

On the final day of the trade show, the guard could restrain his curiosity no longer. "Sir Thief," he said, "I am so perplexed, I cannot live in peace. Please enlighten me. What is it that you are stealing?"

展会最后一天,保安再也抑制不住好奇心。“小偷先生,”他问,“我真的很困惑,我没法安心生活。求给个痛快,你到底偷了什么?”

The man smiled. "I am stealing ideas," he said.

这人笑了,“我在偷取创意,”他说。

3.2

There once was a Master Programmer who wrote unstructured programs. A novice programmer, seeking to imitate him, also began to write unstructured programs. When the novice asked the Master to evaluate his progress, the Master criticized him for writing unstructured programs, saying, "What is appropriate for the Master is not appropriate for the novice. You must understand Tao before transcending structure."

从前,有位编程大师擅长编写没有结构的程序。他的弟子模仿他,也开始编写没有结构的程序。当弟子请大师评价他的程序,大师批评他:“适合大师的不一定适合初学者。在超越结构之前,你必须先领悟道。”

3.3

There was once a programmer who was attached to the court of the warlord of Wu. The warlord asked the programmer: "Which is easier to design: an accounting package or an operating system?"

从前有位程序员在吴氏企业任职。吴总问程序员:“财务系统和操作系统,哪个更容易设计?”

"An operating system," replied the programmer.

“操作系统,”程序员回答。

The warlord uttered an exclamation of disbelief. "Surely an accounting package is trivial next to the complexity of an operating system," he said.

吴总发出一声惊叹,难以置信道:“但与操作系统的复杂性相比,设计财务系统肯定易如反掌吧?”

"Not so," said the programmer, "When designing an accounting package, the programmer operates as a mediator between people having different ideas: how it must operate, how its reports must appear, and how it must conform to the tax laws. By contrast, an operating system is not limited by outside appearances. When designing an operating system, the programmer seeks the simplest harmony between machine and ideas. This is why an operating system is easier to design."

“不,”程序员说,“设计财务系统时,程序员是协调者,帮助人们在不同使用需求​间达成一致,比如如何操作界面、显示报表、遵守税法等。但操作系统不受前端的限制。设计操作系统时,程序员只需在机器与想法之间,寻求最简单的和谐统一。因此,操作系统更容易设计。”

The warlord of Wu nodded and smiled. "That is all good and well, but which is easier to debug?"

吴总点点头,笑道:“你说得很好,但是哪个更容易调试呢?”

The programmer made no reply.

程序员没有回答。

3.4

A manager went to the Master Programmer and showed him the requirements document for a new application. The manager asked the Master: "How long will it take to design this system if I assign five programmers to it?"

一位主管找到编程大师,请他看一个应用程序的需求文档。主管问:“如果让 5 个程序员去设计这个系统,需要多长时间?”

"It will take one year," said the Master promptly.

“需要一年,”大师毫不犹豫地说。

"But we need this system immediately or even sooner! How long will it take if I assign ten programmers to it?"

“但我们现在就需要这个系统,越快越好!如果我找 10 个程序员呢?需要多长时间?”

The Master Programmer frowned. "In that case, it will take two years."

大师皱了皱眉头,“如此的话,需要两年。”

"And what if I assign a hundred programmers to it?"

“那如果我找 100 个程序员呢?”

The Master Programmer shrugged. "Then the design will never be completed," he said.

大师耸耸肩,“那这个设计就永远别想完成了。”

4. Coding 编程

Thus spake the Master Programmer:

编程大师如是说:

"A well-written program is its own Heaven; a poorly-written program is its own Hell."

“优秀的程序仿佛置身天堂,差劲的程序如同自取灭亡。”

4.1

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little nor too much. Neither needless loops nor useless variables; neither lack of structure nor overwhelming rigidity.

程序应当轻巧灵活,内部的子过程彼此连接,串若珍珠。程序的精神和目的,当一以贯之。代码量要恰到好处,减一行则少,增一行则多。不存在多余的循环或变量。既不失整体结构,也不至僵化死板。

A program should follow the "Law of Least Astonishment". What is this law? It is simply that the program should always respond to the users in the way that least astonishes them.

程序应当遵循“最少惊讶原则”。这个原则很简单:程序返回的结果永远符合用户的预期。

A program, no matter how complex, should act as a single unit. The program should be directed by the logic within rather than by outward appearances.

无论程序多么复杂,都可当作一个独立单元来运行。程序应靠内在逻辑指导,而不为前端形式左右。

If the program fails in these requirements, it will be in a state of disorder and confusion. The only way to correct this is to rewrite the program.

如果程序不满足以上要求,它将陷入无序与混乱。唯一的修复办法就是重写程序。

4.2

A novice asked the Master: "I have a program that sometimes runs and sometimes aborts. I have followed the rules of programming, yet I am totally baffled. What is the reason for this?"

弟子问大师:“我的程序有时跑得通,有时跑不通。我遵守了编程的法则,但我这次彻底束手无策了。这是为什么?”

The Master replied: "You are confused because you do not understand Tao. Only a fool expects rational behavior from his fellow humans. Why do you expect it from a machine that humans have constructed? Computers simulate determinism; only Tao is perfect.

大师答:“你心存疑惑,只因你还未悟道。唯有傻子才会期望世人举止理性。你又如何期望世人建造的机器能有理性的行为呢?计算机只能模拟决定论;世间唯有道是完美的。

The rules of programming are transitory; only Tao is eternal. Therefore, you must contemplate Tao before you receive Enlightenment."

编程无常法,唯道恒久远。在获得启示之前,你必须深思道。”

"But how will I know when I have received Enlightenment?" asked the novice.

“但我如何知道我获得了启示呢?”弟子问。

"Your program will run correctly," replied the Master.

“你的程序将顺利运行,”大师答。

4.3

The Master was explaining the nature of Tao to one of his novices.

大师正向他的一个弟子解释道的本质。

"The Tao is embodied in all software -- regardless of how insignificant," said the Master.

“道的真意存在于所有的软件中,即使是最不重要的软件。”大师说。

"Is the Tao in a hand-held calculator?" asked the novice.

“道在手持计算器里吗?”弟子问。

"It is," came the reply.

“在,”大师答。

"Is the Tao in a video game?" asked the novice.

“道在电子游戏里吗?”

"It is even in a video game," said the Master.

“也在。”

"Is the Tao in the DOS for a personal computer?" asked the novice.

“个人电脑的 DOS 中也有道吗?”

The Master coughed and shifted his position slightly. "The lesson is over for today," he said.

大师轻咳一声,微微一动。“今天的课就上到这里。”

【讨论】“个人电脑的 DOS 中也有道吗?” 大师为何微微一笑?

4.4

Prince Wang's programmer was coding software. His fingers danced upon the keyboard. The program compiled without and error message, and the program ran like a gentle wind.

王氏企业内,一名程序员正在编写软件。他的指尖在键盘上飞舞。程序编译时没有任何错误,运行起来如清风拂过,丝滑顺畅。

"Excellent!" the Prince exclaimed. "Your technique is faultless!"

“太棒了!”王总惊呼道,“你的技术简直完美!”

"Technique?" said the programmer, turning from his terminal, "What I follow is Tao -- beyond all techniques! When I first began to program, I would see before me the whole problem in one mass. After three years, I no longer saw this mass. Instead, I used subroutines. But now I see nothing. My whole being exists in a formless void. My senses are idle. My spirit, free to work without a plan, follows its own instinct. In short, my program writes itself. True, sometimes there are difficult problems. I see them coming, I slow down, I watch silently. Then I change a single line of code and the difficulties vanish like puffs of idle smoke. I then compile the program. I sit still and let the joy of the work fill my being. I close my eyes for a moment and then log off."

“技术?”程序员转过身,“我追求的是道——超越所有技术的道!我刚开始编程时,眼前的问题堆积成团、杂乱如麻。三年后,我再也没见过这样的问题,因为我学会了子程序。如今,我什么也看不见了。我的存在变得虚无,我感受不到任何事物。我的精神不受约束,全凭本能自由工作。换句话说,我写程序时,代码是一行行自己显现的。当然,有时我会碰到一些棘手的问题。我看着这些问题出现,我慢下来,静静地看着。然后我改动一行代码,问题像轻烟般自己消失了。我开始编译程序。我静静地坐着,感受着快乐盈满身心。我闭目冥想片刻,然后退出系统。”

Prince Wang said, "Would that all of my programmers were as wise!"

王总说:“愿我司所有的程序员都这样聪明!”

5. Maintenance 代码维护

Thus spake the Master Programmer:

编程大师如是说:

"Though a program be but three lines long, someday it will have to be maintained."

哪怕程序只有三行,总有一天也需要人维护。

5.1

A well-used door needs no oil on its hinges.

户枢不蠹。

A swift-flowing stream does not grow stagnant.

流水不腐。

A deer blends perfectly into the forest colors.

一只鹿完美地融入森林的色彩中。

Software rots if not used.

软件没人用,神奇也会化为腐朽。

These are great mysteries.

这些都是道的奥秘。

5.2

A manager asked a programmer how long it would take him to finish the program on which he was working. "I will be finished tomorrow," the programmer promptly replied.

主管问程序员,写完手上的程序需要多久。“我明天能写完,”程序员毫不犹豫地说。

"I think you are being unrealistic," said the manager, "Truthfully, how long will it take?"

“这太不切实际了,”主管说,“实话实说,到底要多久?”

The programmer thought for a moment. "I have some features that I wish to add. This will take at least two weeks," he finally said.

程序员想了一会儿。“我想补充一些功能,这至少需要两周,”他最终表示。

"Even that is too much to expect," insisted the manager, "I will be satisfied if you simply tell me when the program is complete."

“两周也期望过高了,”主管继续说,“你写完的时候告诉我一声,我就知足了。”

The programmer agreed to this.

程序员同意了。

Several years later, the manager retired. On the way to his retirement luncheon, he discovered the programmer asleep at his terminal. He had been programming all night.

几年后,主管退休了。在去退休午宴的路上,他发现程序员在电脑前睡着了。他整晚都在写代码。

5.3

A novice programmer was once assigned to code a simple financial package.

从前,大师让一个弟子做一个简单的财务系统。

The novice worked furiously for many days, but when his Master reviewed his program, he discovered it contained a screen editor, a set of generalized graphics routines, and an artificial intelligence interface, but not the slightest hint of anything financial.

弟子疯狂地写了很多天代码。大师检查进度时,他发现程序里多了一个屏幕编辑器、一套通用的图形程序和一个人工智能界面,但没发现任何与财务相关的东西。

When the Master asked about this, the novice became indignant. "Don't be so impatient," he said, "I'll put in the financial stuff eventually."

当大师提到这一点,弟子有点生气。“耐心点,”他说,“我最后会写财务的部分的。”

5.4

Does a good farmer neglect a crop he has planted?

好的农民会随意对待自己种的庄稼吗?

Does a good teacher overlook even the most humble student?

好的老师会忽视自己最谦虚的学生吗?

Does a good father allow a single child to starve?

好的父亲会舍得让任何一个孩子挨饿吗?

Does a good programmer refuse to maintain his code?

好的程序员会拒绝维护自己的代码吗?

6. Management 管理

Thus spake the Master Programmer:

编程大师如是说:

"Let the programmers be many and the managers few -- then all will be productive."

“愿世间的程序员多一些,管理人员少一些——这样所有人做事都会更高效。”

6.1

When managers hold endless meetings, the programmers write games.

当管理人员不停地开会,程序员在编写游戏。

When accountants speak of quarterly profits, the development budget is about to be cut.

当财务主管谈到季度盈收,开发预算就要削减。

When senior scientists talk blue sky, the clouds are about to roll in.

当资深科学家谈及蓝天,云层从天边滚滚袭来。

Truly, this is not the Tao of Programming.

确实,这不是编程之道。

When managers make commitments, game programs are ignored.

当管理人员做出承诺,没人再会写游戏程序。

When accountants make long-range plans, harmony and order are about to be restored.

当财务主管制定长期计划,和谐与秩序将会恢复。

When senior scientists address the problems at hand, the problems will soon be solved.

当资深科学家开始处理手头的问题,问题将很快得到解决。

Truly, this is the Tao of Programming.

确实,这就是编程之道。

6.2

Why are programmers non-productive? Because their time is wasted in meetings.

为什么程序员没有工作效率?因为要开的会议没完没了。

Why are programmers rebellious? Because the management interferes too much.

为什么程序员不听指挥?因为管理层管得太多太深。

Why are the programmers resigning one by one? Because they are burnt out.

为什么程序员一个接一个辞职?因为他们累得心力交瘁。

Having worked for poor management, they no longer value their jobs.

在管理不善的部门工作,他们再也看不到自己工作的价值。

6.3

A manager was about to be fired, but a programmer who worked for him wrote a new program that became popular and sold well. As a result, the manager retained his job.

主管要被解雇了,但他手下的一位程序员写了个新程序,这个程序大受欢迎,销量很好。结果,主管保住了工作。

The manager tried to give the programmer a bonus, but the programmer refused it, saying, "I wrote the program because I thought it was an interesting concept, and thus I expect no reward."

主管想给这位程序员额外奖赏,程序员拒绝道:“我写这个程序只是为了实现一个有意思的设想,我不想要任何奖励。”

The manager upon hearing this remarked, "This programmer, though he holds a position of small esteem, understands well the proper duty of an employee. Let us promote him to the exalted position of management consultant!"

主管听完,评价道:“这人虽然职位不高,但他很清楚员工应尽的责任。我们应该让他做公司的管理顾问!”

But when told this, the programmer once more refused, saying, "I exist so that I can program. If I were promoted, I would do nothing but waste everyone's time. Can I go now? I have a program that I am working on."

程序员听说后,再次拒绝了:“我在这里是为了写代码。如果我升职了,我就什么也不会做,只会浪费大家的时间。我可以走了吗?我还有个项目要做。”

6.4

A manager went to his programmers and told them: "As regards to your work hours: you are going to have to come in at nine in the morning and leave at five in the afternoon." At this, all of them became angry and several resigned on the spot.

主管对他手下的程序员说:“关于工作时间的规定下来了:以后你们必须早上九点上班,下午五点下班。”听了这话,所有人都很生气,有几个当场辞职了。

So the manager said: "All right, in that case you may set your own working hours, as long as you finish your projects on schedule." The programmers, now satisfied, began to come in at noon and work to the wee hours of the morning.

于是主管说:“好吧,这样的话,以后你们自己安排工作时间,只要保证按时完成项目。”程序员们这下满意了,从中午开始工作,一直忙碌到凌晨。

7. Corporate Wisdom 企业智慧

Thus spake the Master Programmer:

编程大师如是说:

"You can demonstrate a program for a corporate executive, but you can't make him computer literate."

“你可以给企业高管演示程序,但无法让他精通电脑。”

7.1

A novice asked the Master: "In the East, there is a great tree-structure that men call 'Corporate Headquarters'. It is bloated out of shape with vice presidents and accountants. It issues a multitude of memos, each saying 'Go Hence!' or 'Go Hither!' and nobody knows what is meant. Every year new names are put onto the branches, but all to no avail. How can such an unnatural entity exist?"

弟子问大师:“在西方,有一个巨大的树状结构组织,人们称之为‘企业总部’。里面的副总裁和财务人员多如牛毛,整个组织臃肿不堪。它每天发布大量的备忘录,每一条都写着‘做这个’‘做那个’,没人知道是什么意思。每年,有很多新人加入各个分公司,但都无济于事。为什么会有这么怪异的组织呢?”

The Master replied: "You perceive this immense structure and are disturbed that it has no rational purpose. Can you not take amusement from its endless gyrations? Do you not enjoy the untroubled ease of programming beneath its sheltering branches? Why are you bothered by its uselessness?"

大师答:“你对这个巨大的结构感到不安,因为它没有合理的目的。可是从它不停歇的运作中,你难道不能发现快乐吗?在其枝叶的遮蔽下,你难道不享受编程的轻松自在吗?你为何因为它的无用而苦恼呢?”

7.2

In the East there is a shark which is larger than all other fish. It changes into a bird whose wings are like clouds filling the sky.

东方有鱼,其名为鲲。鲲之大,绵绵若千里之远;化而为鸟,其名为鹏。鹏之翼,皇皇若垂天之云。

When this bird moves across the land, it brings a message from Corporate Headquarters. This message drops into the midst of the programmers, like a seagull making its mark upon the beach. Then the bird mounts on the wind and, with the blue sky at its back, returns home.

这只大鸟从东边飞来,带来了企业总部的消息。如海鸥掠过沙滩,大鸟将消息撒播在了程序员之间。随后它背负青天,扶摇直上,缓缓归去。

The novice programmer stares in wonder at the bird, for he understands it not. The average programmer dreads the coming of the bird, for he fears its message. The Master Programmer continues to work at his terminal, unaware that the bird has come and gone.

初级程序员惊奇地盯着大鸟,因为他不明白这意味着什么。中级程序员害怕大鸟的到来,因为它带来了总部的消息。而编程大师一直在电脑前工作,完全没注意到大鸟来过。

7.3

The Magician of the Ivory Tower brought his latest invention for the Master Programmer to examine. The Magician wheeled a large black box into the Master's office while the Master waited in silence.

来自象牙塔的老学究请编程大师看看他的最新发明。大师默默等着,老学究推着一个大黑匣子进了大师的办公室。

"This is an integrated, distributed, general-purpose workstation," began the Magician, "ergonomically designed with a proprietary operating system, sixth generation languages, and multiple state of the art user interfaces. It took my assistants several hundred man years to construct. Is it not amazing?"

“这是一个集成的、分布式的通用工作站,”老学究开始说,“符合人体工程学的设计,专有操作系统,第六代语言,拥有多种最先进的用户界面。我的助手们总计花了几百年的人天来建造。了不起吧?”

The Master Programmer raised his eyebrows slightly. "It is indeed amazing," he said.

编程大师轻挑了下眉头,说:“的确很了不起。”

"Corporate Headquarters has commanded," continued the Magician, "that everyone use this workstation as a platform for new programs. Do you agree to this?"

“总部已经下令,”老学究继续说,“对于未来的新项目,所有人都得用这个工作站作为新的开发平台。你同意吗?”

"Certainly," replied the Master. "I will have it transported to the Data Center immediately!" And the Magician returned to his tower, well pleased.

“当然,”大师答道。“我马上把它送到数据中心去!”老学究满意地回到了象牙塔。

Several days later, a novice wandered into the office of the Master Programmer and said, "I cannot find the listing for my new program. Do you know where it might be?"

几天后,一位新手走进编程大师的办公室,说:“我找不着我新项目的文件了。你知道它在哪儿吗?”

"Yes," replied the Master, "the listings are stacked on the platform in the Data Center."

“知道,”大师回答,“它们在数据中心平台上放着呢。”

7.4

The Master Programmer moves from program to program without fear. No change in management can harm him. He will not be fired, even if the project is cancelled. Why is this? He is filled with Tao.

编程大师从一个项目转到另一个项目,心中丝毫不慌。任何管理上的变动都影响不了他。即使砍掉项目,上级也不会解雇他。为什么呢?因为他心中充满了道。

8. Hardware and Software 硬件和软件

Thus spake the Master Programmer:

编程大师如是说:

"Without the wind, the grass does not move. Without software hardware is useless."

“没有风,草就不会动;没有软件,硬件就没用。”

8.1

A novice asked the Master: "I perceive that one computer company is much larger than all others. It towers above its competition like a giant among dwarfs. Any one of its divisions could comprise an entire business. Why is this so?"

弟子问大师:“我发现有家计算机公司的规模堪称世界之最。它高高在上,就像矮人中的巨人。它的任何一个部门都可以组成一个完整的公司。为何会这样呢?”

The Master replied, "Why do you ask such foolish questions? That company is large because it is large. If it only made hardware, nobody would buy it. If it only made software, nobody would use it. If it only maintained systems, people would treat it like a servant. But because it combines all of these things, people think it one of the gods! By not seeking to strive, it conquers without effort."

大师答道:“你怎么会问这么蠢的问题?因为那家公司很大,所以它很大。如果它只生产硬件,没人会买它的东西。如果它只做软件,没人会用它的东西。如果它只维护系统,用户会把它当成仆人。但正因为它现在什么都做,人们会将它捧上神坛!因为选择不精益求精,它毫不费力地征服了一切。”

8.2

A Master Programmer passed a novice programmer one day.

一天,编程大师从一个弟子身边路过。

The Master noted the novice's preoccupation with a hand-held computer game.

大师发现弟子正专心致志地玩着掌上游戏机。

"Excuse me," he said, "may I examine it?"

“不好意思,”大师说,“可以让我看看你的游戏机吗?”

The novice bolted to attention and handed the device to the Master. "I see that the device claims to have three levels of play: Easy, Medium, and Hard," said the Master. "Yet every such device has another level of play, where the device seeks not to conquer the human, nor to be conquered by the human."

弟子抬起头,把机器递给了大师。“这游戏机上显示有三种等级的玩法:简单、中等和困难,”大师说,“但这种游戏机还有另一种隐藏玩法。在隐藏玩法下,机器既不会让玩家赢,也不会让玩家输。”

"Pray, Great Master," implored the novice, "how does one find this mysterious setting?"

“请告诉我,大师,”弟子恳求道,“这种神秘的玩法怎么进入?”

The Master dropped the device to the ground and crushed it with his heel. Suddenly the novice was enlightened.

大师把游戏机扔到地上,狠狠踩碎了它。一瞬间,弟子获得了启示。

【讨论】大师砸了游戏机后,弟子为什么突然开悟?悟了什么?

8.3

There was once a programmer who wrote software for personal computers. "Look at how well off I am here," he said to a mainframe programmer who came to visit. "I have my own operating system and file storage device. I do not have to share my resources with anyone. The software is self-consistent and easy-to-use. Why do you not quit your present job and join me here?"

从前,有位 PC 机程序员邀请一位大型机程序员来做客。“看看我这儿多好,”他对大型机程序员说,”我有自己的操作系统和文件存储设备,不需要和任何人共享资源。软件易用、彼此兼容。考虑辞职来和我一起干吗?”

The mainframe programmer then began to describe his system to his friend, saying, "The mainframe sits like an ancient Sage meditating in the midst of the Data Center. Its disk drives lie end-to-end like a great ocean of machinery. The software is as multifaceted as a diamond, and as convoluted as a primeval jungle. The programs, each unique, move through the system like a swift-flowing river. That is why I am happy where I am."

大型机程序员开始描述他的系统:“大型机就像一个古老的圣人,坐在数据中心的中央冥想。它的磁盘驱动器彼此相连,形成巨大的机器海洋。软件像钻石般多面、像原始森林般复杂。内部的程序,个个独一无二,运行起来如同一条湍急的河流,在系统中奔腾涌动。因此,我对我现在的工作很满意。”

The personal computer programmer, upon hearing this, fell silent. But the two programmers remained friends until the end of their days.

PC 机程序员听完陷入了沉默。不过,这两位程序员做了一辈子的朋友。

8.4

Hardware met Software on the road to Changtse. Software said: "You are Yin and I am Yang. If we travel together, we will become famous and earn vast sums of money." And so they set forth together, thinking to conquer the world.

在通往长江的路上,硬件和软件相遇了。软件说:“你是阴,我是阳。我们结伴而行,日后一定会出名、赚大钱。”于是他们一同出发,想要征服世界。

Presently, they met Firmware, who was dressed in tattered rags and hobbled along propped on a thorny stick. Firmware said to them: "The Tao lies beyond Yin and Yang. It is silent and still as a pool of water. It does not seek fame; therefore, nobody knows its presence. It does not seek fortune, for it is complete within itself. It exists beyond space and time."

不久,他们碰见了固件。固件衣衫褴褛,拄着一根拐杖,步履蹒跚地走着。固件对他们说:“道在阴阳之外。它似一潭止水,寂静无声。它不求闻达,所以没人知道它在哪儿。它不求财富,因为它自身已完整无缺。它独立于时空存在。”

Software and Hardware, ashamed, returned to their homes.

软件和硬件羞愧不已,回到了各自的家。

9. Epilogue 尾声

Thus spake the Master Programmer:

编程大师如是说:

"Time for you to leave."

“你该离开了。”

About

《编程之道》 (Tao of Programming, 1987) 最新中英双语版

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published