2001 年 5 月 (我写这篇文章是为了帮助自己准确理解麦卡锡(McCarthy)当年的发现。写 Lisp 程序并不一定非要懂得这些,但对于任何想要理解 Lisp 本质——无论是其历史起源还是其语义核心——的人来说,这应该都会有所帮助。拥有这样一个核心是 Lisp 的显著特征之一,也是为什么 Lisp 会有各种方言,而其他语言却没有的原因。)

May 2001 (I wrote this article to help myself understand exactly what McCarthy discovered. You don't need to know this stuff to program in Lisp, but it should be helpful to anyone who wants to understand the essence of Lisp � both in the sense of its origins and its semantic core. The fact that it has such a core is one of Lisp's distinguishing features, and the reason why, unlike other languages, Lisp has dialects.)

1960 年,约翰·麦卡锡发表了一篇非凡的论文,他在编程领域所做的工作,堪比欧几里得在几何学中所做的一切。他展示了如何仅凭几个简单的运算符和一种函数表示法,就能构建出一门完整的编程语言。他将这门语言命名为 Lisp,即“列表处理”(List Processing)的缩写,因为他的核心想法之一就是使用一种名为“列表”(list)的简单数据结构来同时表示代码和数据。

In 1960, John McCarthy published a remarkable paper in which he did for programming something like what Euclid did for geometry. He showed how, given a handful of simple operators and a notation for functions, you can build a whole programming language. He called this language Lisp, for "List Processing," because one of his key ideas was to use a simple data structure called a list for both code and data.

理解麦卡锡的发现是非常有价值的,这不仅因为它是计算机历史上的一个里程碑,更因为它为我们这个时代编程的发展趋势提供了一个典范。在我看来,迄今为止只有两种真正清晰、一致的编程模型:C 模型和 Lisp 模型。这两者就像是两座高峰,中间隔着一片泥泞的低谷。随着计算机变得越来越强大,新开发出来的语言一直在稳步迈向 Lisp 模型。过去 20 年里,设计新编程语言的一个流行配方就是:采用 C 语言的计算模型,然后零敲碎打地从 Lisp 模型中借鉴一些元素,比如运行时类型检查和垃圾回收。

It's worth understanding what McCarthy discovered, not just as a landmark in the history of computers, but as a model for what programming is tending to become in our own time. It seems to me that there have been two really clean, consistent models of programming so far: the C model and the Lisp model. These two seem points of high ground, with swampy lowlands between them. As computers have grown more powerful, the new languages being developed have been moving steadily toward the Lisp model. A popular recipe for new programming languages in the past 20 years has been to take the C model of computing and add to it, piecemeal, parts taken from the Lisp model, like runtime typing and garbage collection.

在这篇文章中,我将尝试用最通俗易懂的语言来解释麦卡锡的发现。这不仅是为了了解一个四十年前有人琢磨出来的有趣理论成果,更是为了展示编程语言未来的发展方向。Lisp 与众不同之处——事实上,也是 Lisp 的定义性特征——在于它可以用自身来编写。为了理解麦卡锡这句话的含义,我们将重温他的探索足迹,并将其数学表示法转化为可以实际运行的 Common Lisp 代码。

In this article I'm going to try to explain in the simplest possible terms what McCarthy discovered. The point is not just to learn about an interesting theoretical result someone figured out forty years ago, but to show where languages are heading. The unusual thing about Lisp � in fact, the defining quality of Lisp � is that it can be written in itself. To understand what McCarthy meant by this, we're going to retrace his steps, with his mathematical notation translated into running Common Lisp code.