Recently in TAO Category

Book Four Coding

Book Five Maintenance
第五篇 維護

Thus speak the master programmer:
"Though a program be three lines long, someday it have to be maintained. "
編程大師如是說:
"即使一個程序只有三行長, 總有一天它也不得不需要維護. "

5.1
A well-used door needs no oil on its hinges.
A swift-flowing stream does not grow stagnant.
Neither sound nor thoughts can travel through a vacuum.
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 that 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 agree to this.
Several years later, the manager retired. On the way to his retirement lunch, 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 the program, he discovered that it contained a screen editor, a set of generalized graphics routines, an artificial intelligence interface, but not the slightest mention 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?
難道一位好農民會漏掉他所種的一株莊稼嗎?
難道一位好老師會忽視哪怕是最差的學生嗎?
難道一位好父親會允許他唯一的孩子挨餓嗎?
難道一位好程序員會不願意維護他的程序嗎?


Book Four Coding
第四篇 編碼

Thus speak the master programmer:
"A well-written program is its own heaven; a poorly-written program 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 neither too litter 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 user in the way that astonishes him least. 
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 then run correctly." replied the master.
一位初學者問大師: "我有一個程序, 時靈時不靈. 我一直都遵循著編程的規則, 結果卻整個兒搞糊塗樂. 這是什麼原因呢?"
大師回答說: "因為你沒領悟道, 所以你迷惑不解. 只有傻瓜才會指望從人類身上看到理性的行為. 你又能指望一台人類制造的機器怎麼樣呢? 計算機模仿的是決定論, 只有道才是盡善盡美.
編程用的那些條條框框式的規則僅僅是曇花一現, 只有道才是永恆的. 因此, 在你受到道的啟發之前, 你必須沉思於道."
"但我怎樣才能知道我已經受到啟發樂呢?" 初學者問.
"當你的程序運行無誤時." 大師回答說.

4.3
A 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?" continued the novice.
"It is even in a video game," said the master.
"And is the Tao in the DOS for a personal computer?"
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 an 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 all 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 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 my  programmers were as wise!"
一位項目經理手下的一名程序員正在編寫軟件. 他的手指在鍵盤上飛舞著, 在程序的編譯過程中沒有出現任何錯誤的信息. 程序運行起來就像一陣和風.
"太好樂!" 經理高興地大叫樂起來, "你的技藝簡直完美無缺. "
"技藝? " 程序員說著便從他的終端機前轉過身來, "我遵循的是道 ---- 所有的技藝遠不能及! 當我剛開始編程時, 我眼前看見的是整個問題亂成一團. 三年之後, 我再也看不見這種一團糟的情形樂. 相反, 我用樂各種各樣的子程序. 但現在, 我什麼也看不見樂. 我的整個身心存在於一種無形的虛空離, 我的知覺是空蕩蕩的. 
我的精神隨其本能而動, 不需要計劃就能自由的工作. 總而言之, 是我的程序自己寫出樂自己. 誠然, 有時會有一些難題. 我看見那些難題向我走來, 於是我放慢樂速度, 默默地注視著它們. 然後我更改樂一行代碼, 那些問題就煙消雲散樂. 然後我完成程序的編譯. 我靜靜地坐著, 讓工作的歡愉遍布全身. 我閉上雙眼, 歇息片刻, 然後退出系統. "
經理說: '我希望所有的程序員都這麼聰明! "

Book Two The Ancient Masters

Book Three Design
第三篇 設計

Thus speak the master programmer:
"When the program is being tested, it is too late to make design changes."
編程大師如是說:
"當程序被測試時, 再修改設計方案就太遲樂."

3.1
There was once 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 ever better." So the guard watched him 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 space. Please enlighten me. What is it that you are stealing?"
The man smiled. "I am stealing ideas." he said.
曾經有一個人去參加一次計算機交易展會, 每天當他進入展館時, 都對門衛說: "我是個大盜, 我偷盜的本領是出樂名的. 事先警告你, 這次展示會也在劫難逃."
這番話讓門衛坐立不安, 因為裡邊有價值數百萬元的電腦設備, 於是他緊緊盯住這個人, 但這個人只是從一個展攤逛到另一個展攤, 嘴裡輕輕地哼著小曲.
當這個人出門時, 門衛把他拉到一邊, 搜查他的衣服, 但一無所獲.
第二天, 這個人又來樂, 並對著門衛囂張地嚷著: "我昨天滿載而歸, 但今天的收獲會更大." 於是門衛盯他盯得更緊樂, 但仍一無所獲.
在展示會的最後一天, 門衛再也控制不住自己的好奇心樂, "大盜先生, "門衛說, "我被你搞糊塗樂, 實在想不明白. 請告訴我, 你究竟在偷什麼?"
這個人笑樂. "我在偷想法."他說.

3.2
There was once 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."
曾經有一位編程大師, 喜歡編寫非結構化的程序. 一位初學者試圖模仿他, 也開始編寫非結構化的程序. 當這位初學者請大師評價他的進展時, 大師批評樂他的做法. 他說: "對一位編程高手合適的, 對初學者來說並不一定合適. 在超越結構化之前, 你必須先領悟道."

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 tax laws.
By contrast, an operating system is only limited by outward 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,"he said, "but which is easier to debug?"
The programmer made no reply.
曾經有一位程序員被派到Wu的軍機大臣手下工作. 軍機大臣問程序員:  "設計一個財務軟件包, 和設計一個操作系統, 哪一個更容易?"
"操作系統."程序員回答說.
軍機大臣立刻發出一種不信任的驚歎, "與一個復雜的操作系統相比, 一個財務軟件包簡直是小巫見大巫." 他說.
"並非如此,"程序員說, "在設計一個財務軟件包時, 編程人員是作為一個中介者在觀念各異的人們之間起作用的: 這個軟件必須如何操作, 它的報表必須是什麼形式, 它必須如何與稅法一致, 等等."
相反, 一個操作系統則不為其外觀所限制. 當設計一個操作系統 時, 編程人員只要在機器與人的思維之間尋找一種最簡單的和諧就可以樂. 這就是為什麼操作系統更容易設計."
軍機大臣點點頭, 笑樂. "說來也是. 但要想檢測和糾正其中的錯誤, 哪個更容易呢?"
程序員沒有回答.

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?"
"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 programmer to it?"
The master programmer frowned. "In that case, it will take two years."
"And what if I assign a hundred programmers to it?"
The master programmer shrugged. "Then the design will never be completed," he said.
一位經理到編程大師那裡, 交給他一份有關一個新應用程序的需求說明. 經理問編程大師: "如果我分配五個程序員給你, 你需要多久能設計好這個系統?"
"那將花費一年時間." 大師立刻回答.
"但我們馬上需要這個系統. 甚至要求更快! 如果我分配十個程序員給你, 你需要多長事件?"
大師皺樂皺眉頭, "那樣的話, 需要兩年."
"如果我分配一百個程序員給你怎麼樣?"
大師聳樂聳肩膀, "那麼這項設計將永遠無法完成." 他說.


Book Two The Ancient Masters
第二篇 古代的大師

Thus speak 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 can 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 a uncarved blocks of wood.
Opaque, like black pools in darkened caves.
Who can tell the secrets of their hearts and mind?
The answer exists only in Tao.
老一輩的程序員是神秘的, 深奧的. 我們沒法揣摩他們的想法, 我們所能做的只是描述一下他們的表象.
他們是清醒的, 就像一只游過水面的狐狸;
他們是警惕的, 就像一位戰場上將軍;
他們是友善的, 就像一位招待客人的女主人;
他們是簡單的, 就像未經刻鑿的木頭;
他們還是難以琢磨的, 就像黑暗的洞穴中漆黑的池水.
誰能說出他們心中的秘密?
答案只存在於道中.

2.2
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 computer companies? They behaved badly and were unconcerned with appearances. Their hair were long and unkempt and the clothes were wrinkled and old. They crashed our hospitality suite and they made rude noises during my presentation."
The manager said: "I should never sent you to the conference. Those programmers live beyond the physical world. They consider life absurd, and 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 who never designs, documents, or tests his programs. Yet all who know him consider him the one of the best programmers in the world. Why is this?"
The master replied: "The 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 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."
一個初學者問大師: "有位程序員, 從不構思, 編寫文檔或測試他的程序, 然而所有知道他的人都認為他是世界上最棒的程序員. 這是為什麼呢? "
大師回答說: "那個人掌握樂道. 他不需要事先進行構思, 當系統崩潰時, 他不會因此而悶悶不樂, 而是心平氣和的接受整個事實. 他還從編寫程序說明文檔的需要之中超脫樂出來, 不在意是否有人看他的編碼.
他也不需要進行測試, 他的每個程序的內在都完美無缺, 寧靜而優雅, 程序的用途也顯而易見.
的的確確, 他已經進入樂道的神奇境界."

Book One The Silent Void
第一篇 寂靜的空宇

Thus speak 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 don 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 flow far away and returns on the wind of morning.
在寂靜的空宇裡, 一種神奇的物質形成並誕生樂. 它立刻便靜止樂, 獨自守候著, 毫無動靜, 然而又處於永恆的運動之中. 它是所有程序的源頭, 我不知道它的名字, 所以我將它稱為編程之道.
如果此道是完美的, 那麼操作系統就是完美的; 如果操作系統是完美的, 那麼編譯程序就是完美的; 如果編譯程序是完美的, 那麼應用程序就是完美的. 用戶滿意之至----和諧便應運而生.
編程之道流逝遠去, 又乘著晨風而歸.

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 with the Tao.
But do not program in Cobol if you can avoid it.
此道產生樂機器語言, 機器語言又產生樂匯編語言.
匯編語言產生樂編譯程序, 如今有樂上萬種的語言.
每一種語言都有其各自的卑微用途. 每一種語言都表達出軟件的陰和陽. 每一種語言都在此道之中有其一席之地.
但是, 應盡量避免用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 Tao are always running out of time and space for their programs.
Programmers that comprehend 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 search 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.
The Tao is hidden beyond all understanding.
精明的編程者聽說樂此道, 並遵循它; 平庸的編程者聽說樂此道, 並尋覓它; 愚蠢的編程者聽說樂此道, 卻嘲笑它.
要不是因為有嘲笑, 道也就不復存在樂.
最高的聲音最難被聽見. 
前進也是一種倒退.
大器晚成.
即使一個完美的程序也仍然會有隱患.
道深藏不露, 難於理解.


About this Archive

This page is an archive of recent entries in the TAO category.

SDK is the previous category.

Tips is the next category.

Find recent content on the main index or look in the archives to find all content.