你对编程的“道”和“术”的理解( 五 )


程序者,当于用户无惊。何者?不出其意也。
程序者,其表如一,无论繁简。寻之逻辑,不在其表。
夫程序悖此法者,纷乱无序,当复写之。
4.2A 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.3A 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.师释道,曰:“道者遍及软件,无论大小。”
问曰:“计算器者有道欤?”
曰:“有道。”
问曰:“游戏机者有道欤?”
曰:“然也。”
问曰:“微机之DOS者有道欤?”
师咳而转身曰:“课止与此。”
4.4Prince Wang\u0026#39;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 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!"程序员为公子王写软件,指飞键舞,不差丝毫,行之如风。
公子王曰:“嘻,善哉!技盖至此乎?”
程序员释键对曰:“臣之所好者道也,进乎技矣。始臣之编程之时,所见无非程序者;三年之后,未尝见程序也,见其子程序也;方今之时,臣以神遇而不以目视,官知止而神欲行,因其固然,程序自写之。诚然,尝至于难者,吾见其难为,怵然为戒,视为止,行为迟,改其一字,謋然已解,如烟随风。使之编译,释键而坐,为之踌躇满志,闭目而注销之。”


推荐阅读