Glean 拾遗
Albums / Paul Graham / Why Arc Isn't Especially Object-Oriented

Why Arc Isn't Especially Object-Oriented

Source www.paulgraham.com Glean’d 2026-07-07 16:34 Read 3 min
AI summary

Paul Graham questions the current mania for object-oriented programming (OOP), arguing that three and a half of the five reasons people like it are bad. Drawing on his experience with Lisp and the Arc language, he contends: OOP is a workaround for statically-typed languages without closures; it imposes discipline on mediocre programmers at big companies but produces bloated, duplicated code; it generates the appearance of work (e.g., turning a Lisp list operation into a file of classes). Graham himself has never needed CLOS and warns against adding features one has never used. The essay is a thought-provoking critique of OOP, but falls outside AI/engineering.

Original · 3 min
www.paulgraham.com ↗
§ 1

Why Arc Isn't Especially Object-Oriented

There is a kind of mania for object-oriented programming at the moment, but some of the smartest programmers I know are some of the least excited about it. My own feeling is that object-oriented programming is a useful technique in some cases, but it isn't something that has to pervade every program you write. You should be able to define new types, but you shouldn't have to express every program as the definition of new types.

I think there are five reasons people like object-oriented programming, and three and a half of them are bad:

Why Arc Isn't Especially Object-Oriented

当前对面向对象编程有一种狂热,但我认识的一些最聪明的程序员对此却最不热衷。我的看法是,面向对象编程在某些情况下是一项有用的技术,但它不必渗透到你写的每个程序里。你应该能够定义新类型,但不应强制把每个程序都表达为新类型的定义。

我认为人们喜欢面向对象编程有五个原因,其中三个半是不好的:

§ 2

Object-oriented programming is exciting if you have a statically-typed language without lexical closures or macros. To some degree, it offers a way around these limitations. (See Greenspun's Tenth Rule.)

如果你使用的静态类型语言没有词法闭包或宏,面向对象编程会令人兴奋。它在某种程度上提供了一种绕过这些限制的方法。(参见Greenspun第十条规则。)

§ 3

Object-oriented programming is popular in big companies, because it suits the way they write software. At big companies, software tends to be written by large (and frequently changing) teams of mediocre programmers. Object-oriented programming imposes a discipline on these programmers that prevents any one of them from doing too much damage. The price is that the resulting code is bloated with protocols and full of duplication. This is not too high a price for big companies, because their software is probably going to be bloated and full of duplication anyway.

Object-oriented programming generates a lot of what looks like work. Back in the days of fanfold, there was a type of programmer who would only put five or ten lines of code on a page, preceded by twenty lines of elaborately formatted comments. Object-oriented programming is like crack for these people: it lets you incorporate all this scaffolding right into your source code. Something that a Lisp hacker might handle by pushing a symbol onto a list becomes a whole file of classes and methods. So it is a good tool if you want to convince yourself, or someone else, that you are doing a lot of work.

面向对象编程在大公司很流行,因为它适合他们的软件开发方式。大公司的软件通常由庞大且频繁更换的平庸程序员团队编写。面向对象编程对这些程序员施加了一种纪律,防止任何人造成太大破坏。代价是生成的代码充满臃肿的协议和大量重复。对大公司来说,这个代价不算高,因为他们的软件反正也可能臃肿且重复。

面向对象编程会产生大量看起来像是工作的事情。在折叠纸的时代,有一种程序员每页只放五到十行代码,前面却加上二十行精心格式化的注释。面向对象编程对这些程序员来说就像可卡因:它让你将这些支撑结构直接融入源代码。一个Lisp黑客可能通过将一个符号推入列表来处理的事情,在这里变成了一整个文件类和方法的文件。所以,如果你想让自己或别人相信你正在做很多工作,这是一个好工具。

§ 4

If a language is itself an object-oriented program, it can be extended by users. Well, maybe. Or maybe you can do even better by offering the sub-concepts of object-oriented programming a la carte. Overloading, for example, is not intrinsically tied to classes. We'll see.

Object-oriented abstractions map neatly onto the domains of certain specific kinds of programs, like simulations and CAD systems.

如果语言本身是一个面向对象程序,那么用户就可以扩展它。嗯,也许吧。或者,通过按需提供面向对象编程的子概念,你可能做得更好。例如,重载本质上并不与类绑定。我们拭目以待。

面向对象的抽象能干净地映射到某些特定类型程序的领域,比如模拟和CAD系统。

§ 5

I personally have never needed object-oriented abstractions. Common Lisp has an enormously powerful object system and I've never used it once. I've done a lot of things (e.g. making hash tables full of closures) that would have required object-oriented techniques to do in wimpier languages, but I have never had to use CLOS.

Maybe I'm just stupid, or have worked on some limited subset of applications. There is a danger in designing a language based on one's own experience of programming. But it seems more dangerous to put stuff in that you've never needed because it's thought to be a good idea.

我个人从未需要面向对象的抽象。Common Lisp 拥有极其强大的对象系统,但我一次也没用过。我做过很多事(比如创建充满闭包的哈希表),这些在较弱的语言中需要面向对象技术,但我从未需要使用CLOS。

也许我只是愚蠢,或者只涉足了有限的应用程序子集。基于个人编程经验设计语言是有风险的。但更危险的是,因为某种东西被认为好就加入你从未需要过的内容。

Open source ↗