`
wss71104307
  • 浏览: 223078 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
阅读更多


                编程之道
    ————————————————————————


一 太虚幻境
二 古贤
三 设计
四 编码
五 维护
六 管理
七 集体智慧
八 硬件软件
九 尾声


————————————————————————


        *  太虚幻境
-----------------------------------


真正的程序员如是说:


“当你已学会从纷繁中去定位错误的代码,就是你动身的时候了。”


        1.1


    一种神奇的东西形成,诞生在虚无之中。独自不动地等待,它立刻静止,而又在永恒地运动。它是所有程序之源。我不知道它叫什么,所以我称之为编程之道。此道伟大则操作系统伟大,操作系统伟大则编译程序伟大,编译程序伟大则应用软件伟大,用户悦而世间协矣。
    编程之道流之远而归于晨风之中。


        1.2
    由此道而生机器语言,机器语言而生汇编程序,汇编程序而生编译程序,而今语言以万计。
    每种语言都有自己的用途,哪怕微贱。每种语言都表达了软件的阴与阳。每种语言都在此道中占有一席之地。
    然而不要用COBOL编程,如果你能避免。


        1.3
    本源在道。道生时空。故时空乃程序设计之阴阳也。不悟道者时空永不敷用,悟道的程序员总有足够的时间和空间去完成他们的目标。
    否则将何如?


        1.4
    智者闻此道而遵循之。庸者闻此道而探求之。愚者闻此道而讥笑之。苟无笑,亦无道矣。
    声至高则无闻,向前是一种退却,大器晚年成,纵然是完美的程序也仍然有漏洞。
—————————————————————————————————




    *  古贤
-----------------------------


真正的程序员如是说:


“三天不编程,生命就变得毫无意义。”


        2.1
    旧时的程序员神秘而渊博。我们无法看穿他们的思想,所以只能描述他们的外表。谨慎,像狐狸涉过水面。机警,像沙场上的将军。善良,像女主人迎接宾客。质朴,像未经雕琢的木块。莫测,像昏暗洞穴中黑色的池塘。
    谁知道他们心中的秘密?
    答案仅存在于此道之中。


        2.2
    图灵大师一次梦见自己是台机器。醒来后他宣称:“我不知道是我图灵做梦梦见自己是一台机器,还是一台机器做梦梦见我是图灵!”


        2.3


    一个从一家很大的电脑公司来的程序员参加了一个软件会议然后回去向经理报告说:“给其它公司工作的是哪种程序员呢?他们举止恶劣不修边幅。他们的头发长 而蓬乱,他们的衣服又旧又皱。他们破坏了宜人的气氛,他们在我发言时制造粗鲁的噪音。”经理说:“我不该派你去参加那次会议。那些程序员生活在尘世之外。 他们认为生活荒谬,是一次意外的相合。他们来去不受限制。没有顾虑,他们仅仅为了他们的程序生活。他们为什么要为世俗分心呢?”
    “他们生活在此道之中。”


        2.4


    新手向大师请教:“有一位程序员从不设计、写文档、或是测试他的程序。但所有认识他的人都认为他是世界上最好的程序员之一。为什么呢?”大师答道:“那 位程序员已然悟道。他已经不需要设计;系统崩溃时他不会气恼,而是毫不犹豫地去接受这一事实。他已经不需要文档;他不再计较是否有人看他的代码。他已经不 需要测试;他的每个程序自身都完美无瑕,清澈而雅致,目的自明。真的,他已然进入了此道的神奇之中。”
———————————————————————————————




        *  设计
-----------------------------


真正的程序员如是说:


“当程序到了测试阶段,再做设计上的改动就太晚了。”


        3.1


    曾有一个参观计算机交易展的人。每天进门时,他对看门的警卫说:“我是一个大盗,以入店行窃的技艺闻名。预先警告你,这个交易展无法逃过此劫。”这番话 强烈地惊扰了警卫,因为里面有数百万美元的计算机设备,所以他小心地监视这个人。但此人不过从一个摊位度到另一个摊位,自言自语地轻声嘀咕。他离开时,那 个警卫把他带到一边搜查他的衣服,然而一无所获。
    交易展的第二天,那人又来了,并且斥责那个警卫说:“我昨天带走了大量战利品,不过今天会更好。”所以那个警卫更加注意地监视他,然而毫无用处。
    交易展的最后一天,那个警卫无法再抑制自己的好奇心了。“小偷先生,”他说,“我太难理解了,我无法平静下来。请开导我。您到底偷了什么?”
    那人微微一笑,“我偷的是思想。”他说。


        3.2
    曾有一位编程大师写些非结构化的程序。一位初学者,试图模仿他,也开始写非结构化的程序。当那个新手请那位大师评价他的进步时,大师批评他写非结构化的程序,说:“对老手合适的不一定对新手合适。你必须先悟道才能超越结构。”


        3.3
    曾有一位程序员被叫到西联电报公司首脑那儿,首脑问:“哪个设计起来容易些:会计组件还是操作系统?”“操作系统。”程序员回答。
    首脑发出一声怀疑的惊叹。“显然会计组件比起操作系统的复杂性来说是微不足道的。”他说。
    “并非如此,”程序员说,“设计会计组件时,程序员像一个各有不同想法的人们的仲裁者:它必须怎样运转,它的报表必须怎样出现,还有它必须怎样符合税 制。相反,操作系统却不受外界表象的限制。设计操作系统时,程序员寻求机器与思想间最简单的融合。这就是操作系统设计起来更简单的原因。”
    西联电报公司的首脑点头微笑。“很好,但哪个更容易调试呢?”
    程序员不做回答。


        3.4
    一位经理到系统分析员那儿给他看了一个新软件的需求文档。经理问系统分析员:“如果我派五个程序员,设计这一系统需要多长时间?”“需要一年。”系统分析员立刻回答。
    “但我们马上就要这个系统,如果不是更急的话!如果我派十个程序员需要多长时间?”
    系统分析员皱皱眉。“那样的话,需要两年。”
    “那我派一百个程序员呢?”
    系统分析员耸耸肩。“那么设计就永远完不成了。”他说。
—————————————————————————————————




        *  编码
-----------------------------


真正的程序员如是说:


“写得好的程序是它自己的天堂;
  写得差的程序是它自己的地狱。”


        4.1


    程序应该轻便灵活,子程序连接得像一串珍珠。程序的精神和意图应贯穿始终。既不能太少也不能太多,既没有不必要的循环也没有无用的变量,既不乏体系也不 过于死板。程序应遵循最少惊讶原则。这是什么原则呢?它不过是说程序应该总是以使之惊讶程度最小的方式来响应用户。
    一个程序,无论多么复杂,应该产生一个独立单元的效果。程序更该为其内部的逻辑所指引,而不是外部表现。/* 不敢苟同 */
    如果程序没有满足这些要求,它将处于混乱无序的状态之中。改正的唯一途径只有重编。


        4.2
    新手向大师请教:“我有一个程序有时正常运行有时异常中断。我遵守了编程的规则,但我彻底迷惑了。这是什么原因呢?”大师回答:“你糊涂了是因为你没有 悟道。只有傻瓜才指望他同道的人举止总是合理。你为什么去指望一台人类制造的机器呢?计算机模拟决定论;只有道是完美的。
    “编程的规则是暂时的;只有道是永恒的。因此你必须先求道才能得到启迪。”
    “但是我怎样知道我已经得到启迪了呢?”新手问。
    “你的程序就将正确运行了。”大师回答。


        4.3
    一位大师正向自己的一个学生解释道的本性,“道体现于一切软件之中——不管多么的微不足道。”大师说。“此道存在于手提计算器中吗?”学生问。
    “存在”是回答。
    “此道存在于视频游戏中吗?”
    “道也存在于视频游戏中。”
    “道也存在于个人电脑的磁盘操作系统中吗?”
    大师咳嗽一声稍稍移动了一下位置,“今天的课就到这儿吧。”他说。


        4.4
    %#王安电脑公司的程序员正在编软件。他的手指在键盘上飞舞。程序编译得无一处错误信息,程序运行得像一阵轻风。“好极了!”%#董事长惊叫,“你的技术无可挑剔!”
    “技术?”程序员说,从他的终端前转过身来,“我遵循的是道——超过所有的技术。我刚开始编程时可以见到我面前的整个程序在一个块里。三年后我再也看不 见这个块了。取而代之的是,我用了子程序。但现在我什么也看不见了。我整个生命存在于无形的虚无之中。我的感觉是空的。我的灵魂,没有任何计划外工作的束 缚,随它自己的本能行事。简而言之,我的程序是它自己编成的。的确,有时是有些棘手的问题。我看见它们来了,我慢下来,默默地观察。接着我改了一行独立的 代码,难题就如轻烟般消失于无形了。于是我编译那程序。我静静地坐着,让工作的喜悦充满我的生命。我闭一会儿眼然后登出。”
    %#王安董事长说:“愿我所有的程序员都那么贤明!”
—————————————————————————————————




        *  维护
-----------------------------


真正的程序员如是说:


“尽管程序可能只有三行长,有一天它将不得不受到维护。”


        5.1
    户枢不蠹。流水不腐。声音和思想都不能在真空中传播。软件不用就会生锈。
    此皆大神秘也。


        5.2
    经理问一位程序员他正在编的程序多长时间才能编完。“我明天能编完。”程序员立即回答。“我认为你这是不切实际,”经理说,“说实话,得多长时间?”
    程序员略一思索。“我有一些功能想加进去。这将花费至少两周。”他最终说。
    “连这都期望过高了,”经理坚持,“程序完成时再来告诉我,我会满意的。”
    程序员同意了。
    几年过去了,那位经理退休了。在赴告别宴的路上,他发现那个程序员在他的终端前睡着了。他编了一整夜。


        5.3
    有一次一个刚来的程序员接了编一个简单的财务组件的活儿。那新手疯狂地干了好几天,但当他的领导看了他的程序后,发现它包含了一个屏幕编辑器,一系列普通的图形程序和人工智能的界面,但没有丝毫提及有关财务的任何东西。
    领导问及此事时,那新手愤怒了。“别这么不耐烦,”他说,“我最后会把财务的东东放进去的。”


        5.4
    好农民会忽视他种的庄稼吗?好老师能不注意最谦逊的学生吗?好父亲会允许任何一个孩子饿死吗?好程序员会拒绝维护他的代码吗?
—————————————————————————————————




    * 管理
-----------------------------


真正的程序员如是说:


“多一些编程人员少一些管理人员吧,那么都将是高效的。”


        6.1
    当管理人员在开没完没了的会议时,程序员们在编游戏。当会计人员在谈论季利润时,开发经费将被削减。当高级科学家讲到蓝天时,云会蜂拥而来。真的,这不是编程之道。
    当管理人员委以项目时,游戏程序被忽视了。当会计人员作长期计划时,协调和秩序将恢复。当高级科学家忙于手头的问题时,问题很快就会迎刃而解。
    真的,这是编程之道。


        6.2
    为什么程序员没有效率?因为他们的时间浪费在了会议上。为什么程序员难以驾御?因为管理干涉得太多了。
    为什么程序员一个接一个的辞职?因为他们已才思枯竭。
    在不良的管理下工作后,他们不会觉得做的有所价值。


        6.3
    一个经理就要被解雇了,但他手下的一个程序员编了个流行而畅销的新程序。结果,那个经理保住了他的工作。那个经理想给这位程序员一笔奖金,但程序员拒绝了,他说:“我编这个程序是因为它有趣,因而我不想要任何酬劳。”
    那个经理,听了这些话,评论道:“这位程序员,虽然地位卑微,对一个雇员的职责却理解得很恰当。让我们提拔他作尊贵的管理顾问吧!”
    得知这些时,程序员又一次拒绝了,说:“我存在故我能编程。如果我被提升了,我将无所事事只是浪费每个人的时间。我可以走了吗?我有个程序要编。”


        6.4
    一位经理到他的程序员那儿对他们说:“出于对你们工作时间的尊重,要求你们早上九点到下午五点下班。”对此,所有人都愤怒起来几个立刻就辞职了。所以经 理说:“好,那样的话你们可以调整你们的工作时间,只要你们能够按时完成工程。”现在满意了的程序员们,开始中午来然后工作到凌晨。
—————————————————————————————————




        * 集体智慧
-----------------------------


真正的程序员如是说:


“你可以给一个公司的行政人员演示一个程序,但你无法让他成为一位计算机学者。”


        7.1
    一位新手问大师说;“东方有一个庞大的树形结构,人称‘合作总部’。副总裁和会计师们使它形态臃肿。它发表一群备忘录,每个都写着:“走,从此!”或“ 走,这里!”谁也不知道是什么意思。每年都有新名字加到分支机构上,但都没有任何效用。这样一个不自然的实体怎能得以存在呢?”大师回答:“你认识到了这 种广袤的结构并为其没有合理的用途所困扰。你不能把它没完没了的逻辑怪圈当成一种消遣吗?你不会去享受在它庇护的分支下无忧无虑编程的轻松吗?你为什么要 为它的无用而烦恼呢?”


        7.2
    东方有大鱼,谓之鲲。它变成鹏,翅膀云一般弥漫在天空。当此鸟环游大地,它带来了合作总部的讯息。此讯落于程序员之中,如同海鸥在海滩上作它的标记。然 后此鸟乘翅,青天作背,归之。新者惊而望鹏,以其无法理解之。庸者恐鹏之来,以其惧其讯也。老者继续工作于其终端前,以其不知鹏之来去也。
        7.3
    象牙塔里的魔术师带来了他供系统分析员检查之用的最新发明。魔术师转动着一个巨大的黑盒子进入分析员的办公室,当时,分析员正静静地等待。“这是一个综 合的、分布式的、多用途的工作站,”魔术师开始他的话,“生物工程学设计的个人的操作系统。第六代语言,多态的艺术用户界面。我的助手花了几百人年才构建 出来。是不是很惊人呢?”
    分析员轻轻扬了一下眉毛。“的确惊人。”他说。
    “合作总部已经下令,”魔术师继续他的话,“每个人都要用这个工作站作为新程序的平台。你同意吗?”
    “当然,”分析员回答说,“我立刻把它传送到数据中心去!”魔术师回到他的塔里,欣喜非常。
    几天以后,一个新手逛进了系统分析员的办公室说,“我找不到我新程序的清单了。您知道它会在哪儿吗?”
    “知道,”分析员答道,“清单堆在数据中心的平台上了。”
        7.4
    编程大师来往于程序之间而无惧也。没有什么管理上的变化能伤害他,纵使是工程被取消也无济于事。何也?为道所充斥矣。
—————————————————————————————————




        * 硬件软件
-----------------------------


真正的程序员如是说:


“没有风,草就不会动。
没有软件,硬件就没有价值。”
/*  彼无风兮,草不动兮。无软件兮,硬件废矣。*/


        8.1
    新手问大师:“我感到一家电脑公司比所有其它的公司都大得多。它在竞争中高高在上,像巨人站在侏儒之中。它任何的一个分公司都能做完整的交易。何哉?” 大师答道:“你怎么问这么傻的问题?那家公司大是因为它如此之大。如果它只做硬件,就没人会买。如果它只维护系统,人们就会像佣人一样对待它。但因为它联 合了所有这些东西,人们就认为它是一尊神!不靠探索奋斗,它毫不费劲儿的战胜了。”


        8.2
    一天,编程大师从一位新手身边经过。大师注意到新手对一个掌上电脑游戏的全神贯注。“打搅了,”他说,“我能看看它吗?”新手转移了注意力并把设备递给 了大师。“我看到这设备声称有三个游戏等级:易、中和难”,大师说。“不过每个这种设备都有另一种游戏等级,在那儿设备不求战胜人类,也不求为人类所战 胜。”
    “谢谢您喽,尊敬的大师,”新手恳求道,“怎么能找到这么神奇的设置啊?”
    大师把设备摔到地上并把它踩碎在脚下。新手一下子受到了启迪。


        8.3
    从前有一个做微处理器的程序员。“看看我在这儿多么爽啊,”他对一位来访的大型机程序员说,“我有我自己的操作系统和文件存储设备。我不必把我的资源跟 任何人分享。软件自成一体又易于使用。你为什么不辞去现在的工作而来这儿与我共事呢?”那位大型机程序员于是开始向他的朋友描述他的系统,说:“主机像一 位古圣人一样坐着,在数据中心的中央思考。它的磁盘驱动器首尾相接地平放着像机械的大海。软件有多个小面像一颗钻石,像原始丛林一般旋绕。程序,各自独特 地,通过系统像湍急的小溪。那就是为什么我乐意在这儿的原因。”
    微机程序员,听到了这些,不作声了。但这两个程序员的友谊一直持续到了他们的最后一天。


        8.4
    硬件在通往章子峰的路上遇到了软件。软件说:“你是阴而我是阳。如果我们一道将一举成名还能赚大笔的钱。”因此这一对儿就一起出发,想征服世界。不久, 他们遇到了固件,他衣衫褴褛,拄着一根带刺的木棍蹒跚。固件对他们说:“道位于阴阳之外。它寂静得像一池水。它不求名,因而没有人知道它的存在。它不求 利,因为它全部都在它自身之中。它存在于时空之外。”
    软件和硬件,愧而归之。
—————————————————————————————————




        * 尾声
-----------------------------


真正的程序员如是说:


“是你动身的时候了。”
—————————————————————————————————

 


The Tao Of Programming
Translated By Geoffrey James
Transcribed By Seth Robertson
HTMLified By Neil Enns


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."
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.


The Tao of Programming flows 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 within the Tao.


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


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 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.
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.




--------------------------------------------------------------------------------


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.
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 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."
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 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."




--------------------------------------------------------------------------------


Design
Book Three
Thus spake the master programmer:
"When 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 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 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."


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?"
"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?"


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.






--------------------------------------------------------------------------------


Coding
Book Four
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 strings 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 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 the 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 the Tao is perfect.


The rules of programming are transitory; only the Tao is eternal. Therefore you must contemplate the 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 the 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.


4.4
Price 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 Price exclaimed, "Your technique is faultless!"


"Technique?" said the programmer, turning from his terminal, "What I follow is the Tao -- beyond all technique. When I first began to program I would see before me the whole program 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."


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




Mainteance
Book Five
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 steam does no grow stagnant.  // stream
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 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 slated, 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 his program, he discovered that it contained a screen editor, a set of generalized graphics routines, and 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 the financial stuff in 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?






--------------------------------------------------------------------------------


Management
Book Six
Thus spake the master programmer:
"Let the programmer be many and the managers few -- then all will be productive."
6.1
When managers hold endless meetings, the programmers write games. When accountants talk 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 invented 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's 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'm working on."


6.4
A manger 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 a noon and work to the wee hours of the morning.






--------------------------------------------------------------------------------


Corporate Wisdom
Book Seven
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 replies: "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 winds are like clouds filling the sky. When this bird moves across the land, it brings a message from Corporate Headquarters. This message it 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, for he does not know 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 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 canceled. Why is this? He is filled with the Tao.




--------------------------------------------------------------------------------


Hardware and Software
Book Eight
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 so large. If it only made hardware, nobody would buy 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 under foot. And suddenly the novice was enlightened.


8.3
There was once a programmer who worked upon microprocessors. "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?"
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 a multi-faceted 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 microcomputer programmer, upon hearing this, fell silent. But the two programmers remained friends until the end of their days.


8.4
Hardware met Software on the road to Changtse. Software said: "You are the Yin and I am the Yang. If we travel together we will become famous and earn vast sums of money." And so the pair 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 seeks fortune, for it is complete within itself. It exists beyond space and time."


Software and Hardware, ashamed, returned to their homes.






--------------------------------------------------------------------------------


Epilogue
Book Nine
Thus spake the master programmer:
"Time for you to leave."


--------------------------------------------------------------------------------


Neil Enns, ennsnr@brandonU.ca

分享到:
评论

相关推荐

    编程之道.pdf 编程之道

    《编程之道》是一本深入探讨编程艺术和技术的书籍,它涵盖了编程实践的各个方面,旨在帮助读者提升编程技能,理解编程的本质,并掌握编程之道。书名中的“道”寓意着编程不仅仅是技术的堆砌,更是思想的体现和智慧的...

    卓越编程之道 - 卷2.rar

    《卓越编程之道 - 卷2》是一本深受程序员喜爱的编程指南,主要聚焦于底层编程思维和高级语言的编写。作者Randall Hyde以其独特的视角和深入浅出的讲解,为读者揭示了编程世界的奥秘。这本书是《Write Great Code》...

    vc++编程之道配书光盘

    《VC++编程之道》是一本深入探讨Visual C++编程技术的专业书籍,其配书光盘包含了大量的源代码示例,旨在帮助读者更好地理解和实践书中所讲解的编程概念和技术。光盘中的"MR"可能代表“Master Resource”,暗示了这...

    洪恩JAVA编程之道

    《洪恩JAVA编程之道》是一本深入探讨Java编程技术的书籍,其随碟代码提供了丰富的实践示例,帮助读者巩固理论知识,提升编程技能。在Java编程的世界里,理解和掌握这些知识点至关重要,因为它们构成了Java程序员的...

    计算机编程之道(编程之道)

    《编程之道》是一本深入探讨计算机编程艺术与实践的书籍,其核心理念在于教导读者如何以更为高效、优雅的方式编写代码。"编程之道"这一标签,暗示了书中的内容不仅涵盖了基础的编程语法和概念,更注重编程思维的培养...

    安全编程之道

    《安全编程之道》是一本专注于C和C++编程语言的安全编程指南,旨在帮助开发者提升代码质量和安全性,防止软件漏洞导致的潜在威胁。本书基于“program secure”理念,深入探讨了如何在开发过程中实施最佳安全实践。 ...

    Visual C++编程之道 光盘 代码 C++

    《Visual C++编程之道》是一本深入探讨C++编程在Visual Studio环境下的专业书籍,它涵盖了从基础到高级的各种主题,旨在帮助读者掌握利用Visual C++进行高效开发的技巧和最佳实践。书中不仅讲解了C++语言的核心概念...

    《编程之道》

    《编程之道》是一本深入探讨编程艺术和技术的书籍,提供了中英文双语对照,便于读者理解和学习。在本文中,我们将围绕源码分析和工具应用这两个核心标签,深入挖掘书中所涵盖的重要知识点。 首先,源码是编程的核心...

    编程之道ASP数据库编程入门

    编程之道ASP数据库编程入门

    编程之道~~

    ### 编程之道 #### 书籍概述 《编程之道》是一部深入探讨编程艺术与哲学的著作,由美国作家Geoffrey James撰写。该书通过一系列短小精悍的故事和寓言,结合东方哲学思想,尤其是道家思想,来阐述编程的本质、...

    程序员 编程之道 中英双文

    《编程之道》是一本专为程序员打造的书籍,它深入探讨了编程世界中的哲学与实践,旨在提升程序员的技能和理解。这本书不仅涵盖了技术层面的知识,更包含了如何成为一名优秀的程序员所必需的生活态度和思维方式。书中...

    编程之道(Geoffrey James)

    《编程之道》是著名作者Geoffrey James的一部著作,主要探讨了如何在软件开发领域中成为一名杰出的程序员,以及如何正确理解和应对这个行业的各种挑战。这本书为对计算机编程充满热情的人提供了许多实用的指导原则和...

    Qtopia编程之道

    《Qtopia编程之道》是一本深入探讨Qtopia平台编程技术的专业书籍,旨在帮助开发者掌握这一独特的嵌入式Linux应用程序框架。Qtopia,全称为Qt for Embedded Linux,是 Trolltech 公司(现为The Qt Company)开发的一...

    C语言编程之道

    C语言编程之道,人民邮电出版社,刘彬彬等人

    《编程之道》全本完整版

    《编程之道》是一本深入探讨编程艺术和技术的书籍,它旨在揭示编程的哲学与实践,帮助程序员提升技能,实现从技术熟练工到编程大师的转变。书中的内容可能涵盖广泛,包括但不限于编程语言原理、算法设计、软件工程、...

    编程之道全本

    编程之道 编程之道全本

    编程之道.txt

    ### 编程之道知识点解析 #### 一、引言与哲思 - **另一种眼光**:本书《编程之道》从一种独特的视角审视编程,旨在帮助读者深入理解编程的本质及其背后的哲学思考。 - **哲学与技术的结合**:本书不仅探讨了编程...

Global site tag (gtag.js) - Google Analytics