Emacs Turns 50

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

Emacs Turns 50

Programming used to be a very different experience from the one we know today. In fact, the first programmers didn’t write code at all; the six women who worked on the ENIAC, one of the world’s first computers, at the University of Pennsylvania in 1946 did it by physically configuring switches, cables, and plugboards.

编程曾经是一种与我们今天所知的截然不同的体验。事实上,最早的程序员根本不写代码;1946 年在宾夕法尼亚大学为世界上第一台计算机之一 ENIAC 工作的六位女性,是通过物理配置开关、电缆和插线板来完成工作的。

A few years later, MIT engineers programmed the Whirlwind by punching code onto paper tape that was then loaded into the computer’s memory—making it among the first “stored-program” machines. Later, they and others moved on to punch cards, one for each line of code.

几年后,麻省理工学院的工程师们通过将代码打孔到纸带上,然后将其加载到计算机内存中来对 Whirlwind 进行编程,这使其成为最早的“存储程序”机器之一。后来,他们和其他人转而使用打孔卡,每一行代码对应一张卡片。

By the early 1960s, programmers with interactive computers could use a “line editor” to type their code on teletypes—large, noisy keyboard-and-printer machines. They’d type one line of code at a time, and their work would be saved on a spinning hard disk the size of a modern washing machine. But there was still no such thing as the now-familiar full-screen text editors that allow programmers to see and modify many lines at a time on a display.

到了 20 世纪 60 年代初,拥有交互式计算机的程序员可以使用“行编辑器”在电传打字机(一种大型、嘈杂的键盘和打印机设备)上输入代码。他们一次输入一行代码,工作成果会被保存在一台现代洗衣机大小的旋转硬盘上。但当时还没有现在人们所熟悉的、允许程序员在屏幕上同时查看和修改多行的全屏文本编辑器。

One of the first such tools, EMACS, turns 50 this year, and it is still widely used.

这类工具中的佼佼者之一 EMACS 今年迎来了 50 岁生日,并且至今仍被广泛使用。

EMACS first ran on the early video terminals at the MIT Artificial Intelligence Laboratory in 1976, but its core concepts were so powerful that it was rewritten for many operating systems in the decades that followed. Apple even distributed it with Mac OS X. Beyond that, the software-sharing community that started around EMACS helped give rise to the modern-day free software movement and the GNU/Linux operating system.

EMACS 最初于 1976 年在麻省理工学院人工智能实验室的早期视频终端上运行,但其核心概念非常强大,以至于在随后的几十年里,它被重写并移植到了许多操作系统上。苹果公司甚至曾将其随 Mac OS X 一起发布。此外,围绕 EMACS 形成的软件共享社区助力了现代自由软件运动和 GNU/Linux 操作系统的兴起。

EMACS’s roots begin with the TECO text editor (originally the “Tape Editor and Corrector”) that Dan Murphy ’65 created in 1962 for the pioneering PDP-1 computer at MIT. The program’s commands were uppercase letters: A user would type “I” to insert text, “D” to delete a character, and so on. When tape gave way as a storage medium to files on a huge shared disk, the “T” in “TECO” came to stand for “Text.” And as years passed, TECO became a full language that programmers could use to create new commands, called macros, for editing their code.

EMACS 的根源可以追溯到 1962 年由 Dan Murphy(65 届校友)为麻省理工学院开创性的 PDP-1 计算机创建的 TECO 文本编辑器(最初意为“磁带编辑器和校正器”)。该程序的命令是大写字母:用户输入“I”插入文本,输入“D”删除字符,依此类推。当磁带作为存储介质被大型共享磁盘上的文件取代时,“TECO”中的“T”便代表了“文本”。随着时间的推移,TECO 演变成了一种完整的语言,程序员可以用它来创建称为“宏”的新命令,用于编辑代码。

In the fall of 1971, Carl Mikkelsen ’76 created Control-R, an add-on program for TECO that took advantage of “glass teletype” terminals with video displays. Control-R immediately displayed changes to the file being edited on screen; the programmer no longer needed to reprint each line to see the changes. The drawback: The display could show only a few lines of code at a time.

1971 年秋,Carl Mikkelsen(76 届校友)创建了 Control-R,这是一个为 TECO 开发的附加程序,利用了带有视频显示器的“玻璃电传打字机”终端。Control-R 可以立即在屏幕上显示正在编辑的文件的更改;程序员不再需要重新打印每一行来查看更改。缺点是:显示屏一次只能显示几行代码。

“Experienced and sophisticated users found EMACS to be eminently more usable than any of the previous forms of editing.”

“经验丰富且老练的用户发现,EMACS 比之前任何形式的编辑工具都要好用得多。”

Then, in 1976, Richard M. Stallman, a researcher at the MIT AI Lab, saw a full-screen editor—called E—on a visit to Stanford’s AI Lab. Inspired, he returned to MIT and set out to improve Control-R. The most important change to the program’s underlying structure: Every key ran its own macro when pressed, making Control-R far easier to customize. The lab’s hackers took to Stallman’s code with gusto and started changing and adding commands.

1976 年,麻省理工学院人工智能实验室的研究员理查德·斯托曼(Richard M. Stallman)在访问斯坦福大学人工智能实验室时,看到了一个名为 E 的全屏编辑器。受到启发后,他回到麻省理工学院并着手改进 Control-R。程序底层结构最重要的变化是:每个按键在按下时都会运行其对应的宏,这使得 Control-R 的定制变得容易得多。实验室的黑客们热情地投入到斯托曼的代码中,开始修改和添加命令。

That created an issue for Guy Steele Jr., SM ’77, PhD ’80. A graduate student in the lab, Steele frequently needed to help other lab members debug their programs. “I noticed that it was much harder for me to help someone who was using one of these packages rather than straight TECO,” he recalls. “Eventually, it occurred to me to try [to] broker consensus on a standard set of Control-R commands that everyone could agree to use.”

这给 Guy Steele Jr.(77 届硕士,80 届博士)带来了问题。作为实验室的一名研究生,Steele 经常需要帮助其他实验室成员调试程序。他回忆道:“我注意到,帮助那些使用这些软件包的人,比帮助直接使用 TECO 的人要困难得多。最终,我想到尝试就一套大家都能同意使用的标准 Control-R 命令达成共识。”

David Moon ’75, another member of the lab, helped out. Stallman jumped in as well, and eventually he took over. Together, the group assigned a standard set of commands that made use of the Meta key found on many of the lab’s early keyboards: Meta-F would move the cursor forward a word, Meta-B would move it back a word, and so on. They called the result EMACS, short for “Editor Macros” or “Editing Macros.” “My goal was not to construct a great new text editor,” says Steele. “I was trying to address a social problem.”

实验室的另一位成员 David Moon(75 届校友)提供了帮助。斯托曼也加入了进来,并最终接手了这项工作。团队共同指定了一套标准命令,利用了实验室早期许多键盘上都有的 Meta 键:Meta-F 将光标向前移动一个单词,Meta-B 向后移动一个单词,依此类推。他们将最终成果命名为 EMACS,即“编辑器宏”或“编辑宏”的缩写。Steele 说:“我的目标不是构建一个伟大的新文本编辑器,我是在试图解决一个社会问题。”

Nevertheless, EMACS was a great new text editor. Whereas Control-R could be tricky, EMACS users with “no technical experience at all” could learn to edit letters, emails, and even programs “within minutes or an hour,” according to a history by Bernard S. Greenberg, SM ’74. Meanwhile, “experienced and sophisticated users found EMACS to be eminently more usable than any of the previous forms of editing.”

尽管如此,EMACS 确实是一个伟大的新文本编辑器。根据 Bernard S. Greenberg(74 届硕士)撰写的一段历史记载,Control-R 可能很棘手,但“完全没有技术经验”的 EMACS 用户可以在“几分钟或一小时内”学会编辑信件、电子邮件甚至程序。与此同时,“经验丰富且老练的用户发现,EMACS 比之前任何形式的编辑工具都要好用得多。”

Stallman started distributing EMACS to anyone who sent him a magnetic tape and a postage-paid return envelope. “EMACS does not cost anything; instead, you are joining the EMACS software-sharing commune,” he wrote in the 1981 manual. “The conditions of membership are that you must send back any improvements you make to EMACS.”

斯托曼开始向任何寄给他磁带和预付邮资回邮信封的人分发 EMACS。他在 1981 年的手册中写道:“EMACS 不收取任何费用;相反,你加入的是 EMACS 软件共享公社。会员的条件是你必须将你对 EMACS 所做的任何改进寄回。”

Greenberg, meanwhile, decided to write his own version for Multics, an early operating system by that time owned by his employer, Honeywell. Greenberg’s EMACS won first prize at the International Honeywell Software Conference in 1980, and Honeywell started selling it. Honeywell wasn’t alone in marketing a version of EMACS: James Arthur Gosling, a Carnegie Mellon graduate who went on to lead the development of the Java programming language, made a version that he eventually sold as a commercial product.

与此同时,Greenberg 决定为 Multics 编写自己的版本,Multics 是当时由他的雇主霍尼韦尔(Honeywell)拥有的一种早期操作系统。Greenberg 的 EMACS 在 1980 年的国际霍尼韦尔软件大会上获得了一等奖,霍尼韦尔开始销售它。并非只有霍尼韦尔在销售 EMACS 版本:卡内基梅隆大学的毕业生 James Arthur Gosling(后来领导了 Java 编程语言的开发)也制作了一个版本,并最终将其作为商业产品出售。

This transition from free to paid software ultimately spurred Stallman to launch a project to create an operating system that could be freely shared and improved by its users. He modeled this effort, called the GNU Project, after the increasingly popular Unix operating system from Bell Labs. “GNU” was short for “GNU’s Not Unix,” alluding to the fact that, unlike Unix, it would be free.

这种从免费软件向付费软件的转变,最终促使斯托曼发起了一个项目,旨在创建一个可以由用户自由共享和改进的操作系统。他以贝尔实验室日益流行的 Unix 操作系统为蓝本,发起了这项名为 GNU 的项目。“GNU”是“GNU’s Not Unix”的缩写,暗示了它与 Unix 不同,它是免费的。

The project’s first major application was GNU Emacs (now restyled in lowercase). The GNU/Linux operating system was still years away, so, despite the project’s aim to create an entirely free operating system, GNU Emacs initally ran on Unix. It would eventually run on a range of operating systems, including Linux but also other Unix-based systems. When Apple launched

该项目的第一个主要应用程序是 GNU Emacs(现在改用小写字母)。GNU/Linux 操作系统距离问世还有几年时间,因此,尽管该项目的目标是创建一个完全免费的操作系统,但 GNU Emacs 最初是在 Unix 上运行的。它最终将在包括 Linux 在内的多种操作系统以及其他基于 Unix 的系统上运行。当苹果公司推出……