📄 thetaoofpg.htm
字号:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=GB2312">
<META NAME="WinPerTurn" CONTENT="Produced by Doc-2-Doc product, http://www.WinPerTurn.com">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://www.users.cloud9.net/~hennessy/tao.html -->
<HTML><HEAD><TITLE>The Tao of Programming</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GB2312">
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<CENTER>
<H1>The Tao Of Programming</H1><EM>Translated by Geoffrey James</EM>
<P>
<HR>
<P></CENTER>Table of Contents
<UL>
<LI>Book 1 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book1">The Silent
Void</A>
<LI>Book 2 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book2">The Ancient
Masters</A>
<LI>Book 3 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book3">Design</A>
<LI>Book 4 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book4">Coding</A>
<LI>Book 5 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book5">Maintenance</A>
<LI>Book 6 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book6">Management</A>
<LI>Book 7 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book7">Corporate
Wisdom</A>
<LI>Book 8 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book8">Hardware and
Software</A>
<LI>Book 9 -- <A
href="http://www.users.cloud9.net/~hennessy/tao.html#Book9">Epilogue</A>
</LI></UL>
<HR>
<CENTER>
<H3>Book 1 -- <A name=Book1>The Silent Void</A></H3>
<H4>Thus spake the master programmer:</H4>
<BLOCKQUOTE>"When you have learned to snatch the error code from the trap
frame, it will be time for you to
leave."</BLOCKQUOTE><STRONG>1.1</STRONG></CENTER>
<P>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.
<P>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 exists harmony in the world.
<P>The Tao of Programming flows far away and returns on the wind of morning.
<P>
<CENTER><STRONG>1.2</STRONG></CENTER>
<P>The Tao gave birth to machine language. Machine language gave birth to the
assembler.
<P>The assembler gave birth to the compiler. Now their are ten thousand
languages.
<P>Each language has its purpose, however humble. Each language expresses the
Yin and Yang of software. Each language has its place within the Tao.
<P>But do not program in COBOL if you can avoid it.
<P>
<CENTER><STRONG>1.3</STRONG></CENTER>
<P>In the beginning was the Tao. The Tao gave birth to Space and Time. Therefore
Space and Time are Yin and Yang of programming.
<P>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.
<P>How could it be otherwise?
<P>
<CENTER><STRONG>1.4</STRONG></CENTER>
<P>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.
<P>If it were not for laughter, there would be no Tao.
<P>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.
<P>
<HR>
<P>
<CENTER>
<H3>Book 2 -- <A name=Book2>The Ancient Masters</A></H3>
<H4>Thus spake the master programmer:</H4>
<BLOCKQUOTE>"After three days without programming, life becomes meaningless."
</BLOCKQUOTE><STRONG>2.1</STRONG></CENTER>
<P>The programmers of old were mysterious and profound. We cannot fathom their
thoughts, so all we do is describe their appearance.
<P>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.
<P>Who can tell the secrets of their hearts and minds?
<P>The answer exists only in Tao.
<P>
<CENTER><STRONG>2.2</STRONG></CENTER>
<P>Grand Master Turing once dreamed that he was a machine. When he awoke he
exclaimed:
<P>
<BLOCKQUOTE>"I don't know whether I am Turing dreaming that I am a machine, or
a machine dreaming that I am Turing!."</BLOCKQUOTE>
<P>
<CENTER><STRONG>2.3</STRONG></CENTER>
<P>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. There 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."
<P>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?
<P>They are alive within the Tao."
<P>
<CENTER><STRONG>2.4</STRONG></CENTER>
<P>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?"
<P>The Master replies: "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."
<P>
<HR>
<CENTER>
<H3>Book 3 -- <A name=Book3>Design</A></H3>
<H4>Thus spake the master programmer:</H4>
<BLOCKQUOTE>"When the program is being tested, it is too late to make design
changes."</BLOCKQUOTE>
<P><STRONG>3.1</STRONG></CENTER>
<P>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:
<P>
<BLOCKQUOTE>"I am a great thief, renowned for my feats of shoplifting. Be
forewarned, for this trade show shall not escape unplundered." </BLOCKQUOTE>
<P>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.
<P>When the man left, the guard took him aside and searched his clothes, but
nothing was to be found.
<P>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.
<P>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?"
<P>The man smiled. "I am stealing ideas," he said.
<P>
<CENTER><STRONG>3.2</STRONG></CENTER>
<P>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 the Tao before
transcending structure."
<P>
<CENTER><STRONG>3.3</STRONG></CENTER>
<P>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?"
<P>"An operating system," replied the programmer.
<P>The warlord uttered an exclamation of disbelief. "Surely an accounting
package is trivial next to the complexity of an operating system," he said.
<P>"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."
<P>The warlord of Wu nodded and smiled. "That is all good and well, but which is
easier to debug?"
<P>The programmer made no reply.
<P>
<CENTER><STRONG>3.4</STRONG></CENTER>
<P>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?"
<P>"It will take one year," said the master promptly.
<P>"But we need this system immediately or even sooner! How long will it take if
I assign ten programmers to it?"
<P>The master programmer frowned. "In that case, it will take two years."
<P>"And what if I assign a hundred programmers to it?"
<P>The master programmer shrugged. "Then the design will never be completed," he
said.
<P>
<CENTER>
<HR>
<H3>Book 4 -- <A name=Book4>Coding</A></H3>
<H4>Thus spake the master programmer:</H4>
<BLOCKQUOTE>"A well-written program is its own heaven; a poorly-written
program is its own hell."</BLOCKQUOTE><STRONG>4.1</STRONG></CENTER>
<P>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 or too much, neither needless loops nor
useless variables, neither lack of structure nor overwhelming rigidity.
<P>A program should follow the `Law of Least Astonishment'. What is this law? It
is simply that the program should always respond to the user in the way that
astonishes him least.
<P>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.
<P>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.
<P>
<CENTER><STRONG>4.2</STRONG></CENTER>
<P>A novice asked the master: "I have a program that sometime runs and sometimes
aborts. I have followed the rules of programming, yet I am totally baffled. What
is the reason for this?"
<P>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 prefect.
<P>The rules of programming are transitory; only Tao is eternal. Therefore you
must contemplate Tao before you receive enlightenment."
<P>"But how will I know when I have received enlightenment?" asked the novice.
<P>"Your program will then run correctly," replied the master.
<P>
<CENTER><STRONG>4.3</STRONG></CENTER>
<P>A master was explaining the nature of Tao of to one of his novices, "The Tao
is embodied in all software -- regardless of how insignificant," said the
master.
<P>"Is the Tao in a hand-held calculator?" asked the novice.
<P>"It is," came the reply.
<P>"Is the Tao in a video game?" continued the novice.
<P>"It is even in a video game," said the master.
<P>"And is the Tao in the DOS for a personal computer?"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -