← Paul Graham

Revenge of the Nerds

书呆子的复仇
 ·  Paul Graham  ·  原文

<img src="http://www.virtumundo.com/images/spacer.gif" height=15 width=1> Want to start a startup?

<img src="http://www.virtumundo.com/images/spacer.gif" height=15 width=1> 想要创业吗?

Get funded by Y Combinator .

获得 Y Combinator 的资助。

</td > May 2002 "We were after the C++ programmers.

</td> 2002 年 5 月“我们正在寻找 C++ 程序员。

We managed to drag a lot of them about halfway to Lisp." - Guy Steele, co-author of the Java spec (This is an expanded version of the keynote lecture at the International ICAD User's Group conference in May 2002.

我们设法将其中很多拖到 Lisp 的一半左右。” - Guy Steele,Java 规范的合著者(这是 2002 年 5 月国际 ICAD 用户组会议上主题演讲的扩展版本。

It explains how a language

它解释了一种语言如何

developed in 1958 manages to be the most powerful available even today, what power is and when you need it, and why pointy-haired bosses (ideally, your competitors' pointy-haired bosses) deliberately ignore this issue.) Note: In this talk by "Lisp", I mean the Lisp family of languages, including Common Lisp, Scheme, Emacs Lisp, EuLisp, Goo, Arc, etc. --> <!-- Let me start by admitting that I don't know much about ICAD.

1958 年开发的 Lisp 语言至今仍然是最强大的,什么是强大的,什么时候需要它,以及为什么尖头发的老板(最好是你竞争对手的尖头发的老板)故意忽略这个问题。) 注意:在“Lisp”的这次演讲中,我指的是 Lisp 语言家族,包括 Common Lisp、Scheme、Emacs Lisp、EuLisp、Goo、Arc 等。 --> <!-- 首先我要承认我对ICAD了解不多。

I do know that it's written in Lisp, and in fact includes Lisp, in the sense that it lets users create and run Lisp programs.

我确实知道它是用 Lisp 编写的,并且实际上包含 Lisp,因为它允许用户创建和运行 Lisp 程序。

It's fairly common for programs written in Lisp to include Lisp.

用 Lisp 编写的程序包含 Lisp 是相当常见的。

Emacs does, and so does Yahoo Store.

Emacs 可以,Yahoo Store 也可以。

But if you think about it, that's kind of strange.

但如果你仔细想想,这有点奇怪。

How many programs written in C include C, in the sense that the user actually runs the C compiler while he's using the application?

从用户在使用应用程序时实际运行 C 编译器的意义上来说,有多少用 C 编写的程序包含 C?

I can't think of any, unless you count Unix

我想不出任何,除非你算上 Unix

as an application.

作为一个应用程序。

We're only a minute into this talk and already Lisp is looking kind of unusual.

我们的演讲才开始一分钟,Lisp 就已经看起来有点不寻常了。

Now, it is probably not news to any of you that Lisp is looking unusual.

现在,Lisp 看起来不寻常对于你们任何人来说可能都不是什么新闻了。

In fact, that was probably the first thing you noticed about it.

事实上,这可能是您注意到的第一件事。

Believe it or not, there is a reason Lisp code looks so strange.

不管你相信与否,Lisp 代码看起来如此奇怪是有原因的。

Lisp doesn't look this way because it was designed by a bunch of pointy-headed academics.

Lisp 看起来并不是这样,因为它是由一群头脑敏锐的学者设计的。

It was designed by pointy-headed academics, but they had hard-headed

它是由头脑敏锐的学者设计的,但他们也有头脑冷静的人

engineering reasons for making the syntax look so strange.

工程上的原因使得语法看起来如此奇怪。

Are All Languages Equivalent?

所有语言都是等效的吗?

--> In the software business there is an ongoing struggle between the pointy-headed academics, and another equally formidable force, the pointy-haired bosses.

--> 在软件行业,尖头学者和另一股同样强大的力量——尖头老板之间的斗争持续不断。

Everyone knows who the pointy-haired boss is, right?

大家都知道尖头老板是谁吧?

I think most people in the technology world not only recognize this cartoon character, but know the actual person in their company

我认为科技界的大多数人不仅认识这个卡通人物,而且认识他们公司里的真实人物

that he is modelled upon.

他是模仿的。

The pointy-haired boss miraculously combines two qualities that are common by themselves, but rarely seen together: (a) he knows nothing whatsoever about technology, and (b) he has very strong opinions about it.

这位尖头发的老板奇迹般地结合了两种常见但很少同时出现的品质:(a)他对技术一无所知,(b)他对此有非常强烈的看法。

Suppose, for example, you need to write a piece of software.

例如,假设您需要编写一个软件。

The pointy-haired boss has no idea how this software has to work, and can't tell one programming language from

尖头发的老板不知道这个软件是如何工作的,也无法区分一种编程语言和

another, and yet he knows what language you should write it in.

另一个,但他知道你应该用什么语言来写它。

Exactly.

正是如此。

He thinks you should write it in Java.

他认为你应该用 Java 来编写它。

Why does he think this?

他为什么这么想?

Let's take a look inside the brain of the pointy-haired boss.

我们来看看尖头老板的大脑内部。

What he's thinking is something like this.

他的想法是这样的。

Java is a standard.

Java是一个标准。

I know it must be, because I read about it in the press all the time.

我知道一定是这样,因为我一直在媒体上读到这件事。

Since it is a standard, I won't get in trouble for using it.

因为它是一个标准,所以我在使用它时不会遇到麻烦。

And that also means there will always be lots of Java programmers,

这也意味着总会有很多 Java 程序员,

so if the programmers working for me now quit, as programmers working for me mysteriously always do, I can easily replace them.

因此,如果为我工作的程序员现在辞职了,就像为我工作的程序员总是神秘地这样做一样,我可以轻松地替换他们。

Well, this doesn't sound that unreasonable.

嗯,这听起来并不是那么不合理。

But it's all based on one unspoken assumption, and that assumption turns out to be false.

但这一切都基于一个不言而喻的假设,而这一假设最终被证明是错误的。

The pointy-haired boss believes that all programming languages are pretty much equivalent.

尖头发的老板相信所有的编程语言几乎都是等价的。

If that were true, he would be right on target.

如果这是真的,那么他就正中目标了。

If languages are all equivalent, sure, use whatever

如果语言都是等价的,当然,使用任何语言

language everyone else is using.

其他人都在使用的语言。

But all languages are not equivalent, and I think I can prove this to you without even getting into the differences between them.

但并不是所有的语言都是等价的,我想我可以向你证明这一点,甚至不需要讨论它们之间的差异。

If you asked the pointy-haired boss in 1992 what language software should be written in, he would have answered with as little hesitation as he does today.

如果你在 1992 年问尖头发的老板应该用什么语言编写软件,他会像今天一样毫不犹豫地回答。

Software should be written in C++.

软件应该用 C++ 编写。

But if languages are all equivalent, why should the

但如果语言都是等价的,为什么要

pointy-haired boss's opinion ever change?

尖头老板的意见有变吗?

In fact, why should the developers of Java have even bothered to create a new language?

事实上,为什么 Java 开发者还要费心去创建一门新语言呢?

Presumably, if you create a new language, it's because you think it's better in some way than what people already had.

据推测,如果您创建一种新语言,那是因为您认为它在某些方面比人们已有的语言更好。

And in fact, Gosling makes it clear in the first Java white paper that Java was designed to fix some problems with C++.

事实上,Gosling 在第一个 Java 白皮书中就明确表示,Java 的设计目的是为了解决 C++ 的一些问题。

So there you have it: languages are not all equivalent.

所以你明白了:语言并不都是等价的。

If you follow the trail through the pointy-haired boss's brain to Java and then back through Java's history to its origins, you end up holding an idea that contradicts the assumption you started with.

如果你顺着尖头老板的大脑到 Java,然后通过 Java 的历史回到它的起源,你最终会得到一个与你开始的假设相矛盾的想法。

So, who's right?

那么,谁是对的呢?

James Gosling, or the pointy-haired boss?

詹姆斯·高斯林,还是尖头发的老板?

Not surprisingly, Gosling is right.

毫不奇怪,高斯林是对的。

Some languages are better, for certain problems, than others.

对于某些问题,某些语言比其他语言更好。

And you know, that raises some interesting questions.

你知道,这提出了一些有趣的问题。

Java was designed to be better, for certain

确实,Java 被设计得更好

problems, than C++.

比 C++ 更容易出现问题。

What problems?

有什么问题?

When is Java better and when is C++?

Java什么时候更好,C++什么时候更好?

Are there situations where other languages are better than either of them?

是否存在其他语言比其中任何一种语言更好的情况?

Once you start considering this question, you have opened a real can of worms.

一旦你开始考虑这个问题,你就打开了一个真正的蠕虫罐头。

If the pointy-haired boss had to think about the problem in its full complexity, it would make his brain explode.

如果让尖头老板思考这个问题的复杂性,他的大脑会爆炸。

As long as he considers all languages equivalent, all he has to do is choose the one

只要他认为所有语言都是等价的,他所要做的就是选择一种

that seems to have the most momentum, and since that is more a question of fashion than technology, even he can probably get the right answer.

这似乎是最有动力的,而且由于这更多的是时尚问题而不是技术问题,所以即使是他也可能得到正确的答案。

But if languages vary, he suddenly has to solve two simultaneous equations, trying to find an optimal balance between two things he knows nothing about: the relative suitability of the twenty or so leading languages for the problem he needs to solve, and the odds of

但是,如果语言有所不同,他突然必须求解两个联立方程,试图在他一无所知的两件事之间找到最佳平衡:大约二十种主要语言对他需要解决的问题的相对适用性,以及

finding programmers, libraries, etc. for each.

为每个人寻找程序员、库等。

If that's what's on the other side of the door, it is no surprise that the pointy-haired boss doesn't want to open it.

如果门的另一边就是这个,那尖毛老板不愿意打开也就不足为奇了。

The disadvantage of believing that all programming languages are equivalent is that it's not true.

相信所有编程语言都是等效的缺点是事实并非如此。

But the advantage is that it makes your life a lot simpler.

但好处是它让你的生活变得更加简单。

And I think that's the main reason the idea is so widespread.

我认为这是这个想法如此广泛的主要原因。

It is a comfortable idea.

这是一个令人舒服的想法。

We know that Java must be pretty good, because it is the cool, new programming language.

我们知道 Java 一定非常好,因为它是一种很酷的新编程语言。

Or is it?

或者是吗?

If you look at the world of programming languages from a distance, it looks like Java is the latest thing.

如果你从远处观察编程语言的世界,你会发现 Java 似乎是最新的事物。

(From far enough away, all you can see is the large, flashing billboard paid for by Sun.) But if you look at this world up close, you find that there are degrees of coolness.

(从足够远的地方,你只能看到Sun公司花钱买的巨大的、闪烁的广告牌。)但是如果你近距离观察这个世界,你会发现凉爽是有一定程度的。

Within the hacker subculture, there is another language called Perl

在黑客亚文化中,还有另一种语言,称为 Perl

that is considered a lot cooler than Java.

这被认为比 Java 酷得多。

Slashdot, for example, is generated by Perl.

例如,Slashdot 是由 Perl 生成的。

I don't think you would find those guys using Java Server Pages.

我认为您不会发现那些人使用 Java Server Pages。

But there is another, newer language, called Python, whose users tend to look down on Perl, and more waiting in the wings.

但还有另一种更新的语言,称为 Python,它的用户往往看不起 Perl,而更多的人则在等待。

If you look at these languages in order, Java, Perl, Python, you notice an interesting pattern.

如果您按顺序查看这些语言(Java、Perl、Python),您会发现一个有趣的模式。

At least, you notice this pattern if you are a Lisp hacker.

至少,如果您是 Lisp 黑客,您会注意到这种模式。

Each one is progressively

每一项都是循序渐进的

more like Lisp.

更像 Lisp。

Python copies even features that many Lisp hackers consider to be mistakes.

Python 甚至复制了许多 Lisp 黑客认为是错误的功能。

You could translate simple Lisp programs into Python line for line.

你可以将简单的 Lisp 程序逐行翻译成 Python。

It's 2002, and programming languages have almost caught up with 1958.

现在是 2002 年,编程语言几乎已经赶上 1958 年了。

Catching Up with Math What I mean is that Lisp was first discovered by John McCarthy in 1958, and popular programming languages are only now catching up with the ideas he developed then.

赶上数学 我的意思是 Lisp 是由 John McCarthy 于 1958 年首次发现的,流行的编程语言现在才赶上他当时提出的想法。

Now, how could that be true?

现在,这怎么可能是真的呢?

Isn't computer technology something that changes very rapidly?

计算机技术不是变化很快的东西吗?

I mean, in 1958, computers were refrigerator-sized behemoths with the processing power of a wristwatch.

我的意思是,在 1958 年,计算机是冰箱大小的庞然大物,具有手表的处理能力。

How could any technology that old even be relevant, let alone superior to the latest developments?

如此古老的技术怎么可能具有相关性,更不用说优于最新开发的技术了?

I'll tell you how.

我会告诉你怎么做。

It's because Lisp was not really designed to be a programming language, at least not in the sense

这是因为 Lisp 并不是真正被设计成一种编程语言,至少不是这个意义上的

we mean today.

我们指的是今天。

What we mean by a programming language is something we use to tell a computer what to do.

我们所说的编程语言是指我们用来告诉计算机做什么的语言。

McCarthy did eventually intend to develop a programming language in this sense, but the Lisp that we actually ended up with was based on something separate that he did as a theoretical exercise -- an effort to define a more convenient alternative to the Turing Machine.

麦卡锡最终确实打算在这个意义上开发一种编程语言,但我们实际上最终得到的 Lisp 是基于他作为理论练习所做的一些单独的事情 - 努力定义图灵机的更方便的替代方案。

As McCarthy said later, Another way to show that Lisp was neater than Turing machines

正如麦卡锡后来所说,证明 Lisp 比图灵机更简洁的另一种方式

was to write a universal Lisp function and show that it is briefer and more comprehensible than the description of a universal Turing machine.

的目标是编写一个通用的 Lisp 函数,并证明它比通用图灵机的描述更简洁、更容易理解。

This was the Lisp function eval ..., which computes the value of a Lisp expression....

这是 Lisp 函数 eval ...,它计算 Lisp 表达式的值......

Writing eval required inventing a notation representing Lisp functions as Lisp data, and such a notation was devised for the purposes of the paper with no thought that it would be used to express Lisp programs in practice.

编写 eval 需要发明一种将 Lisp 函数表示为 Lisp 数据的符号,这种符号是为了本文的目的而设计的,并没有想到它会在实践中用于表达 Lisp 程序。

What happened next was that, some time in late 1958, Steve Russell, one of McCarthy's grad students, looked at this definition of eval and realized that if he translated it into machine language, the result would be a Lisp interpreter.

接下来发生的事情是,在 1958 年末的某个时候,麦卡锡的研究生之一史蒂夫·拉塞尔 (Steve Russell) 查看了 eval 的定义,并意识到,如果他将其翻译成机器语言,结果将是一个 Lisp 解释器。

This was a big surprise at the time.

这在当时是一个很大的惊喜。

Here is what McCarthy said about it later in an interview: Steve Russell said, look, why don't I program this eval ..., and I said to him, ho, ho, you're confusing theory with practice,

以下是麦卡锡后来在一次采访中对此的评论:史蒂夫·拉塞尔说,看,我为什么不编写这个评估......,我对他说,嗬,嗬,你混淆了理论与实践,

this eval is intended for reading, not for computing.

这个评估是为了阅读,而不是为了计算。

But he went ahead and did it.

但他继续前进并做到了。

That is, he compiled the eval in my paper into [IBM] 704 machine code, fixing bugs, and then advertised this as a Lisp interpreter, which it certainly was.

也就是说,他将我论文中的 eval 编译成 [IBM] 704 机器代码,修复了错误,然后将其宣传为 Lisp 解释器,事实确实如此。

So at that point Lisp had essentially the form that it has today....

所以那时 Lisp 基本上就具有了今天的形式......

Suddenly, in a matter of weeks I think, McCarthy found his theoretical exercise transformed into an actual programming language-- and a

突然之间,我认为在几周内,麦卡锡发现他的理论练习变成了一种实际的编程语言——并且

more powerful one than he had intended.

比他预想的还要强大。

So the short explanation of why this 1950s language is not obsolete is that it was not technology but math, and math doesn't get stale.

因此,对于为什么这种 20 世纪 50 年代的语言没有过时的简单解释是,它不是技术而是数学,而数学不会变得过时。

The right thing to compare Lisp to is not 1950s hardware, but, say, the Quicksort algorithm, which was discovered in 1960 and is still the fastest general-purpose sort.

比较 Lisp 的正确对象不是 20 世纪 50 年代的硬件,而是 1960 年发现的快速排序算法,它仍然是最快的通用排序算法。

There is one other language still surviving from the 1950s, Fortran, and it represents the

还有另一种语言从 20 世纪 50 年代至今仍然存在,即 Fortran,它代表了

opposite approach to language design.

与语言设计相反的方法。

Lisp was a piece of theory that unexpectedly got turned into a programming language.

Lisp 是一个意外地变成了一种编程语言的理论。

Fortran was developed intentionally as a programming language, but what we would now consider a very low-level one.

Fortran 是有意作为一种编程语言而开发的,但我们现在认为它是一种非常低级的语言。

Fortran I , the language that was developed in 1956, was a very different animal from present-day Fortran.

Fortran I 是 1956 年开发的语言,与当今的 Fortran 是一种非常不同的语言。

Fortran I was pretty much assembly language with math.

Fortran 我几乎是汇编语言和数学。

In some ways it was less

从某些方面来说,它更少

powerful than more recent assembly languages; there were no subroutines, for example, only branches.

比最新的汇编语言更强大;例如,没有子程序,只有分支。

Present-day Fortran is now arguably closer to Lisp than to Fortran I.

现在的 Fortran 可以说更接近 Lisp,而不是 Fortran I。

Lisp and Fortran were the trunks of two separate evolutionary trees, one rooted in math and one rooted in machine architecture.

Lisp 和 Fortran 是两棵独立进化树的主干,一棵植根于数学,一棵植根于机器架构。

These two trees have been converging ever since.

从那时起,这两棵树就一直在融合。

Lisp started out powerful, and over the next twenty years

Lisp 一开始就很强大,在接下来的二十年里

got fast.

速度很快。

So-called mainstream languages started out fast, and over the next forty years gradually got more powerful, until now the most advanced of them are fairly close to Lisp.

所谓的主流语言起步很快,在接下来的四十年里逐渐变得更加强大,到目前为止,其中最先进的语言已经相当接近Lisp了。

Close, but they are still missing a few things....

接近了,但他们仍然缺少一些东西......

What Made Lisp Different When it was first developed, Lisp embodied nine new ideas.

是什么让 Lisp 与众不同 当 Lisp 首次开发时,它体现了九个新想法。

Some of these we now take for granted, others are only seen in more advanced languages, and two are still

其中一些我们现在认为是理所当然的,另一些则只在更高级的语言中看到,还有两个仍然是

unique to Lisp.

Lisp 独有的。

The nine ideas are, in order of their adoption by the mainstream, Conditionals.

这九个想法按照被主流采用的顺序排列为条件句。

A conditional is an if-then-else construct.

条件是 if-then-else 结构。

We take these for granted now, but Fortran I didn't have them.

我们现在认为这些是理所当然的,但 Fortran 我没有它们。

It had only a conditional goto closely based on the underlying machine instruction.

它只有一个密切基于底层机器指令的条件跳转。

A function type.

一个函数类型。

In Lisp, functions are a data type just like integers or strings.

在 Lisp 中,函数是一种数据类型,就像整数或字符串一样。

They have a literal representation, can be stored in variables,

它们有文字表示,可以存储在变量中,

can be passed as arguments, and so on.

可以作为参数传递,等等。

Recursion.

递归。

Lisp was the first programming language to support it.

Lisp 是第一个支持它的编程语言。

Dynamic typing.

动态打字。

In Lisp, all variables are effectively pointers.

在 Lisp 中,所有变量实际上都是指针。

Values are what have types, not variables, and assigning or binding variables means copying pointers, not what they point to.

值是有类型的,而不是变量,分配或绑定变量意味着复制指针,而不是它们指向的内容。

Garbage-collection.

垃圾收集。

Programs composed of expressions.

由表达式组成的程序。

Lisp programs are trees of expressions, each of which returns a value.

Lisp 程序是表达式树,每个表达式都返回一个值。

This is in contrast to Fortran and most succeeding languages, which distinguish between expressions and statements.

这与 Fortran 和大多数后续语言形成鲜明对比,它们区分表达式和语句。

It was natural to have this distinction in Fortran I because you could not nest statements.

Fortran I 中存在这种区别是很自然的,因为不能嵌套语句。

And so while you needed expressions for math to work, there was no point in making anything else return a value, because there could not be anything waiting for it.

因此,虽然您需要数学表达式才能工作,但让其他任何东西返回值是没有意义的,因为没有任何东西在等待它。

This limitation went away with the arrival of block-structured languages,

随着块结构语言的出现,这种限制消失了,

but by then it was too late.

但那时已经太晚了。

The distinction between expressions and statements was entrenched.

表达式和陈述之间的区别是根深蒂固的。

It spread from Fortran into Algol and then to both their descendants.

它从 Fortran 传播到 Algol,然后传播到它们的后代。

A symbol type.

符号类型。

Symbols are effectively pointers to strings stored in a hash table.

符号实际上是指向存储在哈希表中的字符串的指针。

So you can test equality by comparing a pointer, instead of comparing each character.

因此,您可以通过比较指针来测试相等性,而不是比较每个字符。

A notation for code using trees of symbols and constants.

使用符号和常量树的代码表示法。

The whole language there all the time.

整个语言一直存在。

There is

有

no real distinction between read-time, compile-time, and runtime.

读取时、编译时和运行时之间没有真正的区别。

You can compile or run code while reading, read or run code while compiling, and read or compile code at runtime.

您可以在读取时编译或运行代码,在编译时读取或运行代码,以及在运行时读取或编译代码。

Running code at read-time lets users reprogram Lisp's syntax; running code at compile-time is the basis of macros; compiling at runtime is the basis of Lisp's use as an extension language in programs like Emacs; and reading at runtime

在读取时运行代码可以让用户重新编程 Lisp 的语法;在编译时运行代码是宏的基础;运行时编译是 Lisp 在 Emacs 等程序中用作扩展语言的基础;并在运行时读取

enables programs to communicate using s-expressions, an idea recently reinvented as XML.

使程序能够使用 s 表达式进行通信,这一想法最近被重新发明为 XML。

When Lisp first appeared, these ideas were far removed from ordinary programming practice, which was dictated largely by the hardware available in the late 1950s.

当 Lisp 首次出现时,这些想法与普通的编程实践相去甚远,而普通的编程实践很大程度上是由 20 世纪 50 年代末可用的硬件决定的。

Over time, the default language, embodied in a succession of popular languages, has gradually evolved toward Lisp.

随着时间的推移,体现在一系列流行语言中的默认语言已逐渐向 Lisp 发展。

Ideas 1-5 are now widespread.

想法 1-5 现在很普遍。

Number 6 is starting to appear in the mainstream.

6号开始成为主流。

Python has a form of 7, though there doesn't seem to be any syntax for it.

Python 的形式为 7,但似乎没有任何语法。

As for number 8, this may be the most interesting of the lot.

至于数字 8,这可能是其中最有趣的。

Ideas 8 and 9 only became part of Lisp by accident, because Steve Russell implemented something McCarthy had never intended to be implemented.

想法 8 和 9 成为 Lisp 的一部分纯属偶然,因为 Steve Russell 实现了 McCarthy 从未打算实现的东西。

And yet these ideas turn out to be responsible for both Lisp's strange appearance and its most distinctive features.

然而,这些想法却被证明是 Lisp 奇怪的外观及其最独特的特征的原因。

Lisp looks strange not so much because

Lisp 看起来并不奇怪,因为

it has a strange syntax as because it has no syntax; you express programs directly in the parse trees that get built behind the scenes when other languages are parsed, and these trees are made of lists, which are Lisp data structures.

它有一个奇怪的语法,因为它没有语法;你可以直接在解析树中表达程序,解析树是在解析其他语言时在幕后构建的,这些树由列表组成,这些列表是 Lisp 数据结构。

Expressing the language in its own data structures turns out to be a very powerful feature.

用自己的数据结构表达语言被证明是一个非常强大的功能。

Ideas 8 and 9 together mean that you can write programs that write programs.

想法 8 和 9 一起意味着您可以编写可以编写程序的程序。

That may sound

这听起来可能

like a bizarre idea, but it's an everyday thing in Lisp.

这就像一个奇怪的想法,但在 Lisp 中却是司空见惯的事情。

The most common way to do it is with something called a macro.

最常见的方法是使用宏。

The term "macro" does not mean in Lisp what it means in other languages.

“宏”一词在 Lisp 中的含义与其他语言中的含义不同。

A Lisp macro can be anything from an abbreviation to a compiler for a new language.

Lisp 宏可以是任何东西,从缩写到新语言的编译器。

If you want to really understand Lisp, or just expand your programming horizons, I would learn more about macros.

如果你想真正理解 Lisp,或者只是想扩展你的编程视野,我会学习更多关于宏的知识。

Macros (in the Lisp sense) are still, as far as

宏(在 Lisp 意义上)仍然是

I know, unique to Lisp.

我知道,这是 Lisp 独有的。

This is partly because in order to have macros you probably have to make your language look as strange as Lisp.

部分原因是为了拥有宏,你可能必须让你的语言看起来像 Lisp 一样奇怪。

It may also be because if you do add that final increment of power, you can no longer claim to have invented a new language, but only a new dialect of Lisp.

也可能是因为,如果你确实添加了最后的能力增量,你就不能再声称发明了一种新语言,而只能声称发明了一种新的 Lisp 方言。

I mention this mostly as a joke, but it is quite true.

我提到这一点主要是作为一个笑话,但这是千真万确的。

If you define a language that has car, cdr, cons, quote, cond, atom,

如果你定义的语言有 car、cdr、cons、quote、cond、atom,

eq, and a notation for functions expressed as lists, then you can build all the rest of Lisp out of it.

eq,以及表示为列表的函数符号,那么你可以用它构建 Lisp 的所有其余部分。

That is in fact the defining quality of Lisp: it was in order to make this so that McCarthy gave Lisp the shape it has.

这实际上是 Lisp 的决定性品质:正是为了做到这一点,麦卡锡才赋予 Lisp 它所具有的形状。

Where Languages Matter So suppose Lisp does represent a kind of limit that mainstream languages are approaching asymptotically-- does that mean you should actually use it to write software?

语言的重要性 因此,假设 Lisp 确实代表了主流语言正在渐近地接近的一种限制——这是否意味着您实际上应该使用它来编写软件?

How much do you lose by using a less powerful language?

使用功能较弱的语言会损失多少?

Isn't it wiser, sometimes, not to be at the very edge of innovation?

有时,不处于创新的最前沿不是更明智吗?

And isn't popularity to some extent its own justification?

流行在某种程度上不也是其自身的正当理由吗?

Isn't the pointy-haired boss right, for example, to want to use a language for which he can easily hire programmers?

例如,尖头发的老板想要使用一种他可以轻松雇用程序员的语言,这不是正确的吗?

There are, of course, projects where the choice of programming language doesn't matter much.

当然,在某些项目中,编程语言的选择并不重要。

As a rule, the more demanding the application, the more

一般来说,应用要求越高,

leverage you get from using a powerful language.

使用强大的语言可以获得优势。

But plenty of projects are not demanding at all.

但很多项目的要求并不高。

Most programming probably consists of writing little glue programs, and for little glue programs you can use any language that you're already familiar with and that has good libraries for whatever you need to do.

大多数编程可能包括编写小型粘合程序,对于小型粘合程序,您可以使用您已经熟悉的任何语言,并且该语言具有适合您需要执行的任何操作的良好库。

If you just need to feed data from one Windows app to another, sure, use Visual Basic.

如果您只需要将数据从一个 Windows 应用程序提供给另一个 Windows 应用程序,那么当然可以使用 Visual Basic。

You can write little glue programs in Lisp too

你也可以用 Lisp 编写小的粘合程序

(I use it as a desktop calculator), but the biggest win for languages like Lisp is at the other end of the spectrum, where you need to write sophisticated programs to solve hard problems in the face of fierce competition.

(我用它作为桌面计算器),但像 Lisp 这样的语言的最大胜利是在另一方面,在激烈的竞争中,你需要编写复杂的程序来解决难题。

A good example is the airline fare search program that ITA Software licenses to Orbitz.

一个很好的例子是 ITA Software 授权给 Orbitz 的机票搜索程序。

These guys entered a market already dominated by two big, entrenched competitors, Travelocity and Expedia, and

这些人进入的市场已经被 Travelocity 和 Expedia 这两个根深蒂固的大竞争对手占据主导地位。

seem to have just humiliated them technologically.

似乎只是在技术上羞辱了他们。

The core of ITA's application is a 200,000 line Common Lisp program that searches many orders of magnitude more possibilities than their competitors, who apparently are still using mainframe-era programming techniques.

ITA 应用程序的核心是一个 200,000 行的 Common Lisp 程序,它比竞争对手搜索更多数量级的可能性,而竞争对手显然仍在使用大型机时代的编程技术。

(Though ITA is also in a sense using a mainframe-era programming language.) I have never seen any of ITA's code, but according to one of their top hackers they use a lot of macros,

(尽管从某种意义上说,ITA 也在使用大型机时代的编程语言。)我从未见过 ITA 的任何代码,但根据他们的一位顶级黑客的说法,他们使用了很多宏,

and I am not surprised to hear it.

听到这个我并不感到惊讶。

Centripetal Forces I'm not saying there is no cost to using uncommon technologies.

向心力 我并不是说使用不常见的技术没有成本。

The pointy-haired boss is not completely mistaken to worry about this.

尖头老板担心这一点也不是完全错误的。

But because he doesn't understand the risks, he tends to magnify them.

但由于他不了解风险,他往往会放大风险。

I can think of three problems that could arise from using less common languages.

我可以想到使用不太常见的语言可能出现的三个问题。

Your programs might not work well with programs written in other languages.

您的程序可能无法与其他语言编写的程序很好地配合。

You might have fewer

你可能会更少

libraries at your disposal.

图书馆供您使用。

And you might have trouble hiring programmers.

而且您可能在招聘程序员时遇到困难。

How much of a problem is each of these?

这些问题的严重程度如何?

The importance of the first varies depending on whether you have control over the whole system.

第一个的重要性取决于您是否可以控制整个系统。

If you're writing software that has to run on a remote user's machine on top of a buggy, closed operating system (I mention no names), there may be advantages to writing your application in the

如果您正在编写必须在有缺陷的封闭操作系统(我没有提到名称)之上的远程用户计算机上运行的软件,那么在

same language as the OS.

与操作系统相同的语言。

But if you control the whole system and have the source code of all the parts, as ITA presumably does, you can use whatever languages you want.

但如果你控制整个系统并拥有所有部分的源代码(就像 ITA 所做的那样),你就可以使用任何你想要的语言。

If any incompatibility arises, you can fix it yourself.

如果出现任何不兼容的情况,您可以自行修复。

In server-based applications you can get away with using the most advanced technologies, and I think this is the main cause of what Jonathan Erickson calls the "<a href= "http://www.byte.com/documents/s=1821/byt20011214s0003/">programming language

在基于服务器的应用程序中,您可以使用最先进的技术,我认为这是 Jonathan Erickson 所说的“<a href=”http://www.byte.com/documents/s=1821/byt20011214s0003/">编程语言的主要原因

renaissance ." This is why we even hear about new languages like Perl and Python.

文艺复兴”。这就是为什么我们甚至听说 Perl 和 Python 等新语言。

We're not hearing about these languages because people are using them to write Windows apps, but because people are using them on servers.

我们听说这些语言并不是因为人们使用它们来编写 Windows 应用程序,而是因为人们在服务器上使用它们。

And as software shifts off the desktop and onto servers (a future even Microsoft seems resigned to), there will be less and less pressure to use middle-of-the-road technologies.

随着软件从桌面转移到服务器(甚至微软似乎也已经接受了这样的未来),使用中间技术的压力将会越来越小。

As for libraries, their importance also

至于图书馆,它们的重要性也

depends on the application.

取决于应用程序。

For less demanding problems, the availability of libraries can outweigh the intrinsic power of the language.

对于要求不高的问题,库的可用性可能超过语言的内在功能。

Where is the breakeven point?

盈亏平衡点在哪里?

Hard to say exactly, but wherever it is, it is short of anything you'd be likely to call an application.

很难准确地说,但无论它在哪里,它都缺乏您可能称之为应用程序的任何东西。

If a company considers itself to be in the software business, and they're writing an application that will be one of their products,

如果一家公司认为自己从事软件业务,并且他们正在编写一个将成为其产品之一的应用程序,

then it will probably involve several hackers and take at least six months to write.

那么它可能会涉及多名黑客,并且至少需要六个月的时间来编写。

In a project of that size, powerful languages probably start to outweigh the convenience of pre-existing libraries.

在这种规模的项目中,强大的语言可能开始超过现有库的便利性。

The third worry of the pointy-haired boss, the difficulty of hiring programmers, I think is a red herring.

尖头老板的第三个担忧,招聘程序员的难度,我认为是一个转移注意力的问题。

How many hackers do you need to hire, after all?

毕竟,您需要雇用多少黑客?

Surely by now we all know that software is best developed by teams of less

当然,现在我们都知道软件最好由更少的团队开发

than ten people.

超过十个人。

And you shouldn't have trouble hiring hackers on that scale for any language anyone has ever heard of.

对于任何人都听说过的任何语言,雇用如此规模的黑客应该不会有困难。

If you can't find ten Lisp hackers, then your company is probably based in the wrong city for developing software.

如果你找不到十个 Lisp 黑客,那么你的公司可能位于错误的城市来开发软件。

In fact, choosing a more powerful language probably decreases the size of the team you need, because (a) if you use a more powerful language you probably won't need as many hackers,

事实上,选择更强大的语言可能会减少您所需团队的规模,因为 (a) 如果您使用更强大的语言,您可能不需要那么多的黑客,

and (b) hackers who work in more advanced languages are likely to be smarter.

(b) 使用更高级语言的黑客可能更聪明。

I'm not saying that you won't get a lot of pressure to use what are perceived as "standard" technologies.

我并不是说您不会承受很大的压力来使用被视为“标准”的技术。

At Viaweb (now Yahoo Store), we raised some eyebrows among VCs and potential acquirers by using Lisp.

在 Viaweb(现在的雅虎商店),我们使用 Lisp 引起了风险投资家和潜在收购者的关注。

But we also raised eyebrows by using generic Intel boxes as servers instead of "industrial strength" servers like Suns, for using a

但我们也通过使用通用英特尔服务器而不是像 Suns 这样的“工业强度”服务器来使用服务器,这也引起了我们的注意。

then-obscure open-source Unix variant called FreeBSD instead of a real commercial OS like Windows NT, for ignoring a supposed e-commerce standard called SET that no one now even remembers, and so on.

当时默默无闻的名为 FreeBSD 的开源 Unix 变体,而不是像 Windows NT 这样的真正的商业操作系统,因为它忽略了一个现在没有人记得的名为 SET 的所谓电子商务标准,等等。

You can't let the suits make technical decisions for you.

你不能让西装为你做出技术决策。

Did it alarm some potential acquirers that we used Lisp?

我们使用 Lisp 是否引起了一些潜在收购者的警觉?

Some, slightly, but if we hadn't used Lisp, we wouldn't have been able to write the software that made them want to buy us.

有一些,有一点,但如果我们没有使用 Lisp,我们就无法编写出让他们想要购买我们的软件。

What seemed like an anomaly to them was in fact cause and effect.

对他们来说看似异常的事情实际上是因果关系。

If you start a startup, don't design your product to please VCs or potential acquirers.

如果你创办一家初创公司,不要为了取悦风险投资家或潜在收购者而设计你的产品。

Design your product to please the users.

设计你的产品来取悦用户。

If you win the users, everything else will follow.

如果你赢得了用户,其他一切都会水到渠成。

And if you don't, no one will care how comfortingly orthodox your technology choices were.

如果你不这样做,没有人会关心你的技术选择是多么令人舒服的正统。

The Cost of Being Average How much do you lose by using a less powerful language?

使用功能较弱的语言会损失多少?

There is actually some data out there about that.

实际上有一些关于这方面的数据。

The most convenient measure of power is probably code size .

最方便的衡量能力的方法可能是代码大小。

The point of high-level languages is to give you bigger abstractions-- bigger bricks, as it were, so you don't need as many to build a wall of a given size.

高级语言的目的是为您提供更大的抽象——可以说是更大的砖块,因此您不需要那么多的砖块来建造给定尺寸的墙。

So the more powerful the language, the shorter the program (not simply in characters, of course, but in distinct elements).

因此,语言越强大,程序就越短(当然不仅仅是字符,而是不同的元素)。

How does a more powerful language enable you to write

更强大的语言如何让你能够写作

shorter programs?

较短的节目?

One technique you can use, if the language will let you, is something called bottom-up programming .

如果语言允许,您可以使用的一种技术是自下而上编程。

Instead of simply writing your application in the base language, you build on top of the base language a language for writing programs like yours, then write your program in it.

您不是简单地用基本语言编写应用程序,而是在基本语言之上构建一种用于编写像您这样的程序的语言,然后用它编写您的程序。

The combined code can be much shorter than if you had written your whole program in the base language-- indeed,

组合后的代码可能比用基本语言编写整个程序要短得多——事实上,

this is how most compression algorithms work.

这就是大多数压缩算法的工作原理。

A bottom-up program should be easier to modify as well, because in many cases the language layer won't have to change at all.

自下而上的程序也应该更容易修改,因为在许多情况下,语言层根本不需要改变。

Code size is important, because the time it takes to write a program depends mostly on its length.

代码大小很重要,因为编写程序所需的时间主要取决于程序的长度。

If your program would be three times as long in another language, it will take three times as long to write-- and you can't get around this by hiring more people, because

如果你的程序用另一种语言编写的时间是原来的三倍,那么编写的时间就会是原来的三倍——而且你无法通过雇用更多的人来解决这个问题,因为

beyond a certain size new hires are actually a net lose.

超过一定规模的新员工实际上是净损失。

Fred Brooks described this phenomenon in his famous book The Mythical Man-Month, and everything I've seen has tended to confirm what he said.

弗雷德·布鲁克斯(Fred Brooks)在他的名著《人月神话》中描述了这种现象,我所看到的一切都证实了他所说的。

So how much shorter are your programs if you write them in Lisp?

那么如果你用 Lisp 编写程序,你的程序会短多少呢?

Most of the numbers I've heard for Lisp versus C, for example, have been around 7-10x.

例如,我听到的 Lisp 与 C 的大多数数字都在 7-10 倍左右。

But a recent article about ITA in New Architect magazine said that

但《New Architect》杂志最近一篇关于 ITA 的文章表示

"one line of Lisp can replace 20 lines of C," and since this article was full of quotes from ITA's president, I assume they got this number from ITA.

“一行 Lisp 可以替代 20 行 C”,并且由于这篇文章充满了 ITA 主席的引言,我猜他们是从 ITA 那里得到这个数字的。

If so then we can put some faith in it; ITA's software includes a lot of C and C++ as well as Lisp, so they are speaking from experience.

如果是这样,那么我们可以对它抱有一定的信心; ITA 的软件包含大量 C 和 C++ 以及 Lisp,所以他们是根据经验说话的。

My guess is that these multiples aren't even constant.

我的猜测是这些倍数甚至不是恒定的。

I think they increase when you face harder problems and also when you have smarter

我认为当你面对更困难的问题并且当你拥有更聪明的能力时,它们就会增加

programmers.

程序员。

A really good hacker can squeeze more out of better tools.

一个真正优秀的黑客可以从更好的工具中榨取更多的东西。

As one data point on the curve, at any rate, if you were to compete with ITA and chose to write your software in C, they would be able to develop software twenty times faster than you.

作为曲线上的一个数据点,无论如何,如果您要与 ITA 竞争并选择用 C 语言编写软件,那么他们开发软件的速度将比您快二十倍。

If you spent a year on a new feature, they'd be able to duplicate it in less than three weeks.

如果你花了一年的时间开发一个新功能,他们将能够在不到三周的时间内复制它。

Whereas if they spent just three months developing something new, it would be

然而,如果他们只花三个月开发新东西,那就是

five years before you had it too.

五年前你也有过它。

And you know what?

你知道吗?

That's the best-case scenario.

这是最好的情况。

When you talk about code-size ratios, you're implicitly assuming that you can actually write the program in the weaker language.

当您谈论代码大小比率时,您隐含地假设您实际上可以用较弱的语言编写程序。

But in fact there are limits on what programmers can do.

但实际上程序员能做的事情是有限的。

If you're trying to solve a hard problem with a language that's too low-level, you reach a point where there is just too much to keep in your head at once.

如果你试图用一种太低级的语言来解决一个难题,那么你就会达到一个需要同时记住太多东西的地步。

So when I say it would take ITA's imaginary competitor five years to duplicate something ITA could write in Lisp in three months, I mean five years if nothing goes wrong.

因此,当我说 ITA 想象中的竞争对手需要五年时间才能复制 ITA 可以在三个月内用 Lisp 编写的东西时,我的意思是如果不出问题的话需要五年。

In fact, the way things work in most companies, any development project that would take five years is likely never to get finished at all.

事实上,按照大多数公司的运作方式,任何需要五年的开发项目都可能永远无法完成。

I admit this is an extreme case.

我承认这是一个极端的例子。

ITA's hackers seem to be unusually smart, and C is a pretty low-level language.

ITA 的黑客似乎异常聪明,而 C 是一种相当低级的语言。

But in a competitive market, even a differential of two or three to one would be enough to guarantee that you'd always be behind.

但在竞争激烈的市场中,即使是二比三或三比一的差距也足以保证你永远落后。

A Recipe This is the kind of possibility that the pointy-haired boss doesn't even want to think about.

菜谱 这是尖头老大连想都不敢想的一种可能性。

And so most of them don't.

所以他们中的大多数人都没有。

Because, you know, when it comes down to it, the pointy-haired boss doesn't mind if his company gets their ass kicked, so long as no one can prove it's his fault.

因为,你知道,归根结底,尖头老板并不介意他的公司被踢,只要没有人能证明这是他的错。

The safest plan for him personally is to stick close to the center of the herd.

对他个人来说,最安全的计划就是紧贴牛群的中心。

Within large organizations, the phrase used to describe this approach is "industry best practice." Its purpose is to shield the pointy-haired boss from responsibility: if he chooses something that is "industry best practice," and the company loses, he can't be blamed.

在大型组织中,用于描述这种方法的短语是“行业最佳实践”。其目的是让尖头老板免于承担责任:如果他选择了“行业最佳实践”,而公司失败了,就不能责怪他。

He didn't choose, the industry did.

不是他选择的,而是行业选择的。

I believe this term was originally used to describe

我相信这个词最初是用来描述

accounting methods and so on.

会计方法等。

What it means, roughly, is don't do anything weird.

粗略地说,这意味着不要做任何奇怪的事情。

And in accounting that's probably a good idea.

在会计领域这可能是个好主意。

The terms "cutting-edge" and "accounting" do not sound good together.

“尖端”和“会计”这两个词放在一起听起来不太好。

But when you import this criterion into decisions about technology, you start to get the wrong answers.

但当你将此标准纳入技术决策时,你就会开始得到错误的答案。

Technology often should be cutting-edge.

技术往往应该是前沿的。

In programming languages, as Erann Gat has pointed out, what "industry best practice" actually

正如 Erann Gat 所指出的,在编程语言中,“行业最佳实践”实际上是什么?

gets you is not the best, but merely the average.

给你的并不是最好的,而只是平均水平。

When a decision causes you to develop software at a fraction of the rate of more aggressive competitors, "best practice" is a misnomer.

当某个决定导致您的软件开发速度仅为更具侵略性的竞争对手的一小部分时,“最佳实践”就用词不当了。

So here we have two pieces of information that I think are very valuable.

所以这里有两条我认为非常有价值的信息。

In fact, I know it from my own experience.

事实上,我从自己的经历中知道这一点。

Number 1, languages vary in power.

第一,语言的力量不同。

Number 2, most managers deliberately ignore this.

第二,大多数管理者故意忽视这一点。

Between them, these two facts

在他们之间,这两个事实

are literally a recipe for making money.

确实是赚钱的秘诀。

ITA is an example of this recipe in action.

ITA 就是这个方法的一个实际例子。

If you want to win in a software business, just take on the hardest problem you can find, use the most powerful language you can get, and wait for your competitors' pointy-haired bosses to revert to the mean.

如果你想在软件行业获胜,只需解决你能找到的最难的问题,使用你能得到的最强大的语言,然后等待你的竞争对手的尖头发老板恢复平均水平。

Appendix: Power As an illustration of what I mean about the relative power of programming languages, consider the following problem.

附录:力量 为了说明我所说的编程语言的相对力量,请考虑以下问题。

We want to write a function that generates accumulators-- a function that takes a number n, and returns a function that takes another number i and returns n incremented by i.

我们想要编写一个生成累加器的函数——一个接受数字 n 的函数,并返回一个接受另一个数字 i 并返回按 i 递增的 n 的函数。

(That's incremented by , not plus.

(这是增加的,而不是加上。

An accumulator has to accumulate.) In Common Lisp this would be (defun foo (n) (lambda (i) (incf n i)))

累加器必须累加。)在 Common Lisp 中,这将是 (defun foo (n) (lambda (i) (incf n i)))

中文为机器翻译,仅供参考。