Glean 拾遗
专辑 / Paul Graham 文集 / Lisp 的根源:McCarthy 如何用七个操作符定义一种语言

Lisp 的根源:McCarthy 如何用七个操作符定义一种语言

原文 www.paulgraham.com 收录 2026-07-07 14:43 阅读 2 min
AI 解读

Paul Graham 在这篇文章中重新审视了 John McCarthy 1960 年关于 Lisp 的原始论文,解释了如何仅用七个基本操作符(atom、quote、car、cdr、cons、eq、cond)和函数定义即可构建一个完整的编程语言。文章通过将 McCarthy 的数学符号转化为可运行的 Common Lisp 代码,展示了 Lisp 的核心特性——可以用自身编写(self-defining),并论证了 Lisp 和 C 是编程的两个最干净模型,而现代语言正逐渐趋近 Lisp 模型。适合对编程语言历史、语言设计原理感兴趣的读者。

原文 2 分钟
原文 www.paulgraham.com ↗
§ 1

(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.)

(我写这篇文章是为了帮助自己确切理解麦卡锡的发现。你不必了解这些也能用 Lisp 编程,但对于想要理解 Lisp 本质——既包括其起源,也包括其语义核心——的人来说,这应该会有帮助。拥有这样一个核心是 Lisp 的显著特征之一,也是为何与其他语言不同,Lisp 有方言的原因。)

§ 2

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.

1960 年,约翰·麦卡锡发表了一篇卓越的论文,他对编程所做的工作,类似于欧几里得对几何所做的工作。他展示了:只要给定少量简单的操作符和一种函数表示法,就能构建出一整套编程语言。他将这种语言命名为 Lisp,即“列表处理”,因为他的一个关键想法是使用一种名为列表的简单数据结构来表示代码和数据。

§ 3

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.

理解麦卡锡的发现是值得的,这不仅因为它是一块计算机史上的里程碑,更因为它为当今编程语言的发展趋势提供了模型。在我看来,迄今为止存在两种真正简洁、一致的编程模型:C 模型和 Lisp 模型。两者如同高地据点,中间是泥泞的低地。随着计算机性能日益强大,新开发的语言正稳步朝着 Lisp 模型靠近。过去二十年,新编程语言的一个流行配方是:以 C 计算模型为基底,逐步从 Lisp 模型中摘取部分特性添加进去,例如运行时类型检查和垃圾回收。

§ 4

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.

在本文中,我将尝试用尽可能简单的语言解释麦卡锡的发现。目的不仅是了解四十年前某个有趣的理论成果,而是要展示语言未来的方向。Lisp 的不寻常之处——事实上,也是 Lisp 的决定性特质——在于它可以用自身来书写。为了理解麦卡锡这句话的含义,我们将重走他的足迹,把他的数学符号翻译成可运行的 Common Lisp 代码。

打开原文 ↗