文章分类

相关文章

[翻译]了 20-50 年的代码,才明白的那些道理

分类:网络文摘     发布:2018-10-08     来源:今日头条     浏览:119 次

1.现如今有关软件开发的一切创造发明,不过是人们不断地重新发现某些东西,并假装他们发明了新东西。所有你认为很酷、很新的东西都是从 Smalltalk(被公认为第二个面向对象的程序设计语言和第一个真正的集成开发环境 IDE)、HAKMEM、Ivan Sutherland(计算机图形学之父和虚拟现实之父)、Douglas Engelbart(计算机界的资深学者)、早期的 IBM 或者贝尔实验室那里抄来的。

Everything in software development has already been invented. People just keep rediscovering it and pretending they invented it. Whatever you think is so cool and new, was copied from Smalltalk, or HAKMEM, or Ivan Sutherland, or Douglas Engelbart, or early IBM, or maybe Bell Labs.

2.不要相信编译器。不要相信工具。不要相信文档。不要相信自己。

Don’t trust the compiler. Don’t trust the tools. Don’t trust the documentation. Don’t trust yourself.

3.我们不需要新的编程语言。不过你肯定还会发明另一种语言。我猜,你的新语言肯定会用 IEEE-754 数学和固定精度整数。那你的新语言已经失败了。

We don’t need any more computer languages. Still, you will run right off and invent another one. Let me guess, your amazing new language uses IEEE-754 math and fixed-precision integers. Your amazing new language is broken.

4.维护代码比编写代码更难。写很多很多新代码是懒惰的表现。

Maintaining code is harder than writing it. Writing lots and lots of new code can be a mark of laziness.

5.学习编程时都会假设内存、处理器时间和网络带宽都是免费且无限的。而事实上,它们不是,它们不是,它们不是。好好读读 Knuth 关于过早优化的文字。

You have been taught to program as though memory, processor time, and network bandwidth are all free and infinite. It isn’t, it isn’t, and it isn’t. Read the rest of Knuth’s paragraph about premature optimization.

6.不出几个月你就会忘记你写过代码。所以代码一定要傻瓜都能看懂。

You’re going to forget what your code does in a few months. Make it ridiculously easy to read.

7.许多时候你只需要一行的 sed 就够了。

Sometimes, all you need is a one-liner in sed.

8.当心那些说话绝对的程序员,比如说我的方法永远比你的好之类的。编程是一门艺术,不是信仰。

Beware of programmers who speak in absolutes, such as My Method Is Always Better Than Yours. Programming is an art, not a religion.

9.如果你知道一系列固定的步骤要重复十次以上,就写个脚本吧。

If you know you will do a fixed sequence of steps more than ten times, automate it.

10.备份是一回事儿,恢复备份是另一回事儿。

Backing it up is one thing. Restoring it is another.

11.在你的机器上能用,不意味着没有 Bug。——Peers Sutton

Just because it works on your machine does not mean there is not a bug. -Piers Sutton

12.开发工具要等出了 .1 版之后再安装。让别人去做小白鼠。

Wait for the point-one release of development tools before installing

上一篇:如何把复杂的事情简单化

下一篇:趣味定律