这些编程警句摘自《C语言程序设计——现代方法》。而此书的又是从Alan J. Perlis的《Epigrams On Programming》中摘录,而且这些警句来自1982年。
此书每章首摘录一句,一共26句。
如果有人说“我想要一种语言,只需对它说我要干什么就行”,给他一支棒棒糖好了。
When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop.
这让我想起prolog逻辑式语言,同时想起王垠的Prolog与人工智能的没落。
某个人的常量可能是其他人的变量。
One man's constant is another man's variable.
在探索难以实现的问题时,简化是唯一的办法。
人不是通过用计算器学会的计算,但却是靠此手段忘记了算术。
One does not learn computing by using a hand calculator, but one can forget arithmetic.
不应用以聪明才智和逻辑分析能力来评判程序员,而要看其分析问题的全面性。
是不是应该讨论下招聘及KPI? :P
不值得编写没有循环和结构化变量的程序。
A program without a loop and a structured variable isn't worth writing.
请别搞错:计算机处理的是数而不是符号。我们用对活动算术化的程序来衡量我们的理解力(和控制力)。
Make no mistake about it: Computers process numbers - not symbols. We measure our understanding (and control) by the extent to which we can arithmetize an activity.
如果程序操纵着大量的数据,那它一定是用较少的方法办到的。
If a program manipulates a large amount of data, it does so in a small number of ways.
想到现在的大数据。虽然,我还没有接触Hadoop。
如果你有一个带了10个参数的过程,那么你很可能还遗漏了一些参数。
If you have a procedure with 10 parameters, you probably missed some.
正如罗杰斯可能会说的那样:“没有像自由变量这样的东西。”
As Will Rogers would have said, "There is no such thing as a free variable."
who's 罗杰斯?
我忘记了第十一条戒律是“你应该计算”,还是“你不应该计算”。
The 11th commandment was "Thou Shalt Compute" or "Thou Shalt Not Compute" - I forget which.
优化阻碍发展。
Optimization hinders evolution.
很难从字符串中找到感觉,但它们却是我们能指望的唯一交流纽带。
It's difficult to extract sense from strings, but they're the only communication coin we can count on.
在程序里我们始终有话要说,但是所有已知的语言都无法表达得很好。
There will always be things we wish to say in our programs that in all known languages can only be said poorly.
很难找到正确的时间单位来衡量计算机的发展。有些大教堂用了一个世纪才建成。你能想象一个壮丽辉煌的大程序也能花这么长的时间吗?
Around computers it is difficult to find the correct unit of time to measure progress. Some cathedrals took a century to complete. Can you imagine the grandeur and scope of a program that would take as long?
函数延迟绑定:数据结构导致绑定。记住:在编程过程后期再结构化数据。
Functions delay binding: data structures induce binding. Moral: Structure data late in the programming process.
人们只会在脑海显示复杂的信息。比如看,静景无论多么生动,都不如景色的运动、流动和改变重要。
One can only display complex information in the mind. Like seeing, movement or flow or alteration of view is more important than the static picture, no matter how lovely.
让一些事情可变很容易,而掌控不变的期限则需要技巧。
只要有模块化就有可能发生误解:隐藏信息意味着需要检查沟通。
Wherever there is modularity there is the potential for misunderstanding: Hiding information implies a need to check communication.
当程序要求关注不相干的内容时,所用的编程语言就是低级的。
A programming language is low level when its programs require attention to the irrelevant.
每个程序都是某些其他程序的一部分,但很少是正合适的。
Every program is a part of some other program and rarely fits.
在人机共生的世界中,必须调整的是人:机器是无法调整的。
In man-machine symbiosis, it is man who must adjust: The machines can't.
与计算机过长时间的接触把数学家变成了书记员,反之亦然。
Prolonged contact with the computer turns mathematicians into clerks and vice versa.
编写无错程序的方法有两种:但只有用第三种方法写的程序才行得通。
Every program has (at least) two purposes: the one for which it was written and another for which it wasn't.
哈,意指不可能写出无错的程序。
如果您的计算机说英语,那么它可能产自日本。
If your computer speaks English it was probably made in Japan.
确定程序参数的应用是用户,而不应该是它们的创造者。
It is the user who should parameterize procedures, not their creators.
这让我想到TDD。严格的测试驱动会强迫你既是代码的创造者,同时也是使用者。
关于C语言的书。大家都知道K&R的那本《C语言程序设计》,我也在里奇过世的时候买了一本,我看完了,但是对如何将C应用到实际项目中,没有指导作用。后来,我又找到了《C语言程序设计——现代方法》。我只能说与“现代方法”比起来,K&R那本只能用来做收藏。
“现代方法”,对“K&R”也有所评论:随着C语言的迅速普及,一系列问题也接踵而至。编写新的C语言编译器的程序员们都把“K&R”作为参考。但是遗憾的是,“K&R”对一些语言特性的描述非常模糊,以至于编译器常常会对这些特征进行不同的处理。而且,“K&R”也没有属于C语言的特性和属于UNIX系统的内容进行明确的区分。何况在“K&R”出版以后,C语言仍在不断变化,增加了新特性并且去除了少量过时的特性。