Browsed by
标签:Alexander Stepanov

面向对象是个骗局?!

面向对象是个骗局?!

今天在网上看到网页叫“Object Orientation Isa Hoax”——面向对象是一个骗局,标题很有煽动性(注:该网站上还有一个网页叫Object Orientation Is Dead),好吧,打开看看上面有些 什么,发现这个网页是在收集一些关于“面向对象的反动言论”,没想到的是,很多言论出自很多大师之口。比如:Alexander Stepanov和Bjarne Stroustrup。这些言论挺有意思的,所以,我摘两段在下面:

第一段是Alexander Stepanov的(不要告诉我你不知道这个人,STL之父,关于他的故事,可以到这里看看)。他N年前作过一段采访,原文在这里(我非常建议大家去读一下这篇采访,相当过瘾),译文在这里(不过有地方把原意都译反了,我重译了一下),其中有一个问答被上述的那个面向对象反动言论的网页收录了:

Alexander Stepanov

Question:
I think STL and Generic Programming mark a definite departure from the common C++ programming style, which I find is almost completely derived from SmallTalk. Do you agree?

提问
我认为STL和泛型编程标志着非同一般的C++编程风格,而一般C++风格几乎完全是从SmallTalk派生过来的。你同意吗?

Answer:
Yes. STL is not object oriented. I think that object orientedness is almost as much of a hoax as Artificial Intelligence. I have yet to see an interesting piece of code that comes from these OO people. In a sense, I am unfair to AI: I learned a lot of stuff from the MIT AI Lab crowd, they have done some really fundamental work: Bill Gosper’s Hakmem is one of the best things for a programmer to read. AI might not have had a serious foundation, but it produced Gosper and Stallman (Emacs), Moses (Macsyma) and Sussman (Scheme, together with Guy Steele). I find OOP technically unsound. It attempts to decompose the world in terms of interfaces that vary on a single type. To deal with the real problems you need multisorted algebras – families of interfaces that span multiple types. I find OOP philosophically unsound. It claims that everything is an object. Even if it is true it is not very interesting – saying that everything is an object is saying nothing at all. I find OOP methodologically wrong. It starts with classes. It is as if mathematicians would start with axioms. You do not start with axioms – you start with proofs. Only when you have found a bunch of related proofs, can you come up with axioms. You end with axioms. The same thing is true in programming: you have to start with interesting algorithms. Only when you understand them well, can you come up with an interface that will let them work.

回答:
是的。STL不是面向对象的。我认为面向对象和人工智能差不多,都是个骗局。我至今仍然没有从那些OO编程的人那里看到一丁点有意思的代码。从某种意义上来说,我这么说对人工智能(AI)并不公平:因为我听说过很多MIT(麻省理工大) AI实验室里一帮人搞出来的东西,而且他们的确直正干了一些基础性的工作:Bill Gosper的Hakmem是程序员最好的读物之一。AI或许没有一个实实在在的基础,但它造就了Gosper和Stallman(Emacs), Moses(Macsyma)和Sussman(Scheme, 和Guy Steele一起)。

  • 我发现OOP在技术上是荒谬的,它企图把事物按照不同单个类型的接口来解构,为了处理实际问题,你需要多种代数方法——横跨多种类型的接口族;
  • 我发现OOP在哲学上是荒谬的,它声称一切都是对象。即使这是真的也不是很有趣——因为说一切都是对象跟什么都没说一样;
  • 我发现OOP的方法论是错误的,它从类开始,就好像数学应该从从公理开始一样。其实你不会是从公理开始的,而是从证明开始。直到你找到了一大堆相关证据后你才能归纳出公理,然后以公理结束。在程序设计方面存在着同样的事实:你要从有趣的算法开始。只有很好地理解了算法,你才有可能提炼出接口以让其工作。

<———>

下面,我们再来看C++的发明者Bjarne Stroustrup,在1998年IEEE采访时的一段话(全篇见这里),下面是其中的几段话:(我的翻译如下)

阅读全文 Read More

好烂啊有点差凑合看看还不错很精彩 (28 人打了分,平均分: 4.57 )
Loading...