《The Tao Of Programming》——编程之道

来源:互联网 发布:数据库常用select语句 编辑:程序博客网 时间:2024/05/17 01:55

这本书居然可以结合老子的《南华经》、庄子的《庄子》,以及《论文》来谈论编程,编程似乎成为了如此文艺的东西,深不可测。后来作者还写了《编程之禅》、《计算机寓言——信息时代的启示》。如此有逼格的东西,下面摘录几句,有点儿意思。

The Silent Void
“When you have learned to snatch the error code from the trap frame, it will be time for you to leave.”
“当你从我手中夺走水晶球时,就是你离开的时候了。”

The Tao of Programming flows far away and returns on the wind of morning.
编程之道去如黄鹤来如晨风。

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.
上士闻道,从而行之。中士闻道,谨而寻之。下士闻道,大笑之。

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
“After three days without programming, life becomes meaningless.”
三日不编程,食肉无味。

“I don’t know whether I am Turing dreaming that I am a machine,
or a machine dreaming that I am Turing!”
“我不知道是图灵梦见自己变成机器还是机器梦见自己变成图灵。”

Design
“When program is being tested, it is too late to make design changes.”
“程序被测试时再去改变它的设计已经太晚了。”

Coding
“A well-written program is its own heaven;
a poorly-written program is its own hell.”
“写的好的程序是它自己的天堂,写的不好的程序是它自己的地狱”

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.
如果一个程序不能满足所要的需求,它就会处于混乱无序的状态中。唯一的出路就是重写这个程序。

“The Tao is embodied in all software – regardless of how insignificant,” said the master.
大师说:“道存在于任何软件中--无论是多么没有意义的软件”。

Mainteance
A well-used door needs no oil on its hinges.
A swift-flowing steam does no grow stagnant.
Neither sound nor thoughts can travel through a vacuum.
Software rots if not used.
经常使用的门不需要往门轴里上油。
流动的东西就不会停滞不前。
流水不腐,户枢不蠹。–王磊
声音和思想都不能在真空里传播。
软件不用就会腐朽。

Management
“Let the programmer be many and the managers few – then all will be productive.”
“增加程序员,减少经理–这样他们都可提高效率。”

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.
这才是编程之道。

Corporate Wisdom
“You can demonstrate a program for a corporate executive, but you can’t make him computer literate.”

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 program- mers, 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.
初学者惊恐地看着这只鸟,根本不敢相信,中级程序员担心这只鸟的到来,因为它害怕它带来的消息,编程大师则继续在他的终端前工作他根本不知道这只鸟曾经来过。

Hardware and Software
“Without the wind, the grass does not move.Without software, hardware is useless.”
风不动则草不动,没有软件,硬件只是一堆发热的电子器件

Epilogue
“Time for you to leave.”
“现在是你出师的时候了。”

《编程之禅》
开始时似乎比较容易的事情,结尾时往往是最困难的。这就是为什么程序员说“开发前面的百分之九需要一半时间,而另一半时间则用来完成最后的百分之十。”


程序不过是梦,
生于无形无象的禅中,
我们只是那做梦的人。


我编程三日,
两耳不闻人声,
只有硬盘在歌唱。


编译程序在运行,
像一条湍急的河流,
我静静地等侯。


为何要用LISP?
COBOL 语言我不懂,
所以我用LISP。


编程一整夜,
透过窗户,照到屏幕上,
初升的太阳。


硬件和软件,
我们是你们的主人和奴隶,
我们的生活是程序。


你能听见吗,
上程序的声音?
答案是NUL。


电子邮件说,
项目已取消,
清理文档时,我哭了。


计算中心空空荡荡,
静静的只有风扇在嗡鸣。
我走过一排排的CPU,
磁通量刺痛了我的皮肤。
我打开一扇门,又冷又硬,
看见指示灯在控制板上跳动。
一台没有灵魂的机器,人们说,
但它的灵魂是同事们的汗水,
在它里面有我们多年的生命,
失望,友谊,悲伤,欢乐,
算法成功时的狂喜,
和无数个徒劳无获的长夜。
我听见了叹息和欢笑的回声,
在这间黑洞洞的办公室里,
终端机闪耀着光芒,就像星星一样。

1 0