Browsed by
标签: Bjarne Stroustrup

面向对象是个骗局?!

面向对象是个骗局?!

今天在网上看到网页叫“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

好烂啊有点差凑合看看还不错很精彩 (37 人打了分,平均分: 4.14 )
Loading...
最佳编程语录

最佳编程语录

以前本站发布过《22条经典的编程引言》、《编程引言补充》、《Linus Torvalds 语录》还有《十条不错的编程观点》。今天向大家介绍“最佳编程语录”,条条都是很不错的语录,如同我们的太阳,照亮了我们的方向(所以我们选用了一个红色的图片,希望能够通过五毛们的网络审查)。其中只有一两条在以前本站发布过的文章中出现过。这篇文章的出处在这里,下面是“Neo”和“陈皓”的翻译,我们的翻译水平有限,所以,我们提供了中英文对照,有不当之处,还请各位指正。

A good programmer is someone who looks both ways before crossing a one-way street. — Doug Linder, systems administrator

好的程序员这样一类人,这类人在横穿一条单行道前都要先看一下路两边。– Doug Linder, 系统管理员

A most important, but also most elusive, aspect of any tool is its influence on the habits of those who train themselves in its use. If the tool is a programming language this influence is, whether we like it or not, an influence on our thinking habits. — Edsger Dijkstra, computer scientist

关于工具,一个最重要的,也是最不易察觉的方面是,工具对使用此工具的人的习惯的潜移默化的影响。如果这个工具是一门程序语言,不管我们是否喜欢它,它都会影响我们的思维惯式。 –Edsger Dijkstra, 著名的计算机科学家。

Being abstract is something profoundly different from being vague… The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise. — Edsger Dijkstra

抽象和模糊完全地不同,抽象的目的并不是把事情变模糊,而去创建一个新的语义层,在那里是绝对精确的描述。 — Edsger Dijkstra

Besides a mathematical inclination, an exceptionally good mastery of one’s native tongue is the most vital asset of a competent programmer. — Edsger Dijkstra

除了数学爱好,对于一个有能力的程序员来说,出色地掌握自己的母语是最宝贵的财富。– Edsger Dijkstra

阅读全文 Read More

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