Glean 拾遗
专辑 / Paul Graham 文集 / 设计与研究:编程语言设计的艺术

设计与研究:编程语言设计的艺术

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

Paul Graham 在本文中剖析了设计(Design)与研究(Research)的本质区别:设计追求“好”而非“新”,研究追求“新”而非“好”。他主张编程语言设计应视为设计问题而非研究问题,核心是关注用户(但非满足用户表面需求,而是挖掘真实需求)。通过类比建筑、绘画、软件原型迭代(Worse is Better),强调快速原型、渐进式精炼、保持工作代码和单调控制对设计质量的关键作用。文章还讨论了协作在设计中的局限性——优秀设计需要独裁者(单一决策者)。适合对编程语言设计、软件设计哲学、创造性工作方法论感兴趣的工程师。

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

Visitors to this country are often surprised to find that Americans like to begin a conversation by asking "what do you do?" I've never liked this question. I've rarely had a neat answer to it. But I think I have finally solved the problem. Now, when someone asks me what I do, I look them straight in the eye and say "I'm designing a new dialect of Lisp." I recommend this answer to anyone who doesn't like being asked what they do. The conversation will turn immediately to other topics.

来到这个国家的访客常常惊讶地发现,美国人喜欢以“你是做什么的?”开启对话。我向来不喜欢这个问题,因为我很少能给出一个简洁的回答。但我想我终于解决了这个问题。现在,当有人问我做什么时,我会直视对方的眼睛说:“我正在设计一门新的 Lisp 方言。”我向所有不喜欢被问及职业的人推荐这个回答——对话会立刻转向其他话题。

§ 2

I don't consider myself to be doing research on programming languages. I'm just designing one, in the same way that someone might design a building or a chair or a new typeface. I'm not trying to discover anything new. I just want to make a language that will be good to program in. In some ways, this assumption makes life a lot easier.

The difference between design and research seems to be a question of new versus good. Design doesn't have to be new, but it has to be good. Research doesn't have to be good, but it has to be new. I think these two paths converge at the top: the best design surpasses its predecessors by using new ideas, and the best research solves problems that are not only new, but actually worth solving. So ultimately we're aiming for the same destination, just approaching it from different directions.

我不认为自己是在做编程语言研究,我仅仅是在设计一门语言,就像有人设计一栋建筑、一把椅子或一套新字体一样。我不是在试图发现新东西,只想做一门好用(good to program in)的语言。从某些方面来说,这种假设让生活轻松了很多。

设计与研究的区别似乎在于“新”与“好”。设计不必新,但必须好;研究不必好,但必须新。我认为这两条路径在顶端交汇:最好的设计通过运用新想法超越前作,最好的研究则解决那些不仅新、而且真正值得解决的问题。因此,我们最终奔向同一目的地,只是从不同方向接近它。

§ 3

What I'm going to talk about today is what your target looks like from the back. What do you do differently when you treat programming languages as a design problem instead of a research topic?

The biggest difference is that you focus more on the user. Design begins by asking, who is this for and what do they need from it? A good architect, for example, does not begin by creating a design that he then imposes on the users, but by studying the intended users and figuring out what they need.

Notice I said "what they need," not "what they want." I don't mean to give the impression that working as a designer means working as a sort of short-order cook, making whatever the client tells you to. This varies from field to field in the arts, but I don't think there is any field in which the best work is done by the people who just make exactly what the customers tell them to.

The customer is always right in the sense that the measure of good design is how well it works for the user. If you make a novel that bores everyone, or a chair that's horribly uncomfortable to sit in, then you've done a bad job, period. It's no defense to say that the novel or the chair is designed according to the most advanced theoretical principles.

And yet, making what works for the user doesn't mean simply making what the user tells you to. Users don't know what all the choices are, and are often mistaken about what they really want.

The answer to the paradox, I think, is that you have to design for the user, but you have to design what the user needs, not simply what he says he wants. It's much like being a doctor. You can't just treat a patient's symptoms. When a patient tells you his symptoms, you have to figure out what's actually wrong with him, and treat that.

我今天要谈的是:从背面看目标是什么。当你把编程语言当作设计问题而非研究课题时,你会做哪些不同的事?

最大的不同在于更关注用户。设计始于提问:这是为谁做的?他们需要什么?例如,优秀的建筑师不会先创建设计方案然后强加给用户,而是研究目标用户,弄清楚他们的需求。

注意我说的是“需要什么”(what they need),而非“想要什么”。我不想让人以为设计师就像快餐厨师,顾客点什么就做什么。这在艺术领域各有不同,但我认为没有一个领域的最佳作品是由完全听从客户指令的人完成的。

客户永远是对的,因为衡量好设计的标准是它对用户是否好用。如果你写一本所有人都觉得无聊的小说,或做一把坐起来极不舒服的椅子,你就是搞砸了,没有借口。你不能说这本小说或这把椅子是根据最先进的理论原理设计的。

然而,做出对用户有效的东西,并不意味着简单照用户说的做。用户并不清楚所有选项,而且常常误解自己真正想要什么。

我认为这个悖论的答案是:你必须为用户设计,但你必须设计用户需要的,而不仅仅是他们说要的。这很像医生的工作:你不能只治疗患者的症状。当患者告诉你症状时,你必须找出他的真实病因并加以治疗。

§ 4

This focus on the user is a kind of axiom from which most of the practice of good design can be derived, and around which most design issues center.

If good design must do what the user needs, who is the user? When I say that design must be for users, I don't mean to imply that good design aims at some kind of lowest common denominator. You can pick any group of users you want. If you're designing a tool, for example, you can design it for anyone from beginners to experts, and what's good design for one group might be bad for another. The point is, you have to pick some group of users. I don't think you can even talk about good or bad design except with reference to some intended user.

You're most likely to get good design if the intended users include the designer himself. When you design something for a group that doesn't include you, it tends to be for people you consider to be less sophisticated than you, not more sophisticated.

That's a problem, because looking down on the user, however benevolently, seems inevitably to corrupt the designer. I suspect that very few housing projects in the US were designed by architects who expected to live in them. You can see the same thing in programming languages. C, Lisp, and Smalltalk were created for their own designers to use. Cobol, Ada, and Java, were created for other people to use.

If you think you're designing something for idiots, the odds are that you're not designing something good, even for idiots.

这种对用户的关注是一条公理,好的设计实践大多源于此,设计议题也多围绕它展开。

如果好的设计必须满足用户所需,那么用户是谁?当我说设计必须面向用户时,我并非暗示好的设计要迎合最低共同标准。你可以选择任何用户群体。例如,设计工具时,你可以为从初学者到专家的任何人设计;对某一群体是好的设计,对另一群体可能很糟。关键是你必须选定某个用户群体。我认为不参照特定用户,就无法谈论设计好坏。

当目标用户包含设计者本人时,最有可能获得好的设计。当你为不包含自己的群体设计时,往往会面向你认为不如自己老练的人,而非更老练的人。

这就有问题了,因为居高临下地看待用户——无论多么善意——似乎总会腐蚀设计师。我怀疑美国很少有建筑师会预期自己住进自己设计的住宅项目。编程语言中也有同样现象:C、Lisp 和 Smalltalk 是为其创造者自己使用而创建的;Cobol、Ada 和 Java 则是为他人使用而创建的。

如果你觉得自己是在为傻瓜设计东西,那么你很可能做不出好设计——即使对傻瓜也是如此。

§ 5

Even if you're designing something for the most sophisticated users, though, you're still designing for humans. It's different in research. In math you don't choose abstractions because they're easy for humans to understand; you choose whichever make the proof shorter. I think this is true for the sciences generally. Scientific ideas are not meant to be ergonomic.

Over in the arts, things are very different. Design is all about people. The human body is a strange thing, but when you're designing a chair, that's what you're designing for, and there's no way around it. All the arts have to pander to the interests and limitations of humans. In painting, for example, all other things being equal a painting with people in it will be more interesting than one without. It is not merely an accident of history that the great paintings of the Renaissance are all full of people. If they hadn't been, painting as a medium wouldn't have the prestige that it does.

Like it or not, programming languages are also for people, and I suspect the human brain is just as lumpy and idiosyncratic as the human body. Some ideas are easy for people to grasp and some aren't. For example, we seem to have a very limited capacity for dealing with detail. It's this fact that makes programming languages a good idea in the first place; if we could handle the detail, we could just program in machine language.

然而,即使你为最老练的用户设计,你仍然是在为人类设计。研究则不同。在数学中,你不会因为某个抽象概念易于人类理解而选择它,你会选择能使证明更简短的那个。我认为这在科学领域普遍成立:科学思想并不追求人性化。

但在艺术领域,情况截然不同。设计完全关乎人。人体是很奇怪的东西,但当你设计椅子时,你就是在为人设计,别无选择。所有艺术都必须迎合人类的兴趣和局限。例如在绘画中,在其他条件相同时,一幅有人物的画比没有的更吸引人。文艺复兴的伟大画作都充满人物,这并非历史的偶然。如果它们不是这样,绘画这门媒介就不会拥有如今的声望。

不管你喜不喜欢,编程语言也是为人设计的,我怀疑人脑就像人体一样凹凸不平、充满特质。有些想法容易理解,有些则不然。例如,我们处理细节的能力非常有限。正是这一点使得编程语言成为好主意——如果人类能处理细节,我们直接用机器语言编程就行了。

§ 6

Remember, too, that languages are not primarily a form for finished programs, but something that programs have to be developed in. Anyone in the arts could tell you that you might want different mediums for the two situations. Marble, for example, is a nice, durable medium for finished ideas, but a hopelessly inflexible one for developing new ideas.

A program, like a proof, is a pruned version of a tree that in the past has had false starts branching off all over it. So the test of a language is not simply how clean the finished program looks in it, but how clean the path to the finished program was. A design choice that gives you elegant finished programs may not give you an elegant design process. For example, I've written a few macro-defining macros full of nested backquotes that look now like little gems, but writing them took hours of the ugliest trial and error, and frankly, I'm still not entirely sure they're correct.

还要记住,语言主要不是成品程序的形式,而是程序必须在其中开发的东西。搞艺术的人会告诉你,对这两种情境你可能需要不同的媒介。例如,大理石对成品想法来说是漂亮且耐久的媒介,但对开发新想法来说却极不灵活。

程序就像证明,是一棵修剪过的树,过去曾有许多错误的分支。因此衡量语言的标准不仅是成品程序在其中的整洁程度,更是通往成品程序的过程是否干净。一个能带来优雅成品的设计选择,可能并不会带来优雅的设计过程。例如,我写过一些宏定义宏,里面全是嵌套的反引号,现在看起来像小宝石,但编写它们花了好几个小时进行最丑陋的试错,坦白说,我至今仍不完全确定它们是否正确。

§ 7

We often act as if the test of a language were how good finished programs look in it. It seems so convincing when you see the same program written in two languages, and one version is much shorter. When you approach the problem from the direction of the arts, you're less likely to depend on this sort of test. You don't want to end up with a programming language like marble.

For example, it is a huge win in developing software to have an interactive toplevel, what in Lisp is called a read-eval-print loop. And when you have one this has real effects on the design of the language. It would not work well for a language where you have to declare variables before using them, for example. When you're just typing expressions into the toplevel, you want to be able to set x to some value and then start doing things to x. You don't want to have to declare the type of x first. You may dispute either of the premises, but if a language has to have a toplevel to be convenient, and mandatory type declarations are incompatible with a toplevel, then no language that makes type declarations mandatory could be convenient to program in.

我们常常表现得像在用一个语言写出的成品程序有多整洁来衡量它。当看到同一个程序用两种语言书写,而其中一个版本短得多时,这似乎很有说服力。但从艺术的角度看,你不太会依赖这种测试。你不想最终得到一个像大理石一样的编程语言。

例如,在软件开发中拥有交互式顶层(在 Lisp 中称为读-求值-打印循环,REPL)是一个巨大的优势。而一旦有了它,就会对语言设计产生实际影响。比如,它对于要求在使用变量前必须先声明的语言就不太适用。当你只是向顶层键入表达式时,你希望可以设置 x 为某个值,然后对 x 进行操作,而不必先声明 x 的类型。你可以对这两个前提中的任何一个提出异议,但如果一门语言要方便就必须有顶层,而强制类型声明又与顶层不兼容,那么任何强制类型声明的语言都不可能方便地用来编程。

§ 8

In practice, to get good design you have to get close, and stay close, to your users. You have to calibrate your ideas on actual users constantly, especially in the beginning. One of the reasons Jane Austen's novels are so good is that she read them out loud to her family. That's why she never sinks into self-indulgently arty descriptions of landscapes, or pretentious philosophizing. (The philosophy's there, but it's woven into the story instead of being pasted onto it like a label.) If you open an average "literary" novel and imagine reading it out loud to your friends as something you'd written, you'll feel all too keenly what an imposition that kind of thing is upon the reader.

In the software world, this idea is known as Worse is Better. Actually, there are several ideas mixed together in the concept of Worse is Better, which is why people are still arguing about whether worse is actually better or not. But one of the main ideas in that mix is that if you're building something new, you should get a prototype in front of users as soon as possible.

The alternative approach might be called the Hail Mary strategy. Instead of getting a prototype out quickly and gradually refining it, you try to create the complete, finished, product in one long touchdown pass. As far as I know, this is a recipe for disaster. Countless startups destroyed themselves this way during the Internet bubble. I've never heard of a case where it worked.

在实践中,要获得好的设计,你必须接近并保持与用户的紧密联系。你必须不断地根据实际用户校准你的想法,尤其在初期。简·奥斯汀的小说之所以如此出色,原因之一是她会大声读给家人听。这就是为什么她从不沉溺于自我放纵的风景描写或矫揉造作的哲学说教(哲学思想当然有,但它们融入故事,而不是像标签一样贴上去)。如果你翻开一本普通的“文学”小说,想象那是你写的东西并大声读给朋友听,你会强烈地感受到那种东西对读者是多么大的负担。

在软件界,这一理念被称为“更糟即更好”。实际上,“更糟即更好”这个概念混合了好几个想法,所以人们至今仍在争论更糟是否真的更好。但其中核心思想之一是:如果你在构建新东西,应该尽快让用户看到原型。

另一种方法可以称为“孤注一掷策略”:不快速推出原型并逐步改进,而是试图一次长传达阵就完成完整成品。据我所知,这是灾难的配方。互联网泡沫期间无数初创公司就是这样毁掉的,我从未听说有哪个案例成功了。

§ 9

What people outside the software world may not realize is that Worse is Better is found throughout the arts. In drawing, for example, the idea was discovered during the Renaissance. Now almost every drawing teacher will tell you that the right way to get an accurate drawing is not to work your way slowly around the contour of an object, because errors will accumulate and you'll find at the end that the lines don't meet. Instead you should draw a few quick lines in roughly the right place, and then gradually refine this initial sketch.

In most fields, prototypes have traditionally been made out of different materials. Typefaces to be cut in metal were initially designed with a brush on paper. Statues to be cast in bronze were modelled in wax. Patterns to be embroidered on tapestries were drawn on paper with ink wash. Buildings to be constructed from stone were tested on a smaller scale in wood.

What made oil paint so exciting, when it first became popular in the fifteenth century, was that you could actually make the finished work from the prototype. You could make a preliminary drawing if you wanted to, but you weren't held to it; you could work out all the details, and even make major changes, as you finished the painting.

You can do this in software too. A prototype doesn't have to be just a model; you can refine it into the finished product. I think you should always do this when you can. It lets you take advantage of new insights you have along the way. But perhaps even more important, it's good for morale.

软件行业之外的人可能没有意识到,“更糟即更好”在艺术领域无处不在。例如在素描中,这一理念是在文艺复兴时期发现的。如今几乎每位素描老师都会告诉你,画准对象的正确方法不是沿着轮廓慢慢画,因为误差会累积,最终你会发现线条接不上。相反,你应该先用快速线条勾出大致正确的位置,然后逐步完善这一初始草图。

在大多数领域,传统上使用不同材料制作原型。用于金属雕刻的字体最初是用笔在纸上设计的;要浇铸青铜的雕像先用蜡建模;挂毯刺绣的图案用墨水在纸上渲染;石制建筑先在木质小样上测试。

15 世纪油画第一次流行时,它的激动人心之处在于:你实际上可以从原型做出成品。你可以先画一幅草图,但不必拘泥于它;你可以在完成过程中处理所有细节,甚至做出重大修改。

软件中也可以这样做。原型不必只是模型;你可以把它逐步完善成最终产品。我认为只要可能就应该这样做。这可以让你利用沿途的新见解,但也许更重要的是,它有利于士气。

§ 10

Morale is key in design. I'm surprised people don't talk more about it. One of my first drawing teachers told me: if you're bored when you're drawing something, the drawing will look boring. For example, suppose you have to draw a building, and you decide to draw each brick individually. You can do this if you want, but if you get bored halfway through and start making the bricks mechanically instead of observing each one, the drawing will look worse than if you had merely suggested the bricks.

Building something by gradually refining a prototype is good for morale because it keeps you engaged. In software, my rule is: always have working code. If you're writing something that you'll be able to test in an hour, then you have the prospect of an immediate reward to motivate you. The same is true in the arts, and particularly in oil painting. Most painters start with a blurry sketch and gradually refine it. If you work this way, then in principle you never have to end the day with something that actually looks unfinished. Indeed, there is even a saying among painters: "A painting is never finished, you just stop working on it." This idea will be familiar to anyone who has worked on software.

Morale is another reason that it's hard to design something for an unsophisticated user. It's hard to stay interested in something you don't like yourself. To make something good, you have to be thinking, "wow, this is really great," not "what a piece of shit; those fools will love it."

Design means making things for humans. But it's not just the user who's human. The designer is human too.

士气是设计的关键。我很惊讶人们很少谈论它。我最早的一位素描老师告诉我:如果你在画某样东西时感到无聊,画出来的东西就会看起来很无聊。例如,假设你要画一栋建筑,你决定逐块画出每块砖。你可以这样做,但如果你画到一半觉得无聊,开始机械地画砖而不是观察每一块,那么画出来的效果比仅仅暗示砖块更差。

通过逐步完善原型来构建东西有利于士气,因为它让你保持投入。在软件中,我的规则是:始终要有可运行的代码。如果你写的东西一小时后就能测试,那么你就有了即时回报的前景来激励自己。艺术中也是如此,尤其是在油画中。大多数画家从模糊的草图开始,逐步细化。用这种方法,原则上你永远不会在一天结束时留下看起来未完成的东西。事实上,画家之间甚至有句谚语:“画作永远不会完成,你只是停止在上面工作而已。”任何做过软件的人都会对这句话感到熟悉。

士气也是难以替不成熟的用户设计东西的另一个原因。你很难对一件自己都不喜欢的东西保持兴趣。要做出好东西,你必须想“哇,这真的很棒”,而不是“真他妈烂,那些笨蛋会喜欢它的”。

设计意味着为人类造物,但不仅用户是人,设计师也是人。

§ 11

Notice all this time I've been talking about "the designer." Design usually has to be under the control of a single person to be any good. And yet it seems to be possible for several people to collaborate on a research project. This seems to me one of the most interesting differences between research and design.

There have been famous instances of collaboration in the arts, but most of them seem to have been cases of molecular bonding rather than nuclear fusion. In an opera it's common for one person to write the libretto and another to write the music. And during the Renaissance, journeymen from northern Europe were often employed to do the landscapes in the backgrounds of Italian paintings. But these aren't true collaborations. They're more like examples of Robert Frost's "good fences make good neighbors." You can stick instances of good design together, but within each individual project, one person has to be in control.

I'm not saying that good design requires that one person think of everything. There's nothing more valuable than the advice of someone whose judgement you trust. But after the talking is done, the decision about what to do has to rest with one person.

Why is it that research can be done by collaborators and design can't? This is an interesting question. I don't know the answer. Perhaps, if design and research converge, the best research is also good design, and in fact can't be done by collaborators. A lot of the most famous scientists seem to have worked alone. But I don't know enough to say whether there is a pattern here. It could be simply that many famous scientists worked when collaboration was less common.

Whatever the story is in the sciences, true collaboration seems to be vanishingly rare in the arts. Design by committee is a synonym for bad design. Why is that so? Is there some way to beat this limitation?

I'm inclined to think there isn't-- that good design requires a dictator. One reason is that good design has to be all of a piece. Design is not just for humans, but for individual humans. If a design represents an idea that fits in one person's head, then the idea will fit in the user's head too.

注意我一直在谈论“设计师”。设计通常必须由一个人掌控才能做好,而研究项目似乎可以由多人合作。这在我看来是设计与研究之间最有趣的差异之一。

艺术领域有过著名的合作实例,但大多数更像是分子键合而非核聚变。在歌剧中,通常由一个人写剧本,另一个人谱曲。文艺复兴时期,北欧的工匠常被雇来画意大利画作背景中的风景。但这些不是真正的合作,更像是罗伯特·弗罗斯特所说的“好篱笆造就好邻居”。你可以把好的设计实例拼凑在一起,但在每个单独项目中,必须由一个人掌控。

我不是说好的设计需要一个人想出所有东西。没有什么比信任之人的建议更有价值了。但讨论结束后,做什么的决定必须由一个人做出。

为什么研究可以由合作者完成,而设计不能?这是个有趣的问题。我不知道答案。也许,如果设计与研究趋同,那么最好的研究也是好的设计,实际上也不能由合作者完成。许多最著名的科学家似乎是独立工作的。但我了解不多,无法断定是否存在某种模式。也可能只是因为许多著名科学家活跃的年代,合作还不那么普遍。

不论科学界情况如何,真正的合作在艺术领域似乎极其罕见。委员会设计是坏设计的同义词。为什么会这样?有没有办法突破这个限制?

我倾向于认为没有——好的设计需要独裁者。一个原因是好的设计必须浑然一体。设计不仅是为人类,更是为每一个具体的人。如果一个设计代表了一个人脑中容纳的想法,那么这个想法也将能容纳在用户脑中。

打开原文 ↗