← Paul Graham

Being Popular

受欢迎
 ·  Paul Graham  ·  原文

May 2001 (This article was written as a kind of business plan for a new language .

2001 年 5 月(本文是作为一种新语言的商业计划编写的。

So it is missing (because it takes for granted) the most important feature of a good programming language: very powerful abstractions.) A friend of mine once told an eminent operating systems expert that he wanted to design a really good programming language.

所以它缺少(因为它认为是理所当然的)好的编程语言最重要的特征:非常强大的抽象。)我的一个朋友曾经告诉一位杰出的操作系统专家,他想设计一种非常好的编程语言。

The expert told him that it would be a waste of time, that programming languages don't become popular

专家告诉他,这只是浪费时间,编程语言不会流行起来

or unpopular based on their merits, and so no matter how good his language was, no one would use it.

或因其优点而不得人心,所以无论他的语言多么好,也没有人会使用它。

At least, that was what had happened to the language he had designed.

至少,他设计的语言就是这样。

What does make a language popular?

是什么让一门语言流行起来?

Do popular languages deserve their popularity?

流行语言值得流行吗?

Is it worth trying to define a good programming language?

是否值得尝试定义一种好的编程语言?

How would you do it?

你会怎么做?

I think the answers to these questions can be found by looking at hackers, and learning what they want.

我认为这些问题的答案可以通过观察黑客并了解他们想要什么来找到。

Programming

编程

languages are for hackers, and a programming language is good as a programming language (rather than, say, an exercise in denotational semantics or compiler design) if and only if hackers like it.

语言是为黑客准备的,当且仅当黑客喜欢时,编程语言才可以作为编程语言(而不是指称语义或编译器设计的练习)。

1 The Mechanics of Popularity It's true, certainly, that most people don't choose programming languages simply based on their merits.

1 流行的机制 当然,大多数人不会仅仅根据编程语言的优点来选择编程语言。

Most programmers are told what language to use by someone else.

大多数程序员都是被其他人告知要使用什么语言的。

And yet I think the effect

但我认为效果

of such external factors on the popularity of programming languages is not as great as it's sometimes thought to be.

这些外部因素对编程语言流行度的影响并不像有时想象的那么大。

I think a bigger problem is that a hacker's idea of a good programming language is not the same as most language designers'.

我认为一个更大的问题是,黑客对于好的编程语言的想法与大多数语言设计者的想法并不相同。

Between the two, the hacker's opinion is the one that matters.

在两者之间,黑客的意见才是最重要的。

Programming languages are not theorems.

编程语言不是定理。

They're tools, designed for people, and they have to be designed to suit human strengths

它们是工具,为人而设计,并且必须根据人的优势进行设计

and weaknesses as much as shoes have to be designed for human feet.

和弱点一样,鞋子必须为人的脚设计。

If a shoe pinches when you put it on, it's a bad shoe, however elegant it may be as a piece of sculpture.

如果一只鞋子在穿上时会被夹住,那么它就是一双糟糕的鞋子,无论它作为一件雕塑作品多么优雅。

It may be that the majority of programmers can't tell a good language from a bad one.

大多数程序员可能无法区分好语言和坏语言。

But that's no different with any other tool.

但这与任何其他工具没有什么不同。

It doesn't mean that it's a waste of time to try designing a good language.

这并不意味着尝试设计一种好的语言是浪费时间。

Expert hackers can tell a good language when they see

专家黑客在看到时可以说出一种好的语言

one, and they'll use it.

一个,他们就会使用它。

Expert hackers are a tiny minority, admittedly, but that tiny minority write all the good software, and their influence is such that the rest of the programmers will tend to use whatever language they use.

诚然,专家黑客只是极少数,但那极少数人编写了所有优秀的软件,他们的影响力使得其他程序员倾向于使用他们使用的任何语言。

Often, indeed, it is not merely influence but command: often the expert hackers are the very people who, as their bosses or faculty advisors, tell the other programmers what language to use.

事实上,通常情况下,这不仅仅是影响力,而且是命令:通常,专家黑客就是作为他们的老板或指导老师告诉其他程序员使用什么语言的人。

The opinion of expert hackers is not the only force that determines the relative popularity of programming languages — legacy software (Cobol) and hype (Ada, Java) also play a role — but I think it is the most powerful force over the long term.

黑客专家的意见并不是决定编程语言相对受欢迎程度的唯一力量——遗留软件(Cobol)和炒作(Ada、Java)也发挥了作用——但我认为从长远来看,它是最强大的力量。

Given an initial critical mass and enough time, a programming language probably becomes about as popular as it deserves to be.

考虑到最初的临界质量和足够的时间,一种编程语言可能会变得像它应有的那样受欢迎。

And popularity further separates

人气进一步拉开差距

good languages from bad ones, because feedback from real live users always leads to improvements.

好语言与坏语言的区别,因为来自真实用户的反馈总是会带来改进。

Look at how much any popular language has changed during its life.

看看流行语言在其生命周期中发生了多少变化。

Perl and Fortran are extreme cases, but even Lisp has changed a lot.

Perl 和 Fortran 是极端的例子,但即使是 Lisp 也发生了很大的变化。

Lisp 1.5 didn't have macros, for example; these evolved later, after hackers at MIT had spent a couple years using Lisp to write real programs.

例如,Lisp 1.5 没有宏;在麻省理工学院的黑客花了几年时间使用 Lisp 编写真正的程序之后,这些技术才得以发展。

[1] So whether or not a language has to be good to be popular, I think

[1] 所以我认为无论一种语言是否必须优秀才能流行

a language has to be popular to be good.

一种语言必须流行才好。

And it has to stay popular to stay good.

它必须保持受欢迎才能保持良好状态。

The state of the art in programming languages doesn't stand still.

编程语言的最新技术并没有停滞不前。

And yet the Lisps we have today are still pretty much what they had at MIT in the mid-1980s, because that's the last time Lisp had a sufficiently large and demanding user base.

然而,我们今天拥有的 Lisp 仍然与 20 世纪 80 年代中期 MIT 的 Lisp 差不多,因为那是 Lisp 最后一次拥有足够大且要求很高的用户群。

Of course, hackers have to know about a language before they can use it.

当然,黑客必须先了解一种语言才能使用它。

How are they to hear?

他们怎么听?

From other hackers.

来自其他黑客。

But there has to

但必须有

be some initial group of hackers using the language for others even to hear about it.

是一些最初的黑客团体,他们使用该语言让其他人甚至听说过它。

I wonder how large this group has to be; how many users make a critical mass?

我想知道这个群体有多大;有多少用户达到了临界质量?

Off the top of my head, I'd say twenty.

我突然想到,我会说二十。

If a language had twenty separate users, meaning twenty users who decided on their own to use it, I'd consider it to be real.

如果一种语言有二十个独立的用户,这意味着二十个用户决定自己使用它,我会认为它是真实的。

Getting there can't be easy.

到达那里并不容易。

I would not be surprised if it is harder to get from zero to twenty than from twenty to a thousand.

如果从零到二十比从二十到一千更难,我不会感到惊讶。

The best way to get those initial twenty users is probably to use a trojan horse: to give people an application they want, which happens to be written in the new language.

获得最初的 20 个用户的最佳方法可能是使用特洛伊木马:为人们提供他们想要的应用程序,而该应用程序恰好是用新语言编写的。

2 External Factors Let's start by acknowledging one external factor that does affect the popularity of a programming language.

2 外部因素首先让我们承认一个确实影响编程语言流行度的外部因素。

To become popular, a programming language has to be the scripting language of a popular system.

为了变得流行,编程语言必须是流行系统的脚本语言。

Fortran and Cobol were the scripting languages of early

Fortran 和 Cobol 是早期的脚本语言

IBM mainframes.

IBM 大型机。

C was the scripting language of Unix, and so, later, was Perl.

C 是 Unix 的脚本语言,后来的 Perl 也是如此。

Tcl is the scripting language of Tk.

Tcl 是 Tk 的脚本语言。

Java and Javascript are intended to be the scripting languages of web browsers.

Java 和 Javascript 旨在成为网络浏览器的脚本语言。

Lisp is not a massively popular language because it is not the scripting language of a massively popular system.

Lisp 并不是一种非常流行的语言,因为它不是一种非常流行的系统的脚本语言。

What popularity it retains dates back to the 1960s and 1970s, when it was the scripting language of MIT.

它的受欢迎程度可以追溯到 20 世纪 60 年代和 1970 年代,当时它是 MIT 的脚本语言。

A lot of the great programmers of the

很多伟大的程序员

day were associated with MIT at some point.

日在某些时候与麻省理工学院有关。

And in the early 1970s, before C, MIT's dialect of Lisp, called MacLisp, was one of the only programming languages a serious hacker would want to use.

在 20 世纪 70 年代初,在 C 出现之前,麻省理工学院的 Lisp 方言(称为 MacLisp)是严肃黑客愿意使用的仅有的编程语言之一。

Today Lisp is the scripting language of two moderately popular systems, Emacs and Autocad, and for that reason I suspect that most of the Lisp programming done today is done in Emacs Lisp or AutoLisp.

今天,Lisp 是 Emacs 和 Autocad 这两个相当流行的系统的脚本语言,因此我怀疑今天完成的大部分 Lisp 编程都是在 Emacs Lisp 或 AutoLisp 中完成的。

Programming languages don't exist in isolation.

编程语言并不是孤立存在的。

To hack is a

黑客攻击是一个

transitive verb — hackers are usually hacking something — and in practice languages are judged relative to whatever they're used to hack.

及物动词——黑客通常是在攻击某些东西——在实践中,语言是根据他们用来攻击的东西来判断的。

So if you want to design a popular language, you either have to supply more than a language, or you have to design your language to replace the scripting language of some existing system.

因此,如果你想设计一种流行的语言,你要么必须提供不止一种语言,要么你必须设计你的语言来替换某些现有系统的脚本语言。

Common Lisp is unpopular partly because it's an orphan.

Common Lisp 不受欢迎的部分原因是它是一个孤儿。

It did originally come with a system to hack: the Lisp Machine.

它最初确实附带了一个可以破解的系统:Lisp Machine。

But Lisp

但是 Lisp

Machines (along with parallel computers) were steamrollered by the increasing power of general purpose processors in the 1980s.

20 世纪 80 年代,机器(以及并行计算机)因通用处理器日益强大的功能而受到压倒。

Common Lisp might have remained popular if it had been a good scripting language for Unix.

如果 Common Lisp 是一种优秀的 Unix 脚本语言,它可能会继续流行。

It is, alas, an atrociously bad one.

唉,这是一件极其糟糕的事情。

One way to describe this situation is to say that a language isn't judged on its own merits.

描述这种情况的一种方法是,人们不会根据语言本身的优点来评判它。

Another view is that a programming language really isn't a programming language unless it's also the scripting

另一种观点是,编程语言实际上不是编程语言,除非它也是脚本

language of something.

某事物的语言。

This only seems unfair if it comes as a surprise.

如果这只是出人意料的话,那么这似乎是不公平的。

I think it's no more unfair than expecting a programming language to have, say, an implementation.

我认为这并不比期望一种编程语言有一个实现更不公平。

It's just part of what a programming language is.

它只是编程语言的一部分。

A programming language does need a good implementation, of course, and this must be free.

当然,编程语言确实需要良好的实现,而且必须是免费的。

Companies will pay for software, but individual hackers won't, and it's the hackers you need to attract.

公司会为软件付费,但个人黑客不会,而这正是你需要吸引的黑客。

A language also needs to have a book about it.

一种语言还需要有一本关于它的书。

The book should be thin, well-written, and full of good examples.

这本书应该很薄,写得很好,并且充满了很好的例子。

K&R is the ideal here.

K&R 是这里的理想选择。

At the moment I'd almost say that a language has to have a book published by O'Reilly.

目前我几乎想说,一种语言必须有一本由 O'Reilly 出版的书。

That's becoming the test of mattering to hackers.

这正在成为对黑客的重要考验。

There should be online documentation as well.

还应该有在线文档。

In fact, the book can start as online documentation.

事实上,这本书可以作为在线文档开始。

But I don't think that physical

但我不认为身体上

books are outmoded yet.

书籍已经过时了。

Their format is convenient, and the de facto censorship imposed by publishers is a useful if imperfect filter.

它们的格式很方便,出版商实施的事实上的审查制度虽然不完善,但却是一个有用的过滤器。

Bookstores are one of the most important places for learning about new languages.

书店是学习新语言最重要的场所之一。

3 Brevity Given that you can supply the three things any language needs — a free implementation, a book, and something to hack — how do you make a language that hackers will like?

3 简洁性 既然你可以提供任何语言所需的三样东西——免费的实现、一本书和一些可以破解的东西——你如何创造一种黑客会喜欢的语言?

One thing hackers like is brevity.

黑客喜欢的一件事就是简洁。

Hackers are lazy, in the same

黑客都是懒惰的,同样

way that mathematicians and modernist architects are lazy: they hate anything extraneous.

就像数学家和现代主义建筑师一样懒惰:他们讨厌任何无关的东西。

It would not be far from the truth to say that a hacker about to write a program decides what language to use, at least subconsciously, based on the total number of characters he'll have to type.

如果说即将编写程序的黑客至少在潜意识中根据他必须输入的字符总数来决定使用哪种语言,这与事实相差不远。

If this isn't precisely how hackers think, a language designer would do well to act as if it were.

如果黑客的想法并非如此,那么语言设计者最好也假装如此。

It is a mistake to try to baby the user with long-winded expressions

试图用冗长的表情来哄骗用户是错误的

that are meant to resemble English.

旨在类似于英语。

Cobol is notorious for this flaw.

Cobol 因这个缺陷而臭名昭著。

A hacker would consider being asked to write add x to y giving z instead of z = x+y as something between an insult to his intelligence and a sin against God.

黑客会认为被要求写 add x to y 给出 z 而不是 z = x+y 是对他的智力的侮辱和对上帝的犯罪。

It has sometimes been said that Lisp should use first and rest instead of car and cdr, because it would make programs easier to read.

有时有人说 Lisp 应该使用first 和rest 而不是car 和cdr,因为这样会使程序更容易阅读。

Maybe for the first couple hours.

也许在最初的几个小时里。

But a hacker can learn

但黑客可以学习

quickly enough that car means the first element of a list and cdr means the rest.

很快,car 表示列表的第一个元素,而 cdr 表示其余元素。

Using first and rest means 50% more typing.

使用先休息意味着多输入 50% 的内容。

And they are also different lengths, meaning that the arguments won't line up when they're called, as car and cdr often are, in successive lines.

而且它们的长度也不同,这意味着在调用它们时,参数不会像 car 和 cdr 那样连续排列。

I've found that it matters a lot how code lines up on the page.

我发现代码在页面上的排列方式非常重要。

I can barely read Lisp code when it is set in a variable-width font, and friends say this is true for other languages too.

当 Lisp 代码设置为可变宽度字体时,我几乎无法阅读它,朋友们说其他语言也是如此。

Brevity is one place where strongly typed languages lose.

简洁性是强类型语言的劣势之一。

All other things being equal, no one wants to begin a program with a bunch of declarations.

在其他条件相同的情况下,没有人愿意用一堆声明来开始一个程序。

Anything that can be implicit, should be.

任何可以隐式的事情都应该是隐式的。

The individual tokens should be short as well.

各个标记也应该很短。

Perl and Common Lisp occupy opposite poles on this question.

Perl 和 Common Lisp 在这个问题上占据了相反的两极。

Perl programs can be almost cryptically dense, while the names of built-in Common Lisp operators are comically long.

Perl 程序的密度几乎是神秘的,而内置 Common Lisp 运算符的名称却长得可笑。

The designers of Common Lisp probably expected

Common Lisp 的设计者可能期望

users to have text editors that would type these long names for them.

用户拥有可以为他们输入这些长名称的文本编辑器。

But the cost of a long name is not just the cost of typing it.

但长名称的成本不仅仅是输入它的成本。

There is also the cost of reading it, and the cost of the space it takes up on your screen.

还有阅读它的成本,以及它在屏幕上占用的空间的成本。

4 Hackability There is one thing more important than brevity to a hacker: being able to do what you want.

4 可黑客性 对于黑客来说,有一件事情比简洁更重要:能够做你想做的事。

In the history of programming languages a surprising amount of effort has gone into preventing programmers

在编程语言的历史上,人们为防止程序员付出了令人惊讶的努力

from doing things considered to be improper.

避免做被认为不适当的事情。

This is a dangerously presumptuous plan.

这是一个危险的自以为是的计划。

How can the language designer know what the programmer is going to need to do?

语言设计者如何知道程序员需要做什么?

I think language designers would do better to consider their target user to be a genius who will need to do things they never anticipated, rather than a bumbler who needs to be protected from himself.

我认为语言设计者最好将他们的目标用户视为需要做他们从未预料到的事情的天才,而不是需要保护自己免受伤害的笨手笨脚的人。

The bumbler will shoot himself in the foot anyway.

貉熊无论如何都会搬起石头砸自己的脚。

You may save him from referring to

你可以让他免于提及

variables in another package, but you can't save him from writing a badly designed program to solve the wrong problem, and taking forever to do it.

变量在另一个包中,但你无法避免他编写一个设计糟糕的程序来解决错误的问题,并且要花很长时间才能完成。

Good programmers often want to do dangerous and unsavory things.

优秀的程序员常常想做危险和令人讨厌的事情。

By unsavory I mean things that go behind whatever semantic facade the language is trying to present: getting hold of the internal representation of some high-level abstraction, for example.

我所说的“令人讨厌”是指语言试图呈现的任何语义外观背后的事物:例如,掌握某些高级抽象的内部表示。

Hackers

黑客

like to hack, and hacking means getting inside things and second guessing the original designer.

喜欢黑客攻击,而黑客攻击意味着深入了解事物并重新猜测原始设计者。

Let yourself be second guessed.

让自己被别人猜测。

When you make any tool, people use it in ways you didn't intend, and this is especially true of a highly articulated tool like a programming language.

当你制作任何工具时,人们会以你不希望的方式使用它,对于像编程语言这样高度明确的工具来说尤其如此。

Many a hacker will want to tweak your semantic model in a way that you never imagined.

许多黑客会想要以您从未想象过的方式调整您的语义模型。

I say, let them; give the programmer access to as much

我说,让他们吧;让程序员能够访问尽可能多的内容

internal stuff as you can without endangering runtime systems like the garbage collector.

尽可能地处理内部的东西,而不危及垃圾收集器等运行时系统。

In Common Lisp I have often wanted to iterate through the fields of a struct — to comb out references to a deleted object, for example, or find fields that are uninitialized.

在 Common Lisp 中,我经常想要迭代结构体的字段——例如,梳理对已删除对象的引用,或者查找未初始化的字段。

I know the structs are just vectors underneath.

我知道结构体只是下面的向量。

And yet I can't write a general purpose function that I can call on any struct.

但我无法编写可以在任何结构上调用的通用函数。

I can only access the fields by

我只能通过以下方式访问这些字段

name, because that's what a struct is supposed to mean.

名称,因为这就是结构的含义。

A hacker may only want to subvert the intended model of things once or twice in a big program.

黑客可能只想在大型程序中破坏预期的事物模型一两次。

But what a difference it makes to be able to.

但能够做到这一点会有多大的不同。

And it may be more than a question of just solving a problem.

这可能不仅仅是解决问题的问题。

There is a kind of pleasure here too.

这里也有一种乐趣。

Hackers share the surgeon's secret pleasure in poking about in gross innards, the teenager's secret pleasure in popping zits.

黑客们分享了外科医生在探查毛茸茸的内脏时的秘密乐趣,以及青少年在挤痘痘时的秘密乐趣。

[2] For boys, at least,

[2] 至少对于男孩来说,

certain kinds of horrors are fascinating.

某些类型的恐怖是令人着迷的。

Maxim magazine publishes an annual volume of photographs, containing a mix of pin-ups and grisly accidents.

《马克西姆》杂志出版了一本年度照片集,其中混合了海报女郎和可怕的事故。

They know their audience.

他们了解他们的观众。

Historically, Lisp has been good at letting hackers have their way.

从历史上看,Lisp 一直很擅长让黑客为所欲为。

The political correctness of Common Lisp is an aberration.

Common Lisp 的政治正确性是一种畸变。

Early Lisps let you get your hands on everything.

早期的 Lisps 让你掌握一切。

A good deal of that spirit is, fortunately, preserved in macros.

幸运的是,这种精神在宏中得到了保留。

What a wonderful thing,

多么美妙的事情,

to be able to make arbitrary transformations on the source code.

能够对源代码进行任意转换。

Classic macros are a real hacker's tool — simple, powerful, and dangerous.

经典宏是真正的黑客工具——简单、强大且危险。

It's so easy to understand what they do: you call a function on the macro's arguments, and whatever it returns gets inserted in place of the macro call.

理解它们的作用非常容易:您在宏的参数上调用函数,并且它返回的任何内容都会插入到宏调用的位置。

Hygienic macros embody the opposite principle.

卫生宏体现了相反的原则。

They try to protect you from understanding what they're doing.

他们试图保护你不明白他们在做什么。

I have never heard hygienic macros explained in one

我从未听过卫生宏指令在一篇文章中被解释过

sentence.

句子。

And they are a classic example of the dangers of deciding what programmers are allowed to want.

它们是决定程序员想要什么的危险的典型例子。

Hygienic macros are intended to protect me from variable capture, among other things, but variable capture is exactly what I want in some macros.

卫生宏的目的是保护我免受变量捕获等问题的影响,但变量捕获正是我在某些宏中想要的。

A really good language should be both clean and dirty: cleanly designed, with a small core of well understood and highly orthogonal operators, but dirty in the sense that it lets hackers have their

真正好的语言应该既干净又肮脏:干净的设计,具有易于理解且高度正交的运算符的小核心,但肮脏的意思是它让黑客有他们的

way with it.

方式与它。

C is like this.

C就是这样的。

So were the early Lisps.

早期的 Lisp 也是如此。

A real hacker's language will always have a slightly raffish character.

真正的黑客的语言总会带着些许不羁的性格。

A good programming language should have features that make the kind of people who use the phrase "software engineering" shake their heads disapprovingly.

一种好的编程语言应该具有让那些使用“软件工程”这个词的人不以为然地摇头的特性。

At the other end of the continuum are languages like Ada and Pascal, models of propriety that are good for teaching and not much else.

连续体的另一端是像 Ada 和 Pascal 这样的语言,它们是适合教学的规范模型,但除此之外就没有什么用处了。

5 Throwaway Programs To be attractive to hackers, a language must be good for writing the kinds of programs they want to write.

5 一次性程序 为了吸引黑客,一种语言必须适合编写他们想要编写的程序。

And that means, perhaps surprisingly, that it has to be good for writing throwaway programs.

也许令人惊讶的是,这意味着它必须适合编写一次性程序。

A throwaway program is a program you write quickly for some limited task: a program to automate some system administration task, or generate test data for a simulation, or convert data from one format

一次性程序是您为某些有限任务快速编写的程序:用于自动执行某些系统管理任务,或生成模拟测试数据,或从一种格式转换数据的程序

to another.

到另一个。

The surprising thing about throwaway programs is that, like the "temporary" buildings built at so many American universities during World War II, they often don't get thrown away.

关于一次性项目的令人惊讶的事情是,就像二战期间许多美国大学建造的“临时”建筑一样,它们通常不会被扔掉。

Many evolve into real programs, with real features and real users.

许多演变成真正的程序,具有真实的功能和真实的用户。

I have a hunch that the best big programs begin life this way, rather than being designed big from the start, like the Hoover Dam.

我有一种预感,最好的大型项目都是这样开始的,而不是像胡佛水坝那样从一开始就设计得很大。

It's terrifying to build something big from scratch.

从头开始建造一些大东西是很可怕的。

When people

当人们

take on a project that's too big, they become overwhelmed.

承担太大的项目,他们就会不知所措。

The project either gets bogged down, or the result is sterile and wooden: a shopping mall rather than a real downtown, Brasilia rather than Rome, Ada rather than C.

该项目要么陷入困境,要么结果是枯燥乏味和呆板的:一个购物中心而不是真正的市中心,巴西利亚而不是罗马,阿达而不是 C。

Another way to get a big program is to start with a throwaway program and keep improving it.

获得大型程序的另一种方法是从一次性程序开始并不断改进它。

This approach is less daunting, and the design of the program benefits from evolution.

这种方法不那么令人畏惧,并且程序的设计受益于进化。

I think, if one

我想,如果一个

looked, that this would turn out to be the way most big programs were developed.

看起来,这将成为大多数大型程序的开发方式。

And those that did evolve this way are probably still written in whatever language they were first written in, because it's rare for a program to be ported, except for political reasons.

那些确实以这种方式演变的程序可能仍然是用它们最初编写的语言编写的,因为除非出于政治原因,否则很少有程序被移植。

And so, paradoxically, if you want to make a language that is used for big systems, you have to make it good for writing throwaway programs, because that's where big systems come from.

因此,矛盾的是,如果你想创建一种用于大型系统的语言,你必须使其适合编写一次性程序,因为这就是大型系统的来源。

Perl is a striking example of this idea.

Perl 是这个想法的一个引人注目的例子。

It was not only designed for writing throwaway programs, but was pretty much a throwaway program itself.

它不仅是为编写一次性程序而设计的,而且本身也是一个一次性程序。

Perl began life as a collection of utilities for generating reports, and only evolved into a programming language as the throwaway programs people wrote in it grew larger.

Perl 最初是一个用于生成报告的实用程序的集合,随着人们用它编写的一次性程序变得越来越大,才演变成一种编程语言。

It was not until Perl 5 (if then) that the language was suitable for writing serious programs, and yet it was already massively popular.

直到 Perl 5(如果那时),该语言才适合编写严肃的程序,但它已经广泛流行。

What makes a language good for throwaway programs?

是什么让一种语言适合一次性程序?

To start with, it must be readily available.

首先,它必须易于获得。

A throwaway program is something that you expect to write in an hour.

一次性程序是您希望在一小时内编写的东西。

So the language probably must already be installed on the computer you're using.

因此,该语言可能必须已经安装在您正在使用的计算机上。

It can't be something you have to install before you use it.

它不可能是您在使用之前必须安装的东西。

It has to be there.

它必须在那里。

C was there because it came with the operating system.

C 之所以存在,是因为它与操作系统一起出现。

Perl was there because it was originally a tool for system administrators,

Perl 的存在是因为它最初是系统管理员的工具,

and yours had already installed it.

并且你的已经安装了它。

Being available means more than being installed, though.

不过,可用不仅仅意味着安装。

An interactive language, with a command-line interface, is more available than one that you have to compile and run separately.

具有命令行界面的交互式语言比必须单独编译和运行的语言更可用。

A popular programming language should be interactive, and start up fast.

流行的编程语言应该是交互式的,并且启动速度快。

Another thing you want in a throwaway program is brevity.

在一次性程序中您想要的另一件事是简洁。

Brevity is always attractive to hackers, and never more so than in a program

简洁总是对黑客有吸引力,尤其是在程序中

they expect to turn out in an hour.

他们预计一小时内就能出来。

6 Libraries Of course the ultimate in brevity is to have the program already written for you, and merely to call it.

6 库 当然,最简洁的方法是让程序已经为您编写,并且只需调用它即可。

And this brings us to what I think will be an increasingly important feature of programming languages: library functions.

这让我们看到了我认为编程语言的一个日益重要的特性:库函数。

Perl wins because it has large libraries for manipulating strings.

Perl 获胜是因为它拥有用于操作字符串的大型库。

This class of library functions are especially important for throwaway programs, which are often

此类库函数对于一次性程序尤其重要,这些程序通常是

originally written for converting or extracting data.

最初是为转换或提取数据而编写的。

Many Perl programs probably begin as just a couple library calls stuck together.

许多 Perl 程序可能一开始只是将几个库调用粘在一起。

I think a lot of the advances that happen in programming languages in the next fifty years will have to do with library functions.

我认为未来五十年编程语言中发生的许多进步都与库函数有关。

I think future programming languages will have libraries that are as carefully designed as the core language.

我认为未来的编程语言将拥有像核心语言一样精心设计的库。

Programming language design

编程语言设计

will not be about whether to make your language strongly or weakly typed, or object oriented, or functional, or whatever, but about how to design great libraries.

不会是关于是否让你的语言强类型或弱类型,或面向对象,或函数式,或其他什么,而是关于如何设计伟大的库。

The kind of language designers who like to think about how to design type systems may shudder at this.

那些喜欢思考如何设计类型系统的语言设计者可能会对此感到不寒而栗。

It's almost like writing applications!

这几乎就像编写应用程序一样!

Too bad.

太糟糕了。

Languages are for programmers, and libraries are what programmers need.

语言是为程序员服务的,而库是程序员所需要的。

It's hard to design good libraries.

设计好的库很困难。

It's not simply a matter of

这不仅仅是一个问题

writing a lot of code.

编写大量代码。

Once the libraries get too big, it can sometimes take longer to find the function you need than to write the code yourself.

一旦库变得太大,有时找到所需的函数可能比自己编写代码花费更长的时间。

Libraries need to be designed using a small set of orthogonal operators, just like the core language.

就像核心语言一样,需要使用一小组正交运算符来设计库。

It ought to be possible for the programmer to guess what library call will do what he needs.

程序员应该能够猜测哪个库调用将执行他所需要的操作。

Libraries are one place Common Lisp falls short.

库是 Common Lisp 的不足之处之一。

There are only

只有

rudimentary libraries for manipulating strings, and almost none for talking to the operating system.

用于操作字符串的基本库,几乎没有用于与操作系统对话的库。

For historical reasons, Common Lisp tries to pretend that the OS doesn't exist.

由于历史原因,Common Lisp 试图假装操作系统不存在。

And because you can't talk to the OS, you're unlikely to be able to write a serious program using only the built-in operators in Common Lisp.

而且因为您无法与操作系统对话,所以您不太可能仅使用 Common Lisp 中的内置运算符来编写正式的程序。

You have to use some implementation-specific hacks as well, and in practice these tend not to give you everything you want.

您还必须使用一些特定于实现的技巧,而在实践中,这些技巧往往无法为您提供您想要的一切。

Hackers would think

黑客会认为

a lot more highly of Lisp if Common Lisp had powerful string libraries and good OS support.

如果 Common Lisp 拥有强大的字符串库和良好的操作系统支持,那么对 Lisp 的评价就会更高。

7 Syntax Could a language with Lisp's syntax, or more precisely, lack of syntax, ever become popular?

7 语法 具有 Lisp 语法的语言,或者更准确地说,缺乏语法的语言会变得流行吗?

I don't know the answer to this question.

我不知道这个问题的答案。

I do think that syntax is not the main reason Lisp isn't currently popular.

我确实认为语法并不是 Lisp 目前不流行的主要原因。

Common Lisp has worse problems than unfamiliar syntax.

Common Lisp 的问题比不熟悉的语法更糟糕。

I know several programmers who are comfortable with prefix

我认识一些熟悉前缀的程序员

syntax and yet use Perl by default, because it has powerful string libraries and can talk to the os.

语法,但默认使用 Perl,因为它具有强大的字符串库并且可以与操作系统对话。

There are two possible problems with prefix notation: that it is unfamiliar to programmers, and that it is not dense enough.

前缀表示法有两个可能的问题:程序员不熟悉它,并且它不够密集。

The conventional wisdom in the Lisp world is that the first problem is the real one.

Lisp 世界的传统观点是,第一个问题是真正的问题。

I'm not so sure.

我不太确定。

Yes, prefix notation makes ordinary programmers panic.

是的,前缀表示法让普通程序员感到恐慌。

But I don't think ordinary programmers' opinions

但我不认为普通程序员的看法

matter.

很重要。

Languages become popular or unpopular based on what expert hackers think of them, and I think expert hackers might be able to deal with prefix notation.

语言变得流行或不流行取决于专家黑客对它们的看法,我认为专家黑客可能能够处理前缀表示法。

Perl syntax can be pretty incomprehensible, but that has not stood in the way of Perl's popularity.

Perl 语法可能相当难以理解,但这并没有妨碍 Perl 的流行。

If anything it may have helped foster a Perl cult.

如果有的话,它可能有助于培养 Perl 崇拜。

A more serious problem is the diffuseness of prefix notation.

一个更严重的问题是前缀表示法的扩散。

For expert hackers, that really is a problem.

对于专家黑客来说,这确实是一个问题。

No one wants to write

没人愿意写

(aref a x y) when they could write a[x,y].

(aref a x y) 当他们可以写 a[x,y] 时。

In this particular case there is a way to finesse our way out of the problem.

在这种特殊情况下,有一种方法可以巧妙地解决这个问题。

If we treat data structures as if they were functions on indexes, we could write (a x y) instead, which is even shorter than the Perl form.

如果我们将数据结构视为索引上的函数,我们可以改为 (a x y),这甚至比 Perl 形式更短。

Similar tricks may shorten other types of expressions.

类似的技巧可以缩短其他类型的表达式。

We can get rid of (or make optional) a lot of parentheses by making indentation significant.

我们可以通过显着缩进来去掉(或可选)大量括号。

That's how programmers read code anyway:

这就是程序员阅读代码的方式:

when indentation says one thing and delimiters say another, we go by the indentation.

当缩进表示一件事而分隔符表示另一件事时,我们就按缩进进行。

Treating indentation as significant would eliminate this common source of bugs as well as making programs shorter.

将缩进视为重要的将消除这种常见的错误来源并缩短程序。

Sometimes infix syntax is easier to read.

有时中缀语法更容易阅读。

This is especially true for math expressions.

对于数学表达式尤其如此。

I've used Lisp my whole programming life and I still don't find prefix math expressions natural.

我的整个编程生涯都在使用 Lisp,但我仍然不认为前缀数学表达式是自然的。

And yet it is convenient, especially when you're generating code, to have operators

然而,使用运算符很方便,尤其是在生成代码时

that take any number of arguments.

需要任意数量的参数。

So if we do have infix syntax, it should probably be implemented as some kind of read-macro.

因此,如果我们确实有中缀语法,它可能应该作为某种读取宏来实现。

I don't think we should be religiously opposed to introducing syntax into Lisp, as long as it translates in a well-understood way into underlying s-expressions.

我认为我们不应该强烈反对将语法引入 Lisp,只要它能够以易于理解的方式转换为底层的 s 表达式即可。

There is already a good deal of syntax in Lisp.

Lisp 中已经有大量语法。

It's not necessarily bad to introduce more, as long as no one is forced to use it.

引入多一些也不一定是坏事,只要不强迫别人使用就可以了。

In Common Lisp, some delimiters are reserved

在 Common Lisp 中,保留了一些分隔符

for the language, suggesting that at least some of the designers intended to have more syntax in the future.

对于该语言,这表明至少一些设计者打算在未来拥有更多语法。

One of the most egregiously unlispy pieces of syntax in Common Lisp occurs in format strings; format is a language in its own right, and that language is not Lisp.

Common Lisp 中最令人震惊的语法片段之一出现在格式字符串中; format 本身就是一种语言,但这种语言不是 Lisp。

If there were a plan for introducing more syntax into Lisp, format specifiers might be able to be included in it.

如果有计划在 Lisp 中引入更多语法,格式说明符也许可以包含在其中。

It would be a good thing if macros could generate format

如果宏能生成格式就好了

specifiers the way they generate any other kind of code.

说明符生成任何其他类型代码的方式。

An eminent Lisp hacker told me that his copy of CLTL falls open to the section format.

一位著名的 Lisp 黑客告诉我,他的 CLTL 副本对节格式是开放的。

Mine too.

我的也是。

This probably indicates room for improvement.

这可能表明还有改进的空间。

It may also mean that programs do a lot of I/O.

这也可能意味着程序会执行大量 I/O。

8 Efficiency A good language, as everyone knows, should generate fast code.

8 效率 众所周知,一门好的语言应该生成快速的代码。

But in practice I don't think fast code comes primarily from things you do in the design of the language.

但实际上,我不认为快速代码主要来自于语言设计中所做的事情。

As Knuth pointed out long

正如高德纳长期指出的那样

ago, speed only matters in certain critical bottlenecks.

以前,速度只在某些关键瓶颈中很重要。

And as many programmers have observed since, one is very often mistaken about where these bottlenecks are.

正如许多程序员此后所观察到的那样,人们经常错误地判断这些瓶颈在哪里。

So, in practice, the way to get fast code is to have a very good profiler, rather than by, say, making the language strongly typed.

因此,在实践中,获得快速代码的方法是拥有一个非常好的分析器,而不是通过使语言强类型化。

You don't need to know the type of every argument in every call in the program.

您不需要知道程序中每次调用中每个参数的类型。

You do need to be able to declare the types of arguments

您确实需要能够声明参数的类型

in the bottlenecks.

在瓶颈中。

And even more, you need to be able to find out where the bottlenecks are.

更重要的是,您需要能够找出瓶颈所在。

One complaint people have had with Lisp is that it's hard to tell what's expensive.

人们对 Lisp 的抱怨之一是很难判断什么是昂贵的。

This might be true.

这可能是真的。

It might also be inevitable, if you want to have a very abstract language.

如果你想要一种非常抽象的语言,这也可能是不可避免的。

And in any case I think good profiling would go a long way toward fixing the problem: you'd soon learn what was expensive.

无论如何,我认为良好的分析对于解决问题大有帮助:您很快就会知道什么是昂贵的。

Part of the problem here is social.

这里的部分问题是社会性的。

Language designers like to

语言设计者喜欢

write fast compilers.

编写快速编译器。

That's how they measure their skill.

这就是他们衡量自己技能的方式。

They think of the profiler as an add-on, at best.

他们最多将分析器视为一个附加组件。

But in practice a good profiler may do more to improve the speed of actual programs written in the language than a compiler that generates fast code.

但在实践中,一个好的分析器可能比生成快速代码的编译器更能提高用该语言编写的实际程序的速度。

Here, again, language designers are somewhat out of touch with their users.

在这里,语言设计者再次与用户脱节。

They do a really good job of solving slightly the wrong problem.

他们在解决稍微错误的问题方面做得非常好。

It might be a good idea to have an active profiler — to push

拥有一个活跃的分析器可能是个好主意 - 推动

performance data to the programmer instead of waiting for him to come asking for it.

将性能数据提供给程序员,而不是等待他来索取。

For example, the editor could display bottlenecks in red when the programmer edits the source code.

例如,当程序员编辑源代码时,编辑器可以将瓶颈显示为红色。

Another approach would be to somehow represent what's happening in running programs.

另一种方法是以某种方式表示正在运行的程序中发生的情况。

This would be an especially big win in server-based applications, where you have lots of running programs to look at.

对于基于服务器的应用程序来说,这将是一个特别大的胜利,因为您有很多正在运行的程序需要查看。

An active profiler could show graphically what's happening in memory as a

主动分析器可以以图形方式显示内存中发生的情况

program's running, or even make sounds that tell what's happening.

程序正在运行,甚至可以发出声音来告诉发生了什么。

Sound is a good cue to problems.

声音是发现问题的良好线索。

In one place I worked, we had a big board of dials showing what was happening to our web servers.

在我工作的一个地方,我们有一大块刻度盘,显示我们的网络服务器发生的情况。

The hands were moved by little servomotors that made a slight noise when they turned.

指针由小型伺服电机驱动,转动时会发出轻微的噪音。

I couldn't see the board from my desk, but I found that I could tell immediately, by the sound, when there was a problem with a server.

我从办公桌上看不到主板,但我发现当服务器出现问题时,我可以通过声音立即得知。

It might even be possible to write a profiler that would automatically detect inefficient algorithms.

甚至可以编写一个自动检测低效算法的分析器。

I would not be surprised if certain patterns of memory access turned out to be sure signs of bad algorithms.

如果某些内存访问模式被证明是糟糕算法的明显迹象,我不会感到惊讶。

If there were a little guy running around inside the computer executing our programs, he would probably have as long and plaintive a tale to tell about his job as a federal government employee.

如果有一个小家伙在计算机内跑来跑去执行我们的程序,他可能会讲述一个漫长而悲伤的故事来讲述他作为联邦政府雇员的工作。

I often have a feeling that I'm sending the processor on

我经常有一种感觉,我正在发送处理器

a lot of wild goose chases, but I've never had a good way to look at what it's doing.

很多都是徒劳的,但我从来没有一个好的方法来看看它在做什么。

A number of Lisps now compile into byte code, which is then executed by an interpreter.

许多 Lisp 现在编译成字节码,然后由解释器执行。

This is usually done to make the implementation easier to port, but it could be a useful language feature.

这样做通常是为了使实现更容易移植,但这可能是一个有用的语言功能。

It might be a good idea to make the byte code an official part of the language, and to allow programmers to use inline byte code in

让字节码成为语言的正式部分,并允许程序员在程序中使用内联字节码可能是个好主意。

bottlenecks.

瓶颈。

Then such optimizations would be portable too.

那么这样的优化也将是可移植的。

The nature of speed, as perceived by the end-user, may be changing.

最终用户所感知的速度的本质可能正在发生变化。

With the rise of server-based applications, more and more programs may turn out to be i/o-bound.

随着基于服务器的应用程序的兴起,越来越多的程序可能会受到 I/O 限制。

It will be worth making i/o fast.

让 I/O 变得更快是值得的。

The language can help with straightforward measures like simple, fast, formatted output functions, and also with deep structural changes like caching and persistent objects.

该语言可以帮助实现简单、快速、格式化输出函数等简单的措施,也可以帮助实现缓存和持久对象等深层结构变化。

Users are interested in response time.

用户对响应时间感兴趣。

But another kind of efficiency will be increasingly important: the number of simultaneous users you can support per processor.

但另一种效率将变得越来越重要:每个处理器可以支持的并发用户数量。

Many of the interesting applications written in the near future will be server-based, and the number of users per server is the critical question for anyone hosting such applications.

在不久的将来编写的许多有趣的应用程序将基于服务器,并且每台服务器的用户数量对于托管此类应用程序的任何人来说都是关键问题。

In the capital cost of a business offering a server-based

提供基于服务器的企业的资本成本

application, this is the divisor.

应用程序,这是除数。

For years, efficiency hasn't mattered much in most end-user applications.

多年来,效率对于大多数最终用户应用程序来说并不重要。

Developers have been able to assume that each user would have an increasingly powerful processor sitting on their desk.

开发人员已经能够假设每个用户的办公桌上都会有一个越来越强大的处理器。

And by Parkinson's Law, software has expanded to use the resources available.

根据帕金森定律,软件已经扩展到使用可用资源。

That will change with server-based applications.

这将随着基于服务器的应用程序而改变。

In that world, the hardware and software will be supplied together.

在那个世界里,硬件和软件将一起提供。

For companies that offer server-based applications, it will make a very big difference to the bottom line how many users they can support per server.

对于提供基于服务器的应用程序的公司来说,每台服务器可以支持多少用户的底线将产生很大的影响。

In some applications, the processor will be the limiting factor, and execution speed will be the most important thing to optimize.

在某些应用中,处理器将成为限制因素,而执行速度将是最重要的优化因素。

But often memory will be the limit; the number of simultaneous users will be determined by the amount of memory you need for each

但通常记忆力是有限的。同时用户的数量将取决于每个用户所需的内存量

user's data.

用户的数据。

The language can help here too.

语言在这里也能有所帮助。

Good support for threads will enable all the users to share a single heap.

对线程的良好支持将使所有用户能够共享单个堆。

It may also help to have persistent objects and/or language level support for lazy loading.

它也可能有助于为延迟加载提供持久对象和/或语言级别支持。

9 Time The last ingredient a popular language needs is time.

9 时间 流行语言需要的最后一个要素是时间。

No one wants to write programs in a language that might go away, as so many programming languages do.

没有人愿意用一种可能消失的语言编写程序,就像许多编程语言一样。

So most hackers will tend to wait until

所以大多数黑客会倾向于等到

a language has been around for a couple years before even considering using it.

一种语言在考虑使用之前已经存在了几年。

Inventors of wonderful new things are often surprised to discover this, but you need time to get any message through to people.

奇妙新事物的发明者常常会惊讶地发现这一点,但你需要时间才能将信息传达给人们。

A friend of mine rarely does anything the first time someone asks him.

我的一个朋友很少在第一次有人问他的时候就做什么。

He knows that people sometimes ask for things that they turn out not to want.

他知道人们有时会要求一些他们并不想要的东西。

To avoid wasting his time, he waits till the third

为了避免浪费时间,他等到了第三次。

or fourth time he's asked to do something; by then, whoever's asking him may be fairly annoyed, but at least they probably really do want whatever they're asking for.

或者第四次要求他做某事;到那时,无论谁向他提出要求,都可能会相当恼火,但至少他们可能确实想要他们所要求的任何东西。

Most people have learned to do a similar sort of filtering on new things they hear about.

大多数人都学会了对他们听到的新事物进行类似的过滤。

They don't even start paying attention until they've heard about something ten times.

他们甚至不会开始注意某件事,直到他们听过十次。

They're perfectly justified: the majority of hot new whatevers do turn out to be a

他们是完全有道理的:大多数热门新事物都被证明是

waste of time, and eventually go away.

浪费时间,最终消失。

By delaying learning VRML, I avoided having to learn it at all.

通过推迟学习 VRML,我完全避免了学习它。

So anyone who invents something new has to expect to keep repeating their message for years before people will start to get it.

因此,任何发明新事物的人都必须期望在人们开始理解它之前多年不断地重复他们的信息。

We wrote what was, as far as I know, the first web-server based application, and it took us years to get it through to people that it didn't have to be downloaded.

据我所知,我们编写了第一个基于网络服务器的应用程序,我们花了数年时间才让人们知道它不需要下载。

It wasn't that they were stupid.

这并不是说他们愚蠢。

They just had us tuned out.

他们只是让我们不理会。

The good news is, simple repetition solves the problem.

好消息是,简单的重复就可以解决问题。

All you have to do is keep telling your story, and eventually people will start to hear.

你所要做的就是继续讲述你的故事,最终人们会开始听到。

It's not when people notice you're there that they pay attention; it's when they notice you're still there.

人们并不是注意到你在那里才注意到你,而是当他们注意到你的时候。当他们注意到你还在那里的时候。

It's just as well that it usually takes a while to gain momentum.

幸好通常需要一段时间才能获得动力。

Most technologies evolve a good deal even after they're first

大多数技术即使在首次出现后也会不断发展

launched — programming languages especially.

推出——尤其是编程语言。

Nothing could be better, for a new techology, than a few years of being used only by a small number of early adopters.

对于一项新技术来说,没有什么比只被少数早期采用者使用几年更好的了。

Early adopters are sophisticated and demanding, and quickly flush out whatever flaws remain in your technology.

早期采用者经验丰富且要求严格,并且会迅速消除技术中残留的任何缺陷。

When you only have a few users you can be in close contact with all of them.

当您只有少数用户时,您可以与所有用户保持密切联系。

And early adopters are forgiving when you improve your system, even if this causes some breakage.

当您改进系统时,早期采用者会很宽容,即使这会导致一些损坏。

There are two ways new technology gets introduced: the organic growth method, and the big bang method.

引入新技术有两种方式:有机增长法和大爆炸法。

The organic growth method is exemplified by the classic seat-of-the-pants underfunded garage startup.

有机增长方法的典型例子是资金不足的车库创业公司。

A couple guys, working in obscurity, develop some new technology.

几个默默无闻的人开发了一些新技术。

They launch it with no marketing and initially have only a few (fanatically devoted) users.

他们在没有营销的情况下推出了它,最初只有少数(狂热的)用户。

They continue to improve the technology, and meanwhile their user base grows by word of

他们不断改进技术,同时他们的用户群也通过口碑不断增长

mouth.

嘴。

Before they know it, they're big.

在他们意识到之前,他们已经很大了。

The other approach, the big bang method, is exemplified by the VC-backed, heavily marketed startup.

另一种方法是大爆炸法,以风投支持、大力营销的初创公司为例。

They rush to develop a product, launch it with great publicity, and immediately (they hope) have a large user base.

他们急于开发产品,大力宣传,并立即(他们希望)拥有大量用户群。

Generally, the garage guys envy the big bang guys.

一般来说,车库里的人都羡慕那些大爆炸的人。

The big bang guys are smooth and confident and respected by the VCs.

Big Bang 的人圆滑、自信,受到风险投资人的尊重。

They can afford the best of everything, and the PR campaign surrounding the

他们可以买得起最好的一切,而围绕这些的公关活动

launch has the side effect of making them celebrities.

发射的副作用是让他们成为名人。

The organic growth guys, sitting in their garage, feel poor and unloved.

有机增长的人坐在车库里,感到贫穷和不被爱。

And yet I think they are often mistaken to feel sorry for themselves.

但我认为他们常常错误地为自己感到难过。

Organic growth seems to yield better technology and richer founders than the big bang method.

与大爆炸法相比,有机增长似乎能带来更好的技术和更富有的创始人。

If you look at the dominant technologies today, you'll find that most of them grew organically.

如果你看看当今的主导技术,你会发现它们中的大多数都是有机增长的。

This pattern doesn't only apply to companies.

这种模式不仅适用于公司。

You see it in sponsored

您可以在赞助中看到它

research too.

研究也。

Multics and Common Lisp were big-bang projects, and Unix and MacLisp were organic growth projects.

Multics 和 Common Lisp 是大爆炸项目,而 Unix 和 MacLisp 是有机增长项目。

10 Redesign "The best writing is rewriting," wrote E.

10 重新设计 “最好的写作就是重写,”E 写道。

B.

B.

White.

白色。

Every good writer knows this, and it's true for software too.

每个优秀的作家都知道这一点,对于软件来说也是如此。

The most important part of design is redesign.

设计中最重要的部分是重新设计。

Programming languages, especially, don't get redesigned enough.

尤其是编程语言,没有得到足够的重新设计。

To write good software you must simultaneously keep two opposing

要编写好的软件,您必须同时保持两个相反的状态

ideas in your head.

你脑子里的想法。

You need the young hacker's naive faith in his abilities, and at the same time the veteran's skepticism.

你需要年轻黑客对自己能力的天真信心,同时也需要老黑客的怀疑态度。

You have to be able to think how hard can it be?

你必须能够想到这有多难?

with one half of your brain while thinking it will never work with the other.

你用你的一半大脑思考,却认为另一半大脑永远无法发挥作用。

The trick is to realize that there's no real contradiction here.

关键是要认识到这里并不存在真正的矛盾。

You want to be optimistic and skeptical about two different things.

你想要对两件不同的事情保持乐观和怀疑。

You have to be optimistic about the possibility of solving the

你必须对解决问题的可能性持乐观态度

problem, but skeptical about the value of whatever solution you've got so far.

问题,但对迄今为止所得到的任何解决方案的价值持怀疑态度。

People who do good work often think that whatever they're working on is no good.

那些做得很好的人常常认为他们所做的一切都是不好的。

Others see what they've done and are full of wonder, but the creator is full of worry.

别人看到他们所做的一切,充满惊奇,但创造者却充满担忧。

This pattern is no coincidence: it is the worry that made the work good.

这种模式并非巧合:正是忧虑让工作变得出色。

If you can keep hope and worry balanced, they will drive a project forward the same way your two legs drive a bicycle forward.

如果你能保持希望和忧虑之间的平衡,它们就会推动项目向前发展,就像你的两条腿推动自行车前进一样。

In the

在

first phase of the two-cycle innovation engine, you work furiously on some problem, inspired by your confidence that you'll be able to solve it.

在两轮创新引擎的第一阶段,你会疯狂地解决某个问题,并受到你能够解决它的信心的启发。

In the second phase, you look at what you've done in the cold light of morning, and see all its flaws very clearly.

在第二阶段,你在清晨的冷光下审视自己所做的事情,并非常清楚地看到它的所有缺陷。

But as long as your critical spirit doesn't outweigh your hope, you'll be able to look at your admittedly incomplete system, and think, how hard can it be to get the rest of the way?, thereby continuing

但只要你的批判精神不超过你的希望,你就能够审视你公认的不完整的系统,并思考,完成剩下的路有多难?,从而继续

the cycle.

循环。

It's tricky to keep the two forces balanced.

保持两种力量的平衡是很棘手的。

In young hackers, optimism predominates.

在年轻的黑客中,乐观情绪占主导地位。

They produce something, are convinced it's great, and never improve it.

他们生产出一些东西,并确信它很棒,但从不改进它。

In old hackers, skepticism predominates, and they won't even dare to take on ambitious projects.

在老黑客中,怀疑主义占主导地位,他们甚至不敢承担雄心勃勃的项目。

Anything you can do to keep the redesign cycle going is good.

任何能让重新设计周期继续进行的事情都是好的。

Prose can be rewritten over and over until you're happy with it.

散文可以一遍又一遍地重写,直到你满意为止。

But software, as a rule, doesn't get redesigned enough.

但软件通常没有得到足够的重新设计。

Prose has

散文有

readers, but software has users.

读者,但软件有用户。

If a writer rewrites an essay, people who read the old version are unlikely to complain that their thoughts have been broken by some newly introduced incompatibility.

如果作家重写一篇文章,阅读旧版本的人不太可能抱怨他们的思想被一些新引入的不兼容性所破坏。

Users are a double-edged sword.

用户是一把双刃剑。

They can help you improve your language, but they can also deter you from improving it.

它们可以帮助你提高你的语言,但也可以阻止你提高它。

So choose your users carefully, and be slow to grow their number.

因此,请谨慎选择用户,并缓慢增加用户数量。

Having users is like optimization: the wise course is to delay it.

拥有用户就像优化:明智的做法是推迟优化。

Also,

另外,

as a general rule, you can at any given time get away with changing more than you think.

一般来说,你在任何特定时间都可以做出比你想象的更多的改变。

Introducing change is like pulling off a bandage: the pain is a memory almost as soon as you feel it.

引入改变就像撕掉绷带:一旦你感觉到疼痛,它就会成为记忆。

Everyone knows that it's not a good idea to have a language designed by a committee.

每个人都知道,由委员会设计一种语言并不是一个好主意。

Committees yield bad design.

委员会产生了糟糕的设计。

But I think the worst danger of committees is that they interfere with redesign.

但我认为委员会最大的危险是它们干扰重新设计。

It is so much work to introduce changes that no one wants to bother.

引入变革是一项繁重的工作,没有人愿意打扰。

Whatever a committee decides tends to stay that way, even if most of the members don't like it.

无论委员会做出什么决定,即使大多数成员不喜欢,它也往往会保持这种状态。

Even a committee of two gets in the way of redesign.

即使是两个人的委员会也会妨碍重新设计。

This happens particularly in the interfaces between pieces of software written by two different people.

这种情况尤其发生在两个不同人编写的软件之间的接口中。

To change the interface both have to agree to change it at once.

要更改界面,双方必须立即同意更改。

And so interfaces tend not to change at all, which is a problem because they tend to be one of the most ad hoc

因此,接口往往根本不会改变,这是一个问题,因为它们往往是最特别的接口之一

parts of any system.

任何系统的一部分。

One solution here might be to design systems so that interfaces are horizontal instead of vertical — so that modules are always vertically stacked strata of abstraction.

这里的一种解决方案可能是设计系统,使界面是水平的而不是垂直的——这样模块总是垂直堆叠的抽象层。

Then the interface will tend to be owned by one of them.

那么该接口往往会归其中之一所有。

The lower of two levels will either be a language in which the upper is written, in which case the lower level will own the interface, or it will be a slave, in which

两个级别中较低的一个级别要么是上一个级别所用的语言,在这种情况下,较低的级别将拥有该接口,要么它将是一个从属,在这种情况下

case the interface can be dictated by the upper level.

如果接口可以由上层指定。

11 Lisp What all this implies is that there is hope for a new Lisp.

11 Lisp 所有这一切都意味着新的 Lisp 是有希望的。

There is hope for any language that gives hackers what they want, including Lisp.

任何语言都有希望为黑客提供他们想要的东西,包括 Lisp。

I think we may have made a mistake in thinking that hackers are turned off by Lisp's strangeness.

我认为我们可能犯了一个错误,即认为黑客因 Lisp 的陌生性而望而却步。

This comforting illusion may have prevented us from seeing the real problem with Lisp, or at least Common Lisp, which is that it sucks for doing what hackers

这种令人安慰的错觉可能让我们看不到 Lisp 的真正问题,或者至少是 Common Lisp 的真正问题,那就是它做黑客的事情很糟糕

want to do.

想做。

A hacker's language needs powerful libraries and something to hack.

黑客的语言需要强大的库和一些可以破解的东西。

Common Lisp has neither.

Common Lisp 两者都没有。

A hacker's language is terse and hackable.

黑客的语言简洁且易于破解。

Common Lisp is not.

Common Lisp 则不然。

The good news is, it's not Lisp that sucks, but Common Lisp.

好消息是,糟糕的不是 Lisp,而是 Common Lisp。

If we can develop a new Lisp that is a real hacker's language, I think hackers will use it.

如果我们能够开发出一种新的 Lisp,一种真正的黑客语言,我认为黑客会使用它。

They will use whatever language does the job.

他们将使用任何能完成工作的语言。

All we have to do is make sure this new Lisp does some important

我们所要做的就是确保这个新的 Lisp 做一些重要的事情

job better than other languages.

比其他语言更好的工作。

History offers some encouragement.

历史提供了一些鼓励。

Over time, successive new programming languages have taken more and more features from Lisp.

随着时间的推移,相继出现的新编程语言从 Lisp 中获取了越来越多的功能。

There is no longer much left to copy before the language you've made is Lisp.

在你创造的语言成为 Lisp 之前,已经没有太多需要复制的了。

The latest hot language, Python, is a watered-down Lisp with infix syntax and no macros.

最新的热门语言 Python 是一种带有中缀语法且没有宏的淡化 Lisp。

A new Lisp would be a natural step in this progression.

新的 Lisp 将是这一进程中自然而然的一步。

I sometimes think that it would be a good marketing trick to call

有时我认为打电话是一个很好的营销技巧

it an improved version of Python.

它是Python的改进版本。

That sounds hipper than Lisp.

这听起来比 Lisp 更时髦。

To many people, Lisp is a slow AI language with a lot of parentheses.

对于很多人来说,Lisp 是一种运行缓慢、带有大量括号的 AI 语言。

Fritz Kunze's official biography carefully avoids mentioning the L-word.

弗里茨·昆泽 (Fritz Kunze) 的官方传记小心翼翼地避免提及“L”一词。

But my guess is that we shouldn't be afraid to call the new Lisp Lisp.

但我的猜测是,我们不应该害怕将新的 Lisp 称为 Lisp。

Lisp still has a lot of latent respect among the very best hackers — the ones who took 6.001 and understood it, for example.

Lisp 在最优秀的黑客中仍然拥有很多潜在的尊重——例如,那些拿到 6.001 并理解它的人。

And those are the users you need to win.

这些就是您需要赢得的用户。

In "How to Become a Hacker," Eric Raymond describes Lisp as something like Latin or Greek — a language you should learn as an intellectual exercise, even though you won't actually use it: Lisp is worth learning for the profound enlightenment experience you will have when you finally get it; that experience will make you a better programmer for the rest of your days, even if you never actually use Lisp itself a lot.

在《如何成为一名黑客》中,埃里克·雷蒙德 (Eric Raymond) 将 Lisp 描述为类似拉丁语或希腊语的语言 — 一种你应该作为智力练习来学习的语言,即使你不会真正使用它:Lisp 值得学习,因为当你最终掌握它时,你将获得深刻的启蒙体验;即使你实际上从未经常使用 Lisp 本身,这种经历也会让你在余下的日子里成为一名更好的程序员。

If I didn't know Lisp, reading this would set me asking questions.

如果我不懂 Lisp,读这篇文章会让我提出问题。

A language that would make me a better programmer, if it means anything at all, means a language that would be better for programming.

一种能让我成为更好的程序员的语言,如果有什么意义的话,意味着一种更适合编程的语言。

And that is in fact the implication of what Eric is saying.

这实际上就是埃里克所说的含义。

As long as that idea is still floating around, I think hackers will be receptive enough to a new Lisp, even if it is called Lisp.

只要这个想法仍然存在,我认为黑客就会足够容易地接受新的 Lisp,即使它被称为 Lisp。

But this Lisp must be a hacker's language, like the classic Lisps of

但是这个Lisp一定是黑客的语言,就像经典的Lisps一样

the 1970s.

20世纪70年代。

It must be terse, simple, and hackable.

它必须简洁、简单且易于修改。

And it must have powerful libraries for doing what hackers want to do now.

它必须拥有强大的库来完成黑客现在想做的事情。

In the matter of libraries I think there is room to beat languages like Perl and Python at their own game.

就库而言,我认为 Perl 和 Python 等语言在它们自己的游戏中还有击败它们的空间。

A lot of the new applications that will need to be written in the coming years will be server-based applications .

未来几年需要编写的许多新应用程序将是基于服务器的应用程序。

There's no reason a new Lisp shouldn't have string libraries as good as Perl, and if this new Lisp also had powerful

没有理由一个新的 Lisp 不应该有像 Perl 一样好的字符串库,如果这个新的 Lisp 也有强大的功能的话

libraries for server-based applications, it could be very popular.

基于服务器的应用程序的库,它可能会非常受欢迎。

Real hackers won't turn up their noses at a new tool that will let them solve hard problems with a few library calls.

真正的黑客不会对一个新工具嗤之以鼻,因为这个新工具可以让他们通过几次库调用来解决难题。

Remember, hackers are lazy.

请记住,黑客是懒惰的。

It could be an even bigger win to have core language support for server-based applications.

为基于服务器的应用程序提供核心语言支持可能是一个更大的胜利。

For example, explicit support for programs with multiple users, or data ownership at the level of type tags.

例如,对具有多个用户的程序的显式支持,或者类型标记级别的数据所有权。

Server-based applications also give us the answer to the question of what this new Lisp will be used to hack.

基于服务器的应用程序也为我们提供了这个新 Lisp 将用于破解什么问题的答案。

It would not hurt to make Lisp better as a scripting language for Unix.

让 Lisp 成为更好的 Unix 脚本语言不会有什么坏处。

(It would be hard to make it worse.) But I think there are areas where existing languages would be easier to beat.

(很难让情况变得更糟。)但我认为在某些领域现有语言更容易被击败。

I think it might be better to follow the model of Tcl, and supply the Lisp together with a complete system for supporting server-based applications.

我认为遵循 Tcl 的模型可能会更好,并提供 Lisp 和完整的系统来支持基于服务器的应用程序。

Lisp is a natural

Lisp 是天生的

fit for server-based applications.

适合基于服务器的应用程序。

Lexical closures provide a way to get the effect of subroutines when the ui is just a series of web pages.

当 ui 只是一系列网页时,词法闭包提供了一种获得子例程效果的方法。

S-expressions map nicely onto html, and macros are good at generating it.

S 表达式可以很好地映射到 html,并且宏可以很好地生成它。

There need to be better tools for writing server-based applications, and there needs to be a new Lisp, and the two would work very well together.

需要有更好的工具来编写基于服务器的应用程序,并且需要有一个新的 Lisp,并且两者可以很好地协同工作。

12 The Dream Language By way of summary, let's try describing the hacker's dream language.

12 梦想语言 作为总结,让我们尝试描述一下黑客的梦想语言。

The dream language is beautiful , clean, and terse.

梦想的语言美丽、干净、简洁。

It has an interactive toplevel that starts up fast.

它有一个快速启动的交互式顶层。

You can write programs to solve common problems with very little code.

您可以使用很少的代码编写程序来解决常见问题。

Nearly all the code in any program you write is code that's specific to your application.

您编写的任何程序中几乎所有代码都是特定于您的应用程序的代码。

Everything else has been done for you.

其他一切都已为您完成。

The syntax of the language is brief to a fault.

该语言的语法非常简短。

You never have to type an unnecessary character, or even to use the shift key much.

您永远不必输入不必要的字符,甚至不必频繁使用 Shift 键。

Using big abstractions you can write the first version of a program very quickly.

使用大抽象,您可以非常快速地编写程序的第一个版本。

Later, when you want to optimize, there's a really good profiler that tells you where to focus your attention.

稍后,当您想要优化时,有一个非常好的分析器可以告诉您将注意力集中在哪里。

You can make inner loops blindingly fast, even writing inline byte code if you need to.

您可以使内部循环快得令人眼花缭乱,甚至可以根据需要编写内联字节代码。

There are lots of good examples to learn from, and the language is intuitive enough that you can learn how to use it from examples in

有很多很好的例子可供学习,而且该语言足够直观,您可以从以下示例中学习如何使用它

a couple minutes.

几分钟。

You don't need to look in the manual much.

你不需要看太多手册。

The manual is thin, and has few warnings and qualifications.

该手册很薄,并且几乎没有警告和限定。

The language has a small core, and powerful, highly orthogonal libraries that are as carefully designed as the core language.

该语言有一个小核心,以及与核心语言一样精心设计的强大、高度正交的库。

The libraries all work well together; everything in the language fits together like the parts in a fine camera.

这些库都可以很好地协同工作;该语言中的所有内容都像精美相机的各个部件一样组合在一起。

Nothing is deprecated, or retained for compatibility.

没有任何内容被弃用或保留以实现兼容性。

The source code of all the libraries

所有库的源代码

is readily available.

很容易获得。

It's easy to talk to the operating system and to applications written in other languages.

与操作系统和用其他语言编写的应用程序进行对话很容易。

The language is built in layers.

该语言是分层构建的。

The higher-level abstractions are built in a very transparent way out of lower-level abstractions, which you can get hold of if you want.

较高级别的抽象是以一种非常透明的方式从较低级别的抽象中构建出来的,如果您愿意,您可以获取这些抽象。

Nothing is hidden from you that doesn't absolutely have to be.

没有什么是绝对必要的。

The language offers abstractions only as a way of saving you work,

该语言提供抽象只是为了节省您的工作量,

rather than as a way of telling you what to do.

而不是告诉您要做什么的方式。

In fact, the language encourages you to be an equal participant in its design.

事实上,该语言鼓励您平等地参与其设计。

You can change everything about it, including even its syntax, and anything you write has, as much as possible, the same status as what comes predefined.

您可以更改它的所有内容,甚至包括它的语法,并且您编写的任何内容都尽可能具有与预定义的状态相同的状态。

Notes [1] Macros very close to the modern idea were proposed by Timothy Hart in 1964, two years after Lisp 1.5 was released.

注释 [1] 非常接近现代思想的宏是由 Timothy Hart 于 1964 年,即 Lisp 1.5 发布两年后提出的。

What was

什么是

missing, initially, were ways to avoid variable capture and multiple evaluation; Hart's examples are subject to both.

最初,缺少避免变量捕获和多重评估的方法;哈特的例子同时适用于两者。

[2] In When the Air Hits Your Brain, neurosurgeon Frank Vertosick recounts a conversation in which his chief resident, Gary, talks about the difference between surgeons and internists ("fleas"): Gary and I ordered a large pizza and found an open booth.

[2] 在《当空气击中你的大脑》一书中,神经外科医生弗兰克·沃托西克(Frank Vertosick)讲述了一次对话,在对话中,他的首席住院医师加里(Gary)谈到了外科医生和内科医生(“跳蚤”)之间的区别:加里和我点了一份大披萨,找到了一个开放的摊位。

The chief lit a cigarette.

酋长点燃了一根香烟。

"Look at those goddamn fleas, jabbering

“看看那些该死的跳蚤,叽叽喳喳地叫着

about some disease they'll see once in their lifetimes.

关于他们一生中会遇到一次的某种疾病。

That's the trouble with fleas, they only like the bizarre stuff.

这就是跳蚤的麻烦所在,它们只喜欢奇怪的东西。

They hate their bread and butter cases.

他们讨厌面包和黄油盒。

That's the difference between us and the fucking fleas.

这就是我们和跳蚤的区别。

See, we love big juicy lumbar disc herniations, but they hate hypertension...." It's hard to think of a lumbar disc herniation as juicy (except literally).

你看,我们喜欢大而多汁的腰椎间盘突出症,但他们讨厌高血压......”很难认为腰椎间盘突出症是多汁的(除了字面上)。

And yet I think I know what they mean.

但我想我知道它们的意思。

I've often had

我经常有

a juicy bug to track down.

一个值得追踪的有趣的错误。

Someone who's not a programmer would find it hard to imagine that there could be pleasure in a bug.

非程序员很难想象 bug 能带来乐趣。

Surely it's better if everything just works.

如果一切正常的话当然更好。

In one way, it is.

从某种意义上说,确实如此。

And yet there is undeniably a grim satisfaction in hunting down certain sorts of bugs.

然而,不可否认的是,在追捕某些类型的错误时会产生一种严峻的满足感。

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