Loading...
墨滴

逸之

2022/01/03  阅读:45  主题:红绯

How Lisp Became God's Own Programming Language

How Lisp Became God's Own Programming Language

When programmers discuss the relative merits of different programming languages, they often talk about them in prosaic terms as if they were so many tools in a tool belt—one might be more appropriate for systems programming, another might be more appropriate for gluing together other programs to accomplish some ad hoc task. This is as it should be. Languages have different strengths and claiming that a language is better than other languages without reference to a specific use case only invites an unproductive and vitriolic debate.

当程序员讨论不同编程语言的相对优点时,他们常常用平淡的词语来谈论这些语言,好像它们是一个工具带中的许多工具一样ーー一种可能更适合于系统编程,另一种可能更适合于将其他程序粘合在一起来完成一些临时任务。这是理所当然的。语言有不同的优势,声称一种语言比其他语言更好,而没有提到一个具体的用例,只会招致一场徒劳无益的尖酸刻薄的辩论。

But there is one language that seems to inspire a peculiar universal reverence: Lisp. Keyboard crusaders that would otherwise pounce on anyone daring to suggest that some language is better than any other will concede that Lisp is on another level. Lisp transcends the utilitarian criteria used to judge other languages, because the median programmer has never used Lisp to build anything practical and probably never will, yet the reverence for Lisp runs so deep that Lisp is often ascribed mystical properties. Everyone’s favorite webcomic, xkcd, has depicted Lisp this way at least twice: In one comic, a character reaches some sort of Lisp enlightenment, which appears to allow him to comprehend the fundamental structure of the universe. In another comic, a robed, senescent programmer hands a stack of parentheses to his padawan, saying that the parentheses are “elegant weapons for a more civilized age,” suggesting that Lisp has all the occult power of the Force.

但是有一种语言似乎激发了一种特殊的普遍的敬畏之情: Lisp。键盘爱好者们会攻击那些敢于说某种语言比其他任何语言都好的人,他们承认 Lisp 是另一个层次的语言。超越了用来评判其他语言的功利主义标准,因为中间程序员从未使用 Lisp 构建任何实用的东西,而且可能永远也不会使用,然而对 Lisp 的崇敬如此之深,以至于 Lisp 经常被归结为神秘属性。每个人最喜欢的网络漫画 xkcd 至少两次这样描述 Lisp: 在一本漫画中,一个角色得到了某种 Lisp 启示,这似乎让他理解了宇宙的基本结构。在另一本漫画中,一个穿着长袍、年老的程序员给他的学徒递了一堆括号,说括号是“更文明时代的优雅武器”,暗示 Lisp 拥有原力的所有神秘力量。

Another great example is Bob Kanefsky’s parody of a song called “God Lives on Terra.” His parody, written in the mid-1990s and called “Eternal Flame”, describes how God must have created the world using Lisp. The following is an excerpt, but the full set of lyrics can be found in the GNU Humor Collection:

另一个很好的例子是 Bob Kanefsky 对一首名为“ God Lives on Terra”的歌曲的拙劣模仿他的拙劣模仿作品写于20世纪90年代中期,名为“永恒的火焰”,描述了上帝如何用 Lisp 创造了世界。下面是一段摘录,但是完整的歌词可以在 GNU Humor 合集中找到:

For God wrote in Lisp code
When he filled the leaves with green.
The fractal flowers and recursive roots:
The most lovely hack I’ve seen.
And when I ponder snowflakes,
never finding two the same,
I know God likes a language
with its own four-letter name.

因为上帝用 Lisp 代码写下,当他用绿色填满树叶时。分形花朵和递归根: 我见过的最可爱的黑客。当我思考雪花的时候,从来没有发现两片一样的雪花,我知道上帝喜欢有自己四个字母名字的语言。

I can only speak for myself, I suppose, but I think this “Lisp Is Arcane Magic” cultural meme is the most bizarre and fascinating thing ever. Lisp was concocted in the ivory tower as a tool for artificial intelligence research, so it was always going to be unfamiliar and maybe even a bit mysterious to the programming laity. But programmers now urge each other to “try Lisp before you die” as if it were some kind of mind-expanding psychedelic. They do this even though Lisp is now the second-oldest programming language in widespread use, younger only than Fortran, and even then by just one year.1 Imagine if your job were to promote some new programming language on behalf of the organization or team that created it. Wouldn’t it be great if you could convince everyone that your new language had divine powers? But how would you even do that? How does a programming language come to be known as a font of hidden knowledge?

我只能为自己说话,我想,但我认为这个“ Lisp 是神秘的魔法”的文化迷因是有史以来最奇异和迷人的事情。Lisp 是在象牙塔里创造出来作为人工智能研究的工具,所以对于普通编程人员来说,它总是很陌生,甚至可能有点神秘。但是现在程序员们互相督促“在你死之前试试 Lisp”,好像它是某种扩展思维的迷幻剂。尽管 Lisp 是目前广泛使用的第二古老的编程语言,只比 Fortran 年轻,甚至只比 Fortran 年轻一岁,他们仍然这样做。想象一下,如果你的工作是代表创造它的组织或团队推广一些新的编程语言。如果你能让每个人都相信你的新语言有神圣的力量,那不是很棒吗?但是你怎么能这么做呢?一种编程语言是如何被称为隐藏知识的字体的?

How did Lisp get to be this way?

为什么 Lisp 会变成这样?

The cover of Byte Magazine, August, 1979.

字节杂志封面,1979年8月。

Theory A: The Axiomatic Language

理论 a: 公理化语言

John McCarthy, Lisp’s creator, did not originally intend for Lisp to be an elegant distillation of the principles of computation. But, after one or two fortunate insights and a series of refinements, that’s what Lisp became. Paul Graham—we will talk about him some more later—has written that, with Lisp, McCarthy “did for programming something like what Euclid did for geometry.”2 People might see a deeper meaning in Lisp because McCarthy built Lisp out of parts so fundamental that it is hard to say whether he invented it or discovered it.

Lisp 的创建者 John McCarthy 最初并不打算让 Lisp 成为计算原则的一个优雅的提炼。但是,在一两个幸运的见解和一系列的改进之后,Lisp 就变成了这样。保罗 · 格雷厄姆(Paul graham)——我们稍后会谈到他——写道,在 Lisp 中,麦卡锡“为编程做了一些像欧几里德为几何所做的事情”2. 人们可能在 Lisp 中看到了更深层次的含义,因为 McCarthy 构建 Lisp 的部分非常基础,很难说是他发明的还是他发现的。

McCarthy began thinking about creating a language during the 1956 Darthmouth Summer Research Project on Artificial Intelligence. The Summer Research Project was in effect an ongoing, multi-week academic conference, the very first in the field of artificial intelligence. McCarthy, then an assistant professor of Mathematics at Dartmouth, had actually coined the term “artificial intelligence” when he proposed the event.3 About ten or so people attended the conference for its entire duration.4 Among them were Allen Newell and Herbert Simon, two researchers affiliated with the RAND Corporation and Carnegie Mellon that had just designed a language called IPL.

麦卡锡在1956年达斯茅斯夏季人工智能研究项目期间开始考虑创造一门语言。这个暑期研究项目实际上是一个持续多周的学术会议,是人工智能领域的第一次会议。在整个会议期间,大约有10个人参加了会议,其中包括 Allen Newell 和 Herbert Simon,这两位研究人员隶属于兰德公司和卡内基梅隆大学,他们刚刚设计了一种名为 IPL 的语言。

Newell and Simon had been trying to build a system capable of generating proofs in propositional calculus. They realized that it would be hard to do this while working at the level of the computer’s native instruction set, so they decided to create a language—or, as they called it, a “pseudo-code”—that would help them more naturally express the workings of their “Logic Theory Machine.”5 Their language, called IPL for “Information Processing Language”, was more of a high-level assembly dialect then a programming language in the sense we mean today. Newell and Simon, perhaps referring to Fortran, noted that other “pseudo-codes” then in development were “preoccupied” with representing equations in standard mathematical notation.6 Their language focused instead on representing sentences in propositional calculus as lists of symbolic expressions. Programs in IPL would basically leverage a series of assembly-language macros to manipulate and evaluate expressions within one or more of these lists.

纽厄尔和西蒙一直在尝试建立一个能够在20世纪命题逻辑生成证明的系统。他们意识到,在计算机的本机指令集级别工作时很难做到这一点,因此他们决定创建一种语言——或者,他们称之为“伪代码”——来帮助他们更自然地表达“逻辑理论机器”的工作原理他们的语言,称为“信息处理语言”的 IPL,更像是一种高级汇编语言,而不是我们今天所说的程序设计语言。纽厄尔和西蒙也许指的是 Fortran,他们注意到当时正在发展的其他“伪代码”专注于用标准的数学符号表示方程。他们的语言专注于用符号表达式列表来表示命题逻辑中的句子。IPL 中的程序基本上利用一系列汇编语言宏来操作和计算这些列表中的一个或多个表达式。

McCarthy thought that having algebraic expressions in a language, Fortran-style, would be useful. So he didn’t like IPL very much.7 But he thought that symbolic lists were a good way to model problems in artificial intelligence, particularly problems involving deduction. This was the germ of McCarthy’s desire to create an algebraic list processing language, a language that would resemble Fortran but also be able to process symbolic lists like IPL.

麦卡锡认为在一种语言(fortran 风格)中使用代数表达式是有用的。所以他不太喜欢 IPL。但是他认为符号列表是一个很好的方法来模拟人工智能中的问题,特别是涉及演绎的问题。这就是麦卡锡想要创造一种代数列表处理语言的萌芽,这种语言类似于 Fortran,但是也能够处理象 IPL 这样的符号列表。

Of course, Lisp today does not resemble Fortran. Over the next few years, McCarthy’s ideas about what an ideal list processing language should look like evolved. His ideas began to change in 1957, when he started writing routines for a chess-playing program in Fortran. The prolonged exposure to Fortran convinced McCarthy that there were several infelicities in its design, chief among them the awkward IF statement.8 McCarthy invented an alternative, the “true” conditional expression, which returns sub-expression A if the supplied test succeeds and sub-expression B if the supplied test fails and which also only evaluates the sub-expression that actually gets returned. During the summer of 1958, when McCarthy worked to design a program that could perform differentiation, he realized that his “true” conditional expression made writing recursive functions easier and more natural.9 The differentiation problem also prompted McCarthy to devise the maplist function, which takes another function as an argument and applies it to all the elements in a list.10 This was useful for differentiating sums of arbitrarily many terms.

当然,Lisp 今天并不像 Fortran。在接下来的几年里,McCarthy 关于理想的列表处理语言应该是什么样子的想法有了进一步的发展。他的想法在1957年开始改变,当时他开始为 Fortran 的一个国际象棋程序写程序。8. McCarthy 发明了一种替代方法,“ true”条件表达式,如果提供的测试成功,它返回子表达式 a; 如果提供的测试失败,它返回子表达式 b; 如果提供的测试失败,它也只计算实际返回的子表达式。在1958年夏天,当 McCarthy 设计一个可以执行微分的程序时,他意识到他的“真”条件表达式使得编写递归函数变得更加容易和自然。微分问题也促使 McCarthy 设计了映射表函数,该函数将另一个函数作为参数,并将其应用于一个列表中的所有元素。

None of these things could be expressed in Fortran, so, in the fall of 1958, McCarthy set some students to work implementing Lisp. Since McCarthy was now an assistant professor at MIT, these were all MIT students. As McCarthy and his students translated his ideas into running code, they made changes that further simplified the language. The biggest change involved Lisp’s syntax. McCarthy had originally intended for the language to include something called “M-expressions,” which would be a layer of syntactic sugar that made Lisp’s syntax resemble Fortran’s. Though M-expressions could be translated to S-expressions—the basic lists enclosed by parentheses that Lisp is known for— S-expressions were really a low-level representation meant for the machine. The only problem was that McCarthy had been denoting M-expressions using square brackets, and the IBM 026 keypunch that McCarthy’s team used at MIT did not have any square bracket keys on its keyboard.11 So the Lisp team stuck with S-expressions, using them to represent not just lists of data but function applications too. McCarthy and his students also made a few other simplifications, including a switch to prefix notation and a memory model change that meant the language only had one real type.12

所有这些东西在 Fortran 都无法表达,因此,在1958年秋天,McCarthy 让一些学生开始实现 Lisp。因为麦卡锡现在是麻省理工学院的助理教授,这些都是麻省理工学院的学生。当麦卡锡和他的学生将他的想法转化为运行代码时,他们所做的改变进一步简化了语言。最大的变化是 Lisp 的语法。McCarthy 最初打算在语言中加入“ m 表达式”,这是一层使 Lisp 的语法类似于 Fortran 的语法。虽然 m 表达式可以转换为 s 表达式ーー Lisp 所熟知的用括号括起来的基本列表ーー s 表达式实际上是机器的底层表示。唯一的问题是,麦卡锡一直使用方括号来表示 m 表达式,而且麦卡锡团队在麻省理工学院使用的 IBM 026键穿孔机键盘上没有任何方括号键。11因此,Lisp 团队坚持使用 s 表达式,使用它们不仅表示数据列表,还表示函数应用程序。麦卡锡和他的学生们还进行了一些其他的简化,包括改用前缀标记法和改变记忆模型,这意味着语言只有一种实际类型

In 1960, McCarthy published his famous paper on Lisp called “Recursive Functions of Symbolic Expressions and Their Computation by Machine.” By that time, the language had been pared down to such a degree that McCarthy realized he had the makings of “an elegant mathematical system” and not just another programming language.13 He later wrote that the many simplifications that had been made to Lisp turned it “into a way of describing computable functions much neater than the Turing machines or the general recursive definitions used in recursive function theory.”14 In his paper, he therefore presented Lisp both as a working programming language and as a formalism for studying the behavior of recursive functions.

1960年,McCarthy 发表了他关于 Lisp 的著名论文《符号表达式的递归函数及其机器计算》到那时,该语言已被削减到如此程度,以至于麦卡锡意识到他具有“一个优雅的数学系统”的素质,而不仅仅是另一种编程语言。13他后来写道,对 Lisp 进行的许多简化使它“成为一种描述可计算函数的方式,比图灵机或函数理论中使用的一般递归定义更加简洁”14因此,在他的论文中,他提出 Lisp 既是一种工作的编程语言,也是一种研究递归函数行为的形式主义。

McCarthy explained Lisp to his readers by building it up out of only a very small collection of rules. Paul Graham later retraced McCarthy’s steps, using more readable language, in his essay “The Roots of Lisp”. Graham is able to explain Lisp using only seven primitive operators, two different notations for functions, and a half-dozen higher-level functions defined in terms of the primitive operators. That Lisp can be specified by such a small sequence of basic rules no doubt contributes to its mystique. Graham has called McCarthy’s paper an attempt to “axiomatize computation.”15 I think that is a great way to think about Lisp’s appeal. Whereas other languages have clearly artificial constructs denoted by reserved words like while or typedef or public static void, Lisp’s design almost seems entailed by the very logic of computing. This quality and Lisp’s original connection to a field as esoteric as “recursive function theory” should make it no surprise that Lisp has so much prestige today.

McCarthy 向他的读者解释 Lisp 时,只用了很少的一些规则。Paul Graham 后来在他的文章“ Lisp 的根源”中使用更具可读性的语言重新追溯了 McCarthy 的步骤。Graham 只能用七个原始运算符来解释 Lisp,两个不同的函数符号,以及用原始运算符定义的六个高级函数。Lisp 可以通过如此小的一系列基本规则来指定,这无疑增加了它的神秘性。格雷厄姆称麦卡锡的论文是“公理化计算”的尝试15我认为这是思考 Lisp 吸引力的一个很好的方式。虽然其他语言有明显的人工构造,如 while、 typedef 或 public static void,但 Lisp 的设计几乎是由计算的逻辑所引起的。这种特性以及 Lisp 与像“递归函数理论”这样深奥领域的最初联系,使得 Lisp 在今天拥有如此高的声望不足为奇。

Theory B: Machine of the Future

理论 b: 未来的机器

Two decades after its creation, Lisp had become, according to the famous Hacker’s Dictionary, the “mother tongue” of artificial intelligence research. Early on, Lisp spread quickly, probably because its regular syntax made implementing it on new machines relatively straightforward. Later, researchers would keep using it because of how well it handled symbolic expressions, important in an era when so much of artificial intelligence was symbolic. Lisp was used in seminal artificial intelligence projects like the SHRDLU natural language program, the Macsyma algebra system, and the ACL2 logic system.

根据著名的黑客字典,Lisp 在创建二十年后,已经成为人工智能研究的“母语”。在早期,Lisp 传播得很快,可能是因为它的常规语法使它在新机器上的实现相对简单。后来,研究人员继续使用它,因为它能很好地处理象征性表达,在人工智能如此多是象征性的时代,象征性表达很重要。Lisp 被用于开创性的人工智能项目,如 SHRDLU 自然语言程序、 Macsyma 代数系统和 acl2逻辑系统。

By the mid-1970s, though, artificial intelligence researchers were running out of computer power. The PDP-10, in particular—everyone’s favorite machine for artificial intelligence work—had an 18-bit address space that increasingly was insufficient for Lisp AI programs.16 Many AI programs were also supposed to be interactive, and making a demanding interactive program perform well on a time-sharing system was challenging. The solution, originally proposed by Peter Deutsch at MIT, was to engineer a computer specifically designed to run Lisp programs. These Lisp machines, as I described in my last post on Chaosnet, would give each user a dedicated processor optimized for Lisp. They would also eventually come with development environments written entirely in Lisp for hardcore Lisp programmers. Lisp machines, devised in an awkward moment at the tail of the minicomputer era but before the full flowering of the microcomputer revolution, were high-performance personal computers for the programming elite.

然而,到了20世纪70年代中期,人工智能研究人员的计算机能力已经耗尽。特别是 PDP-10——每个人最喜欢用于人工智能工作的机器——有一个18位的地址空间,对于 Lisp 人工智能程序来说越来越不够用。16许多人工智能程序也被认为是交互式的,让一个要求很高的交互程序在分时系统上表现良好是一个挑战。这个最初由麻省理工学院的 Peter Deutsch 提出的解决方案是设计一台专门用于运行 Lisp 程序的计算机。这些 Lisp 机器,正如我在 Chaosnet 的上一篇文章中所描述的,将为每个用户提供一个专门为 Lisp 优化的处理器。它们最终也会带来完全用 Lisp 编写的开发环境,这些开发环境是为 Lisp 的核心程序员准备的。Lisp 机器是在小型计算机时代末期、微型计算机革命全面开花之前的一个尴尬时刻设计出来的,是面向编程精英的高性能个人计算机。

For a while, it seemed as if Lisp machines would be the wave of the future. Several companies sprang into existence and raced to commercialize the technology. The most successful of these companies was called Symbolics, founded by veterans of the MIT AI Lab. Throughout the 1980s, Symbolics produced a line of computers known as the 3600 series, which were popular in the AI field and in industries requiring high-powered computing. The 3600 series computers featured large screens, bit-mapped graphics, a mouse interface, and powerful graphics and animation software. These were impressive machines that enabled impressive programs. For example, Bob Culley, who worked in robotics research and contacted me via Twitter, was able to implement and visualize a path-finding algorithm on a Symbolics 3650 in 1985. He explained to me that bit-mapped graphics and object-oriented programming (available on Lisp machines via the Flavors extension) were very new in the 1980s. Symbolics was the cutting edge.

有一段时间,Lisp 机器似乎将成为未来的潮流。几家公司迅速成立,并迅速将这项技术商业化。这些公司中最成功的叫做 Symbolics,由麻省理工学院人工智能实验室的资深人员创立。在整个20世纪80年代,Symbolics 生产了一系列被称为3600系列的计算机,这些计算机在人工智能领域和需要高性能计算的行业中很受欢迎。该3600系列计算机的特点是大屏幕,位图图形,鼠标界面,强大的图形和动画软件。这些令人印象深刻的机器使得令人印象深刻的程序成为可能。例如,Bob Culley 在机器人研究领域工作,他通过 Twitter 与我联系,他在1985年就能够在 Symbolics 3650上实现并可视化路径搜索算法。他向我解释说,位映射图形和面向对象程序设计文件(通过 flavor 扩展在 Lisp 机器上可用)在20世纪80年代是非常新的。象征主义是前沿。

Bob Culley’s path-finding program.

Bob Culley 的路径查找程序。

As a result, Symbolics machines were outrageously expensive. The Symbolics 3600 cost $110,000 in 1983.16 So most people could only marvel at the power of Lisp machines and the wizardry of their Lisp-writing operators from afar. But marvel they did. Byte Magazine featured Lisp and Lisp machines several times from 1979 through to the end of the 1980s. In the August, 1979 issue, a special on Lisp, the magazine’s editor raved about the new machines being developed at MIT with “gobs of memory” and “an advanced operating system.”17 He thought they sounded so promising that they would make the two prior years—which saw the launch of the Apple II, the Commodore PET, and the TRS-80—look boring by comparison. A half decade later, in 1985, a Byte Magazine contributor described writing Lisp programs for the “sophisticated, superpowerful Symbolics 3670” and urged his audience to learn Lisp, claiming it was both “the language of choice for most people working in AI” and soon to be a general-purpose programming language as well.18

因此,Symbolics 机器的价格高得惊人。在1983年,Symbolics 3600售价为11万美元。16. 因此,大多数人只能从远处惊叹 Lisp 机器的威力和它们的 Lisp 编写操作符的魔法。但他们做到了,真是令人惊奇。从1979年到20世纪80年代末,Byte Magazine 曾多次推出 Lisp 和 Lisp 机器。在1979年8月的一期 Lisp 特刊中,该杂志的编辑极力赞扬麻省理工学院正在开发的具有“大量内存”和“先进操作系统”的新机器17. 他认为这些计划听起来很有前途,相比之下,前两年——苹果 II 型、康莫多 PET 型和 trs-80型的发布——就显得乏味了。五年之后,也就是1985年,一位《字节》杂志的撰稿人描述了为“复杂、超级强大的 Symbolics 3670”编写 Lisp 程序的经历,并敦促他的读者学习 Lisp,声称 Lisp 既是“大多数人工智能工作者的首选语言”,很快也将成为一门通用编程语言

I asked Paul McJones, who has done lots of Lisp preservation work for the Computer History Museum in Mountain View, about when people first began talking about Lisp as if it were a gift from higher-dimensional beings. He said that the inherent properties of the language no doubt had a lot to do with it, but he also said that the close association between Lisp and the powerful artificial intelligence applications of the 1960s and 1970s probably contributed too. When Lisp machines became available for purchase in the 1980s, a few more people outside of places like MIT and Stanford were exposed to Lisp’s power and the legend grew. Today, Lisp machines and Symbolics are little remembered, but they helped keep the mystique of Lisp alive through to the late 1980s.

我问了 Paul McJones,他为山景城的计算机历史博物馆做了很多 Lisp 保存工作,关于人们什么时候开始谈论 Lisp,好像它是高维存在的礼物一样。他说,这种语言的固有属性无疑与它有很大关系,但他也说,Lisp 与1960年代和1970年代强大的人工智能应用程序之间的紧密联系可能也起到了一定作用。当 Lisp 机器在20世纪80年代开始出售时,麻省理工学院和斯坦福大学之外的一些人接触到了 Lisp 的力量,这个传奇也随之成长。今天,Lisp 机器和 Symbolics 已经很少被人们记住了,但是它们帮助 Lisp 的神秘性一直延续到20世纪80年代末。

Theory C: Learn to Program

理论 c: 学习编程

In 1985, MIT professors Harold Abelson and Gerald Sussman, along with Sussman’s wife, Julie Sussman, published a textbook called Structure and Interpretation of Computer Programs. The textbook introduced readers to programming using the language Scheme, a dialect of Lisp. It was used to teach MIT’s introductory programming class for two decades. My hunch is that SICP (as the title is commonly abbreviated) about doubled Lisp’s “mystique factor.” SICP took Lisp and showed how it could be used to illustrate deep, almost philosophical concepts in the art of computer programming. Those concepts were general enough that any language could have been used, but SICP’s authors chose Lisp. As a result, Lisp’s reputation was augmented by the notoriety of this bizarre and brilliant book, which has intrigued generations of programmers (and also become a very strange meme). Lisp had always been “McCarthy’s elegant formalism”; now it was also “that language that teaches you the hidden secrets of programming.”

1985年,麻省理工学院教授 Harold Abelson 和 Gerald Sussman 与 Sussman 的妻子 Julie Sussman 共同出版了一本名为《计算机程序的构造和解释。教科书向读者介绍了使用 Lisp 的一种方言——语言 Scheme 进行编程。二十年来,它被用来教麻省理工学院的编程入门课程。我的直觉是,SICP (书名通常缩写)使 Lisp 的“神秘因素”增加了一倍接受了 Lisp,并展示了如何用它来阐明计算机编程艺术中深刻的、几乎是哲学性的概念。这些概念非常通用,任何语言都可以使用,但是 SICP 的作者选择了 Lisp。因此,这本怪诞而出色的书的恶名让 Lisp 的声誉大增,这本书吸引了一代又一代程序员(同时也成为了一个非常奇怪的文化基因)。Lisp 一直是“麦卡锡优雅的形式主义”; 现在它也是“教你编程隐藏秘密的语言”

It’s worth dwelling for a while on how weird SICP really is, because I think the book’s weirdness and Lisp’s weirdness get conflated today. The weirdness starts with the book’s cover. It depicts a wizard or alchemist approaching a table, prepared to perform some sort of sorcery. In one hand he holds a set of calipers or a compass, in the other he holds a globe inscribed with the words “eval” and “apply.” A woman opposite him gestures at the table; in the background, the Greek letter lambda floats in mid-air, radiating light.

因为我认为这本书的怪异性和 Lisp 的怪异性在今天被混为一谈了。这本书的封面就是奇怪的开始。它描绘了一个巫师或炼金术士走近一张桌子,准备施行某种巫术。他一只手拿着一套卡尺或一个罗盘,另一只手拿着一个写有“ eval”和“ apply”字样的地球仪一个女人在他对面的桌子上做着手势; 在背景里,希腊字母“ λ”漂浮在半空中,散发着光芒。

The cover art for SICP.

Sicip 的封面设计。

Honestly, what is going on here? Why does the table have animal feet? Why is the woman gesturing at the table? What is the significance of the inkwell? Are we supposed to conclude that the wizard has unlocked the hidden mysteries of the universe, and that those mysteries consist of the “eval/apply” loop and the Lambda Calculus? It would seem so. This image alone must have done an enormous amount to shape how people talk about Lisp today.

老实说,这到底是怎么回事?为什么桌子上有动物的脚?那个女人为什么对着桌子做手势?墨水池的意义是什么?我们是否应该得出这样的结论: 巫师已经打开了宇宙中隐藏的秘密,而这些秘密是由“ eval/apply”循环和 Lambda 微积分组成的?看起来是这样。单单这张图片就足以塑造今天人们谈论 Lisp 的方式。

But the text of the book itself is often just as weird. SICP is unlike most other computer science textbooks that you have ever read. Its authors explain in the foreword to the book that the book is not merely about how to program in Lisp—it is instead about “three foci of phenomena: the human mind, collections of computer programs, and the computer.”19 Later, they elaborate, describing their conviction that programming shouldn’t be considered a discipline of computer science but instead should be considered a new notation for “procedural epistemology.”20 Programs are a new way of structuring thought that only incidentally get fed into computers. The first chapter of the book gives a brief tour of Lisp, but most of the book after that point is about much more abstract concepts. There is a discussion of different programming paradigms, a discussion of the nature of “time” and “identity” in object-oriented systems, and at one point a discussion of how synchronization problems may arise because of fundamental constraints on communication that play a role akin to the fixed speed of light in the theory of relativity.21 It’s heady stuff.

但是这本书的文字本身往往也同样奇怪。与你读过的大多数计算机科学教科书不同。该书的作者在该书的前言中解释说,该书不仅仅是关于如何用 lisp 编程,而是关于“三个焦点现象: 人类思维、计算机程序集和计算机”19后来,他们详细阐述,描述他们的信念,编程不应被视为一门计算机科学的学科,而应被视为一种新的符号为“程序认识论”20程序是一种新的结构化思维方式,只是偶然地输入到计算机中。本书的第一章简要介绍了 Lisp,但之后的大部分内容都是关于更抽象的概念。文章讨论了不同的编程范式,讨论了面向对象系统中“时间”和“身份”的本质,还讨论了同步问题是如何产生的,因为通信的基本约束起着类似于相对论中的光速的作用。

All this isn’t to say that the book is bad. It’s a wonderful book. It discusses important programming concepts at a higher level than anything else I have read, concepts that I had long wondered about but didn’t quite have the language to describe. It’s impressive that an introductory programming textbook can move so quickly to describing the fundamental shortfalls of object-oriented programming and the benefits of functional languages that minimize mutable state. It’s mind-blowing that this then turns into a discussion of how a stream paradigm, perhaps something like today’s RxJS, can give you the best of both worlds. SICP distills the essence of high-level program design in a way reminiscent of McCarthy’s original Lisp paper. The first thing you want to do after reading it is get your programmer friends to read it; if they look it up, see the cover, but then don’t read it, all they take away is that some mysterious, fundamental “eval/apply” thing gives magicians special powers over tables with animal feet. I would be deeply impressed in their shoes too.

所有这些并不是说这本书不好。这是一本很棒的书。它在更高的层次上讨论了重要的编程概念,比我读过的任何其他概念都要深入,这些概念我一直想知道,但是没有足够的语言来描述。令人印象深刻的是,一本介绍性的编程教科书可以如此迅速地描述面向对象程序设计语言的基本缺陷,以及将可变状态降到最低的函数式语言的好处。令人兴奋的是,接下来我们将讨论流范式(比如今天的 RxJS)如何能够同时满足两个世界的要求。SICP 提炼了高级程序设计的精髓,这种方式让人想起 McCarthy 最初的 Lisp 论文。读完这本书后,你要做的第一件事就是让你的程序员朋友们去读它; 如果他们查看了它,看到了封面,但是没有去读,他们带走的只是一些神秘的,基本的“ eval/apply”东西给了魔术师对于动物脚桌子的特殊能力。如果我是他们,我也会对他们印象深刻。

But maybe SICP’s most important contribution was to elevate Lisp from curious oddity to pedagogical must-have. Well before SICP, people told each other to learn Lisp as a way of getting better at programming. The 1979 Lisp issue of Byte Magazine is testament to that fact. The same editor that raved about MIT’s new Lisp machines also explained that the language was worth learning because it “represents a different point of view from which to analyze problems.”22 But SICP presented Lisp as more than just a foil for other languages; SICP used Lisp as an introductory language, implicitly making the argument that Lisp is the best language in which to grasp the fundamentals of computer programming. When programmers today tell each other to try Lisp before they die, they arguably do so in large part because of SICP. After all, the language Brainfuck presumably offers “a different point of view from which to analyze problems.” But people learn Lisp instead because they know that, for twenty years or so, the Lisp point of view was thought to be so useful that MIT taught Lisp to undergraduates before anything else.

但是,也许 SICP 最重要的贡献是将 Lisp 从奇怪的怪异提升为教学必备。早在 SICP 之前,人们就告诉彼此学习 Lisp 作为提高编程能力的一种方式。1979年发行的 Lisp 字节杂志就证明了这一点。那个对 MIT 的新 Lisp 机器赞不绝口的编辑也解释说,这门语言值得学习,因为它“代表了分析问题的不同观点”22. 但是 SICP 不仅仅把 Lisp 当作其他语言的陪衬; SICP 把 Lisp 当作一种导论语言,含蓄地表明 Lisp 是掌握计算机编程基础的最佳语言。当今的程序员告诉彼此在死之前尝试 Lisp 时,他们之所以这样做,很大程度上可以说是因为 SICP。毕竟,Brainfuck 这种语言大概提供了“一种分析问题的不同观点”但是人们学习 Lisp 是因为他们知道,在过去的二十年左右的时间里,Lisp 的观点被认为是非常有用的,以至于麻省理工学院首先把 Lisp 教给了本科生。

Lisp Comes Back

返回 Lisp

The same year that SICP was released, Bjarne Stroustrup published the first edition of The C++ Programming Language, which brought object-oriented programming to the masses. A few years later, the market for Lisp machines collapsed and the AI winter began. For the next decade and change, C++ and then Java would be the languages of the future and Lisp would be left out in the cold.

在 SICP 发布的同一年,比雅尼·斯特劳斯特鲁普出版了第一版的《 C++程式语言志,将面向对象程序设计带给了大众。几年后,Lisp 机器的市场崩溃了,AI 的冬天开始了。在接下来的十年和变化中,c + + 和 Java 将成为未来的语言,而 Lisp 将被冷落。

It is of course impossible to pinpoint when people started getting excited about Lisp again. But that may have happened after Paul Graham, Y-Combinator co-founder and Hacker News creator, published a series of influential essays pushing Lisp as the best language for startups. In his essay “Beating the Averages,” for example, Graham argued that Lisp macros simply made Lisp more powerful than other languages. He claimed that using Lisp at his own startup, Viaweb, helped him develop features faster than his competitors were able to. Some programmers at least were persuaded. But the vast majority of programmers did not switch to Lisp.

当然不可能确定人们是什么时候又开始对 Lisp 感到兴奋的。但在 Y-Combinator 联合创始人、 Hacker News 创始人保罗•格雷厄姆(Paul Graham)发表了一系列有影响力的文章,推动 Lisp 成为最适合创业公司使用的语言之后,这种情况可能已经发生了。例如,格雷厄姆在他的文章“打败平均值”中提出,Lisp 宏只是让 Lisp 比其他语言更强大。他声称,在他自己的创业公司 Viaweb 上使用 Lisp,帮助他以比竞争对手更快的速度开发特性。至少一些程序员被说服了。但是绝大多数程序员并没有切换到 Lisp。

What happened instead is that more and more Lisp-y features have been incorporated into everyone’s favorite programming languages. Python got list comprehensions. C# got Linq. Ruby got… well, Ruby is a Lisp. As Graham noted even back in 2001, “the default language, embodied in a succession of popular languages, has gradually evolved toward Lisp.”23 Though other languages are gradually becoming like Lisp, Lisp itself somehow manages to retain its special reputation as that mysterious language that few people understand but everybody should learn. In 1980, on the occasion of Lisp’s 20th anniversary, McCarthy wrote that Lisp had survived as long as it had because it occupied “some kind of approximate local optimum in the space of programming languages.”24 That understates Lisp’s real influence. Lisp hasn’t survived for over half a century because programmers have begrudgingly conceded that it is the best tool for the job decade after decade; in fact, it has survived even though most programmers do not use it at all. Thanks to its origins and use in artificial intelligence research and perhaps also the legacy of SICP, Lisp continues to fascinate people. Until we can imagine God creating the world with some newer language, Lisp isn’t going anywhere.

取而代之的是,越来越多的 lisp 特性被纳入到每个人最喜欢的编程语言中。得到了 list comprehension。C # 得到了 Linq。Ruby 得到了... 好吧,Ruby 是一个 Lisp。正如 Graham 早在2001年就指出的那样,“默认语言体现在一系列流行语言中,逐渐演变为 Lisp 语言。”23. 尽管其他语言正逐渐变得像 Lisp 一样,但 Lisp 本身却以某种方式保持了它的特殊声誉,它是一种很少有人能理解但是每个人都应该学习的神秘语言。1980年,在 Lisp 诞生20周年之际,McCarthy 写道,Lisp 之所以能存在这么久,是因为它占据了“编程语言空间中某种近似的局部最优空间”24. 这低估了 Lisp 的真正影响力。在过去的半个多世纪里,Lisp 一直没有存活下来,因为程序员们不情愿地承认,它是这项工作十几年来最好的工具; 事实上,尽管大多数程序员根本不使用它,它还是存活了下来。由于它的起源和在人工智能研究中的应用,也许还有 SICP 的遗产,Lisp 继续吸引着人们。除非我们能够想象上帝用一些更新的语言创造了这个世界,否则 Lisp 不会走向任何地方。

Previously on TwoBitHistory…

前情提要。

  1. John McCarthy, “History of Lisp”, 14, Stanford University, February 12, 1979, accessed October 14, 2018, http://jmc.stanford.edu/articles/lisp/lisp.pdf

  2. Paul Graham, “The Roots of Lisp”, 1, January 18, 2002, accessed October 14, 2018, http://languagelog.ldc.upenn.edu/myl/llog/jmc.pdf

  3. Martin Childs, “John McCarthy: Computer scientist known as the father of AI”, The Independent, November 1, 2011, accessed on October 14, 2018, https://www.independent.co.uk/news/obituaries/john-mccarthy-computer-scientist-known-as-the-father-of-ai-6255307.html

  4. Lisp Bulletin History. http://www.artinfo-musinfo.org/scans/lb/lb3f.pdf 

  5. Allen Newell and Herbert Simon, “Current Developments in Complex Information Processing,” 19, May 1, 1956, accessed on October 14, 2018, http://bitsavers.org/pdf/rand/ipl/P-850_Current_Developments_In_Complex_Information_Processing_May56.pdf

  6. ibid. 

  7. Herbert Stoyan, “Lisp History”, 43, Lisp Bulletin #3, December 1979, accessed on October 14, 2018, http://www.artinfo-musinfo.org/scans/lb/lb3f.pdf 

  8. McCarthy, “History of Lisp”, 5. 

  9. ibid. 

  10. McCarthy “History of Lisp”, 6. 

  11. Stoyan, “Lisp History”, 45 

  12. McCarthy, “History of Lisp”, 8. 

  13. McCarthy, “History of Lisp”, 2. 

  14. McCarthy, “History of Lisp”, 8. 

  15. Graham, “The Roots of Lisp”, 11. 

  16. Guy Steele and Richard Gabriel, “The Evolution of Lisp”, 22, History of Programming Languages 2, 1993, accessed on October 14, 2018, http://www.dreamsongs.com/Files/HOPL2-Uncut.pdf 2

  17. Carl Helmers, “Editorial”, Byte Magazine, 154, August 1979, accessed on October 14, 2018, https://archive.org/details/byte-magazine-1979-08/page/n153

  18. Patrick Winston, “The Lisp Revolution”, 209, April 1985, accessed on October 14, 2018, https://archive.org/details/byte-magazine-1985-04/page/n207

  19. Harold Abelson, Gerald Jay. Sussman, and Julie Sussman, Structure and Interpretation of Computer Programs (Cambridge, Mass: MIT Press, 2010), xiii. 

  20. Abelson, xxiii. 

  21. Abelson, 428. 

  22. Helmers, 7. 

  23. Paul Graham, “What Made Lisp Different”, December 2001, accessed on October 14, 2018, http://www.paulgraham.com/diff.html

  24. John McCarthy, “Lisp—Notes on its past and future”, 3, Stanford University, 1980, accessed on October 14, 2018, http://jmc.stanford.edu/articles/lisp20th/lisp20th.pdf

逸之

2022/01/03  阅读:45  主题:红绯

作者介绍

逸之