[閒聊] 轉貼一篇評論 物件導向 的國外文章
原文網址:
http://coolshell.cn/articles/3036.html
我轉成繁體中文後,節錄前半篇內容於下。
--
今天在網上看到網頁叫「Object Orientation Isa Hoax」——物件導向是一個騙局,
http://c2.com/cgi/wiki?ObjectOrientationIsaHoax
標題很有煽動性
(註:該網站上還有一個網頁叫Object Orientation Is Dead),
http://c2.com/cgi/wiki?ObjectOrientationIsDead
好吧,打開看看上面有些什麼,發現這個網頁是在收集一些關於
「物件導向的反動言論」,沒想到的是,很多言論出自很多大師之口。
比如:Alexander Stepanov 和 Bjarne Stroustrup。
這些言論挺有意思的,所以,我摘兩段在下面:
第一段是Alexander Stepanov的
(不要告訴我你不知道這個人,STL之父,關於他的故事,可以到這裡看看)。
http://www.techcn.com.cn/index.php?doc-view-131345.html
他N年前作過一段採訪,原文在這裡
http://www.stlport.org/resources/StepanovUSA.html
(我非常建議大家去讀一下這篇採訪,相當過癮),譯文在這裡
http://dev.csdn.net/htmls/11/11440.html
(不過有地方把原意都譯反了,我重譯了一下),其中有一個問答被上述的那個
物件導向反動言論的網頁收錄了:
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++程式設計風格,而這種風格幾乎完全是從
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 實驗室裡一幫人搞出來的東西,
(I learned a lot of stuff from the MIT AI Lab crowd,)
而且他們的確直正幹了一些基礎性的工作:
(they have done some really fundamental work:)
Bill Gosper 的 Hakmem 是程式設計師最好的讀物之一。
AI 或許沒有一個實實在在的基礎,
(AI might not have had a serious foundation,)
但它造就了 Gosper 和 Stallman(Emacs),Moses(Macsyma)和 Sussman
(Scheme, 和 Guy Steele 一起)。
* 我發現 OOP 在技術上是荒謬的,它企圖把事物按照不同單個型態的介面來解構,
為了處理實際問題,你需要多種代數方法——橫跨多種型態的介面族;
(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.)
* 我發現 OOP 在哲學上是荒謬的,它聲稱一切都是物件。即使這是真的也不是
很有趣——因為說一切都是物件跟什麼都沒說一樣;
* 我發現 OOP 的方法論是錯誤的,它從類別開始,就好像數學要從公理開始一樣。
你不從公理開始,你就要從證明開始。直到你找到了一大堆相關證據後你才能
歸納出公理 (axioms),然後以公理結束。在程式設計方面存在著同樣的事實:
你要從有趣的演算法開始。只有很好地理解了演算法,你才有可能提煉出介面
以讓其工作。
下面,我們再來看 C++ 的發明者 Bjarne Stroustrup,在1998年 IEEE 採訪時的一段話
(全篇見這裡),
http://www2.research.att.com/~bs/ieee_interview.html
下面是其中的幾段話:(我的翻譯如下)
.....後半篇略,有興趣可至原文網址觀看。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.8.130.150
推
09/29 12:45, , 1F
09/29 12:45, 1F
→
09/29 12:46, , 2F
09/29 12:46, 2F
→
09/29 12:46, , 3F
09/29 12:46, 3F
→
09/29 12:47, , 4F
09/29 12:47, 4F
推
09/29 12:55, , 5F
09/29 12:55, 5F
→
09/29 13:00, , 6F
09/29 13:00, 6F
→
09/29 13:36, , 7F
09/29 13:36, 7F
→
09/29 13:36, , 8F
09/29 13:36, 8F
→
09/29 13:37, , 9F
09/29 13:37, 9F
→
09/29 13:57, , 10F
09/29 13:57, 10F
→
09/29 14:47, , 11F
09/29 14:47, 11F
→
09/29 14:48, , 12F
09/29 14:48, 12F
→
09/29 14:49, , 13F
09/29 14:49, 13F
→
09/29 14:49, , 14F
09/29 14:49, 14F
推
09/29 15:19, , 15F
09/29 15:19, 15F
→
09/29 15:19, , 16F
09/29 15:19, 16F
推
09/29 15:25, , 17F
09/29 15:25, 17F
→
09/29 15:35, , 18F
09/29 15:35, 18F
→
09/29 15:35, , 19F
09/29 15:35, 19F
→
09/29 15:36, , 20F
09/29 15:36, 20F
→
09/29 15:36, , 21F
09/29 15:36, 21F
→
09/29 15:37, , 22F
09/29 15:37, 22F
推
09/29 17:05, , 23F
09/29 17:05, 23F
→
09/29 17:15, , 24F
09/29 17:15, 24F
→
09/29 17:15, , 25F
09/29 17:15, 25F
→
09/29 17:26, , 26F
09/29 17:26, 26F
推
09/30 01:53, , 27F
09/30 01:53, 27F
推
09/30 23:31, , 28F
09/30 23:31, 28F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章