明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

編程之道(完全小趙譯版)上輯

[摘要]《編程之道》(小趙譯版) 藍(lán)森林 http://www.lslnet.com 2001年1月1日 21:39The Tao Of Programming —— 編程之道Translated By Geoffrey James[小趙(slimzhao@21cn.com)]翻譯整理說明:  本文是&l...
《編程之道》(小趙譯版) 藍(lán)森林 http://www.lslnet.com 2001年1月1日 21:39

The Tao Of Programming —— 編程之道


Translated By Geoffrey James

[小趙(slimzhao@21cn.com)]翻譯整理

說明:
  本文是<<編程之道>> <<編程之禪>><<計算機時代的寓言>>其中的一冊, 由小趙翻譯整理, 另外, 這三冊書的完整電子文檔由小趙根據(jù)市面上的<< 編程之道>>一書(包括了上面的三卷)錄入整理, 隨后將一起刊登(參見《編程之道》全譯文)。
Table of Contents 目錄
  • Book 1 -- The Silent Void
  • Book 2 -- The Ancient Masters
  • Book 3 -- Design
  • Book 4 -- Coding
  • Book 5 -- Maintenance
  • Book 6 -- Management
  • Book 7 -- Corporate Wisdom
  • Book 8 -- Hardware and Software
  • Book 9 -- Epilogue



  • The Silent Void
    Book One


    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."
    “當(dāng)你從我手中奪走水晶球時,就是你離開的時候了!

    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 greater, then the applications is great. The user is pleased and there is harmony in the world.
    如果道是完美的,那么操作系統(tǒng)就是完美的,如果操作系統(tǒng)是完美的,那么編譯囂就是完美的,如果編譯囂是完美的,那么應(yīng)用程序就是完美的,所以用戶心滿意足,整個世界因此和諧。
    The Tao of Programming flows far away and returns on the wind of morning.
    編程之道去如黃鶴來如晨風(fēng)。

    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.
    匯編器生編譯器,最后產(chǎn)生上萬種高級語言。
    Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao.
    不論多么的微不足道,每種語言都有它自己的目的,每種語言都表達(dá)了軟件的陰陽兩極。每種語言都各得其道。
    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 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.
    不懂編程之道的程序員常常把空間和時間消耗殆盡,得道的程序員則總是有足夠的空間和時間去完成編程任務(wù)。
    How could it be otherwise?
    否則會是什么樣呢?

    1.4

    The wise programmer is told about the Tao and follows it. The average programmer is told about the Tao and searches for it. The foolish programmer is told about the Tao and laughs at it.
    上士聞道,從而行之。中士聞道,謹(jǐn)而尋之。下士聞道,大笑之。
    If it were not for laughter, there would be no Tao.
    大笑不足為道。
    The highest sounds are the hardest to hear. Going forward is a way to retreat. Greater talent shows itself late in life. Even a perfect program still has bugs.
    希音不聞,進(jìn)即是退,大囂晚成。任何程序都有漏洞。

    The Ancient Masters
    Book Two


    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.
    遠(yuǎn)古時代的編程大師們高深莫測,我們不能揣測他們的所思所想,只能描述外表所見。
    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.
    他達(dá)明,如狐貍過水;機警,如戰(zhàn)場上的將軍;和善,如主婦款待客人;簡單,呆若木雞;混沌,如深淵之水。
    Who can tell the secrets of their hearts and minds?
    誰能道盡他們的所有?
    The answer exists only in the 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 companies? They behaved badly and were unconcerned with appearances. Their hair was long and unkempt and their clothes were wrinkled and old. They crashed out hospitality suites and they made rude noises during my presentation."
    一個大公司的程序員參加一個軟件會議后向他的主管匯報:“那些別的公司的程序員都是些什么樣的人呀?他們舉止不雅,不修邊幅,頭發(fā)蓬亂,衣服破舊,根本不熱情好客,還在我說話的時候亂嚷嚷。”
    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?"
    他的主管說:“我不應(yīng)該讓你參加這次會議,這些程序員生活在現(xiàn)實世界之外。他們認(rèn)為生活是可笑的,一場意外的偶然而已。他們來去自由,無所牽掛,他們只為他們的程序生活。為什么要用世俗的煩擾去擾亂他們呢?”
    "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?"
    一個初學(xué)者問主管經(jīng)理:“有一個程序員,他從來不預(yù)先設(shè)計,也不寫文檔,甚至不測試他的程序,但是知道他的人都認(rèn)為他是世界上最偉大的程序員,為什么呢?”
    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 the Tao."
    經(jīng)理說:“那個程序員掌握了道。他不需要預(yù)先進(jìn)行設(shè)計;系統(tǒng)崩潰時他也從不煩燥,只是接受發(fā)生的一切而不管發(fā)生的事是好是壞 。他不需要寫文檔,他從不顧及有沒有人看他寫的代碼。他也不需要進(jìn)行測試;他寫的每個程序都有一個完美的自我,平靜而優(yōu)雅,它們的目的不言自明。他已經(jīng)真正掌握了道的精髓!

    Design
    Book Three


    Thus spake the master programmer:
    編程大師如是說:
    "When program is being tested, it is too late to make design changes."

    “程序被測試時再去改變它的設(shè)計已經(jīng)太晚了!

    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:
    曾經(jīng)有一個人參加計算機展覽,每天他進(jìn)門時都對門衛(wèi)說:
    "I am a great thief, renowned for my feats of shoplifting. Be forewarned, for this trade show shall not escape unplundered."
    “先警告你,我是偷盜高手,我入室偷盜的本領(lǐng)聞名遐邇。這次展覽會也再劫難逃!

    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.
    警衛(wèi)因此大動干戈,因為里面有價值百萬的計算機設(shè)備,所以他牢牢盯緊了這個人,但是這個人只是從一個攤位逛到另一個攤位,一邊平靜地喃喃自語。
    When the man left, the guard took him aside and searched his clothes, but nothing was to be found.
    當(dāng)這個人離開時,警衛(wèi)搜了他的身,但是什么也沒有發(fā)現(xiàn)。
    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.
    展覽會的第二天,這個人又對警衛(wèi)說:“昨天我滿載而歸,但是今天我會收獲更大!彼跃l(wèi)更加小心地盯緊他,但是這樣做完全于事無補。
    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?"
    展覽會的最后一天,警衛(wèi)再也不能忍住他的好奇心了!靶⊥迪壬,”他說,“ 你說我驚慌不安,請告訴我,你到底偷了什么?”。
    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 the Tao before transcending structure."
    有一位編程大師,他寫非結(jié)構(gòu)化的程序,一位初學(xué)者刻意模仿他,也寫非結(jié)構(gòu)化的程序。當(dāng)他讓大師看他的進(jìn)步時,大師批評了他的非結(jié)構(gòu)化程序:“ 對一位編程大師合適的東西未必對一個初學(xué)者同樣合適,在超越結(jié)構(gòu)化之前,你必須理解編程之道!

    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?"
    ###有人問一位程序員,“一個財務(wù)軟件和一個操作系統(tǒng)哪個更容易設(shè)計?”
    "An operating system," replied the programmer.
    “是操作系統(tǒng)”,這位程序員回答說。
    The warlord uttered an exclamation of disbelief. "Surely an accounting package is trivial next to the complexity of an operating system," he said.
    此人大惑不解。他說:“顯然一個財務(wù)軟件比起操作系統(tǒng)來說其復(fù)雜性是微不足道的”。
    "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 my 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."
    程序員說:“不,設(shè)計財務(wù)軟件時,一個程序員必須成為持不同意見的用戶與計算機的一個中介,他必須了解用戶的操作習(xí)慣,報表要是什么形式,如何遵循稅法。相反,一個操作系統(tǒng)完全與這些外部的東西無關(guān)。設(shè)計操作系統(tǒng),程序員只需要達(dá)到自己的設(shè)想與機器之間的簡單的和諧。這就是為什么操作系統(tǒng)反而比財務(wù)軟件更容易設(shè)計!
    The warlord of Wu nodded and smiled. "That is all good and well, but which is easier to debug?"
    這些人笑著說!安诲e,但是哪一個更容易調(diào)試呢?”
    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?"
    一個項目經(jīng)理帶給編程大師一個項目的需求,然后問大師:“如果我給你5個程序員,要多少時間設(shè)計這個項目?”
    "It will take one year," said the master promptly.
    “一年”,大師說。
    "But we need this system immediately or even sooner! How long will it take it I assign ten programmers to it?"
    “但是我們等不了那么長時間,越快越好,如果10程序員呢?”
    The master programmer frowned. "In that case, it will take two years."
    大師皺了一下眉頭說:“那就要花2年”。
    "And what if I assign a hundred programmers to it?"
    “那,100年程序員呢?”
    The master programmer shrugged. "Then the design will never be completed," he said.
    大師聳了聳肩說:“那這個項目就永遠(yuǎn)完不成了。”

    Coding
    Book Four


    Thus spake the master programmer:
    編程大師如是說:
    "A well-written program is its own heaven;
    a poorly-written program is its own hell."
    “寫的好的程序是它自己的天堂,寫的不好的程序是它自己的地獄”