From: Subject: The Tao Of Programming Date: Sun, 18 Sep 2005 08:38:28 -0400 MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_NextPart_000_0000_01C5BC2C.57EB79C0"; type="text/html" X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C5BC2C.57EB79C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.canonical.org/~kragen/tao-of-programming.html The Tao Of Programming

The Tao Of Programming

Translated by Geoffrey James=20

Transcribed by Duke Hillard=20

Transmitted by Anupam Trivedi, Sajitha Tampi, and Meghshyam Jagannath =

Re-html-ized and edited by Kragen Sittler=20

Last modified 1996-04-10 or earlier=20


Table of Contents

  1. T= he=20 Silent Void=20
  2. T= he=20 Ancient Masters=20
  3. D= esign=20
  4. C= oding=20
  5. M= aintenance=20
  6. M= anagement=20
  7. C= orporate=20 Wisdom=20
  8. H= ardware=20 and Software=20
  9. E= pilogue=20

Book 1 - The Silent Void

Thus spake the master programmer:=20

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

1.1

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

If the Tao is great, then the operating system is great. If the = operating=20 system is great, then the compiler is great. If the compiler is great, = then the=20 application is great. The user is pleased and there exists harmony in = the world.=20

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

1.2

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

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

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

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

1.3

In the beginning was the Tao. The Tao gave birth to Space and Time. = Therefore=20 Space and Time are Yin and Yang of programming.=20

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

How could it be otherwise?=20

1.4

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

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

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=20 still has bugs.


Book 2 - The Ancient Masters

Thus spake the master programmer:=20

``After three days without programming, life becomes meaningless.''=20

2.1

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

Aware, like a fox crossing the water. Alert, like a general on the=20 battlefield. Kind, like a hostess greeting her guests. Simple, like = uncarved=20 blocks of wood. Opaque, like black pools in darkened caves.=20

Who can tell the secrets of their hearts and minds?=20

The answer exists only in Tao.=20

2.2

Grand Master Turing once dreamed that he was a machine. When he awoke = he=20 exclaimed:=20

``I don't know whether I am Turing dreaming that I am a = machine,=20 or a machine dreaming that I am Turing!''

2.3

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

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

``They are alive within the Tao.''=20

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=20 best programmers in the world. Why is this?''=20

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


Book 3 - Design

Thus spake the master programmer:=20

``When the program is being tested, it is too late to make design = changes.''=20

3.1

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

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

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

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

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

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

The man smiled. ``I am stealing ideas,'' he said.=20

3.2

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

3.3

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

``An operating system,'' replied the programmer.=20

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

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

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

The programmer made no reply.=20

3.4

A manager went to the master programmer and showed him the = requirements=20 document for a new application. The manager asked the master: ``How long = will it=20 take to design this system if I assign five programmers to it?''=20

``It will take one year,'' said the master promptly.=20

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

The master programmer frowned. ``In that case, it will take two = years.''=20

``And what if I assign a hundred programmers to it?''=20

The master programmer shrugged. ``Then the design will never be = completed,''=20 he said.=20


Book 4 - Coding

Thus spake the master programmer:=20

``A well-written program is its own heaven; a poorly-written program = is its=20 own hell.''=20

4.1

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

A program should follow the `Law of Least Astonishment'. What is this = law? It=20 is simply that the program should always respond to the user in the way = that=20 astonishes him least.=20

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

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

4.2

A novice asked the master: ``I have a program that sometime runs and=20 sometimes aborts. I have followed the rules of programming, yet I am = totally=20 baffled. What is the reason for this?''=20

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

``The rules of programming are transitory; only Tao is eternal. = Therefore you=20 must contemplate Tao before you receive enlightenment.''=20

``But how will I know when I have received enlightenment?'' asked the = novice.=20

``Your program will then run correctly,'' replied the master.=20

4.3

A master was explaining the nature of Tao of to one of his novices. = ``The Tao=20 is embodied in all software - regardless of how insignificant,'' said = the=20 master.=20

``Is the Tao in a hand-held calculator?'' asked the novice.=20

``It is,'' came the reply.=20

``Is the Tao in a video game?'' continued the novice.=20

``It is even in a video game,'' said the master.=20

``And is the Tao in the DOS for a personal computer?''=20

The master coughed and shifted his position slightly. ``The lesson is = over=20 for today,'' he said.=20

4.4

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

``Excellent!'' the Prince exclaimed, ``Your technique is faultless!'' =

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

Prince Wang said, ``Would that all of my programmers were as wise!''=20


Book 5 - Maintenance

Thus spake the master programmer:=20

``Though a program be but three lines long, someday it will have to = be=20 maintained.''=20

5.1

A well-used door needs no oil on its hinges.
A swift-flowing = stream does=20 not grow stagnant.
Neither sound nor thoughts can travel through a = vacuum.=20
Software rots if not used.

These are great mysteries.=20

5.2

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

``I think you are being unrealistic,'' said the manager, = ``Truthfully, how=20 long will it take?''=20

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

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

The programmer agreed to this.=20

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

5.3

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

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

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

5.4

Does a good farmer neglect a crop he has planted?
Does a good = teacher=20 overlook even the most humble student?
Does a good father allow a = single=20 child to starve?
Does a good programmer refuse to maintain his code? =


Book 6 - Management

Thus spake the master programmer:=20

``Let the programmers be many and the managers few - then all will be = productive.''=20

6.1

When managers hold endless meetings, the programmers write games. = When=20 accountants talk of quarterly profits, the development budget is about = to be=20 cut. When senior scientists talk blue sky, the clouds are about to roll = in.=20

Truly, this is not the Tao of Programming.=20

When managers make commitments, game programs are ignored. When = accountants=20 make long-range plans, harmony and order are about to be restored. When = senior=20 scientists address the problems at hand, the problems will soon be = solved.=20

Truly, this is the Tao of Programming.=20

6.2

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

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

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

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

6.3

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

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

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

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

6.4

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

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


Book 7 - Corporate Wisdom

Thus spake the master programmer:=20

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

7.1

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

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

7.2

In the east there is a shark which is larger than all other fish. It = changes=20 into a bird whose wings are like clouds filling the sky. When this bird = moves=20 across the land, it brings a message from Corporate Headquarters. This = message=20 it drops into the midst of the programmers, like a seagull making its = mark upon=20 the beach. Then the bird mounts on the wind and, with the blue sky at = its back,=20 returns home.=20

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

7.3

The Magician of the Ivory Tower brought his latest invention for the = master=20 programmer to examine. The magician wheeled a large black box into the = master's=20 office while the master waited in silence.=20

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

The master raised his eyebrows slightly. ``It is indeed amazing,'' he = said.=20

``Corporate Headquarters has commanded,'' continued the magician, = ``that=20 everyone use this workstation as a platform for new programs. Do you = agree to=20 this?''=20

``Certainly,'' replied the master, ``I will have it transported to = the data=20 center immediately!'' And the magician returned to his tower, well = pleased.=20

Several days later, a novice wandered into the office of the master=20 programmer and said, ``I cannot find the listing for my new program. Do = you know=20 where it might be?''=20

``Yes,'' replied the master, ``the listings are stacked on the = platform in=20 the data center.''=20

7.4

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


Book 8 - Hardware and = Software

Thus spake the master programmer:=20

``Without the wind, the grass does not move. Without software, = hardware is=20 useless.''=20

8.1

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

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

8.2

A master programmer passed a novice programmer one day. The master = noted the=20 novice's preoccupation with a hand-held computer game. ``Excuse me,'' he = said,=20 ``may I examine it?''=20

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

``Pray, great master,'' implored the novice, ``how does one find this = mysterious setting?''=20

The master dropped the device to the ground and crushed it underfoot. = And=20 suddenly the novice was enlightened.=20

8.3

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

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

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

8.4

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

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

Software and Hardware, ashamed, returned to their homes.=20


Book 9 - Epilogue

Thus spake the master programmer:=20

``It is time for you to leave.''=20


------=_NextPart_000_0000_01C5BC2C.57EB79C0 Content-Type: text/css; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.canonical.org/~kragen/style.css .explanation { PADDING-RIGHT: 1ex; PADDING-LEFT: 1ex; BACKGROUND: #f0f0f0; = PADDING-BOTTOM: 1ex; PADDING-TOP: 1ex } BODY { BACKGROUND-POSITION: center 50%; BACKGROUND-ATTACHMENT: fixed; = BACKGROUND-IMAGE: url(http://pobox.com/~kragen/kjlogobg.png); = BACKGROUND-REPEAT: no-repeat } ------=_NextPart_000_0000_01C5BC2C.57EB79C0--