(譯文)古典哲學與程式設計語言

來源:互聯網
上載者:User

英文原文連結 : http://www.perlmonks.org/?node_id=349593

前言: 覺得這篇文章寫的不錯,另外我本人以前也非常喜歡文中提到的柏拉圖和亞裡士多德,所以就拿來翻譯下跟大家分享下.不過由於本人翻譯水平有限,很多地方翻譯的不一定準確.自己翻譯的時候才真正體會到要做到翻譯得準確是多麼困難啊.比如文中有個詞Republic,你如果關看意思就是,共和國,共和政體.但如果這樣翻譯的話肯定不通的.實際上這個詞指的是柏拉圖一本著作的名字,我看那本書的中文版時看到是被翻譯成"烏托邦".

 

Ancient Philosophy And Programming Languages

 

古典哲學與程式設計語言

This is a subject that I have long thought about but had yet to write about so I thought that this would be the right place to discuss this. I will warn you however that this might be a long ramble. So please get comfortable.

這個話題我已經考慮了很久但一直沒寫出來,我覺得這裡是一個合適的地方來討論這話題.但是我要提醒你的是這可能是一篇較長的隨筆文章,所以你看的時候就悠著點啊.

 

You may not have thought about it before but Classical Philosophy (Greek specifically) has much to say about the nature of programming languages. Two Greek writers stand out as the ones that I will talk about most today. The first
is Plato who is probably one of the most famous philosophers ever. The other is his student Aristotle.

古典哲學(特別是古希臘的)闡述了很多有關程式設計語言本質的觀點,關於這點你以前可能沒有想到過.今天我重點要講的是兩位古希臘哲學家.第一個是柏拉圖,他可能是古往今來最著名的哲學家之一.另外一位是柏拉圖的學生亞裡士多德.

 

Plato in his Republic describes a notion called the "world of ideas". It goes something like this: everything in the universe has a corresponding abstract in the world of ideas. For instance, a table in the real world is just a reflection
of the Table in the world of ideas. These abstracts continue to go up a hierarchy of types until you get to the ultimate type. In fact, this was a philosopher's job, according to Plato. It was the finding by dialectic of the ultimate type from which everything
else derives.

柏拉圖在他的著作<<烏托邦>>中闡述了一種叫 "理念世界" 的觀念.理念世界的大概意思是這樣:現實世界中的任何事物在理念世界中都有一個對應的抽象概念.舉個例子,現實世界中的一張桌子只是理念世界的"桌子"的一個映射.這些抽象類別型可以沿著類階層一直往上追溯,直到終極type.實際上,按照柏拉圖的觀點,做這樣的追溯是哲學家的工作.那個萬事萬物皆源於它的終極type是可以通過辯證推理追溯到的.

 

If you are heavily into Object Oriented Programming. This may sound extremely familiar. In fact, I would suggest that the entire OOP paradigm is based upon Plato's "world of ideas". In Plato's famous "allegory of the cave", he describes
the ultimate Object as goodness. Neo-Platonists in the second century AD would describe this ultimate Object as God. In OOP terms, this is the object from which everything else implicitly derives.

如果你對物件導向程式設計有深入理解的話,上面的觀點對你來說會非常熟悉.事實上,我認為所有的物件導向編程範式都是基於柏拉圖的"理念世界".在柏拉圖著名的"洞穴寓言"中,他把終極object看成美德.不過公元2世紀出現的新柏拉圖主義者們會把這種終極object看成上帝.在物件導向編程的術語中,終極object就是這樣一個對象:所有其他對象都隱式的繼承於它.

 

Which programming languages can be described as Platonic? I would argue that Java, Perl (because all objects derive from UNIVERSAL), and Smalltalk all fall under the Platonic description. They all have an ultimate Object from which
all other objects derive. Java will pose a problem but I will return to that presently.

那麼哪些程式設計語言可以被看成是柏拉圖式的呢? 我認為 Java, Perl(因為所有的對象都繼承自UNIVERSAL),還有Smalltalk都屬於柏拉圖式的. 他們都有一個終極的Object,而所有其他對象都繼承自它.關於這一點在Java中是有點爭議的,我等會會討論這個問題.

 

Now Plato's student Aristotle takes a completely different view of the universe. Rather than each object in the universe reflecting an Object in the "world of ideas", the universe is made up of descrete primative things called atoms.
From these atoms, everything else in the universe is built. So for instance, to build a house, you must have all the atoms arranged in the right way to make wood. Then you have to arranged these "wood" objects into a house.

柏拉圖的學生亞裡士多德是用一種完全不同的觀點來看待這個世界.亞裡士多德認為這個世界是由稱為原子的離散基本物質構成的,而不是像柏拉圖說的每一個現實世界中的object都是"理念世界"中的Object的映射.現實世界中的所有事物都是由許多的原子構成的.舉個例子,為了修一個房子,你必須把所有的原子用正確的方式組織好形成一些木材,然後呢你再把這些"木材" objects組織好形成一個房子.

 

I would suggest that programming languages, which rely upon descrete primatives can be described as Aristotlean. Among these programming languages I would list: C and C++ (if there are any more which fit this description, please let
me know). The reason for this is that both of these languages build larger abstractions based upon fundimental primatives such as int, float, char, etc. For instance, an array of chars makes a string rather than having a string object which represents a line
of text (or many lines depending).

我認為所有基於離散的基本元素的程式設計語言都可以看成亞裡士多德式的程式設計語言.這樣的程式設計語言我認為有:C 和 C++ (如果還有其他合格程式設計語言,請告知下我). 我之所有把C和C++劃為一類是因為它們都是基於int ,float, char 等一些基本的元素構建更大的抽象類別型.舉個例子,通過字元數組構造一個string類型,還不是直接有一個代表字串的string類型

 

I understand that there may be some objections to these classifications. Like I alluded to above, Java has both an Aristotlean primitive system with int's, byte's, char's, etc. and a Platonic system based upon deriving from an ultimate
base class. I would state that this has little effect since you can easily use objects to simulate the Platonic environment. Interestingly, with the addition of auto-boxing in Java 1.5, it will blur this distinction even further. (As an aside, I think that
Smalltalk is the most "pure" Platonic system. Although, I do not have much experience with it.)

我知道關於這樣的分類會存在很多反對意見.就像我前面有提到的Java,實際上它同時有int,byte,char等這樣的亞裡士多德式的基本類型系統和基於繼承自終極的class的柏拉圖式類型系統.但是我要強調的是因為你能輕易的通過使用許多object來類比柏拉圖式的世界,所以上面說的情況影響不大. 有趣的是,通過在Java 1.5中添加自動裝箱機制,柏拉圖式和亞裡士多德式這樣的區分將變得更加模糊不清.(順便說下,我覺得Smalltalk是一種最"純粹"的柏拉圖式系統.儘管我在使用Smalltalk方面沒太多經驗.)

 

It is also interesting to note how Platonic programming systems almost inveriably have virtual machines to manage their environment. It seems that the only way to have a Platonic system is to have a completely separate universe pre-constructed
for its sole use.

另外有趣的是柏拉圖式的編程系統差不多總是使用虛擬機器來管理它們的運行環境.這看起來使用柏拉圖式系統的唯一方式是預先構建一個完全獨立的世界.

 

Hopefully, next time you think that a required course in Classical Philosophy has nothing to do with your computer science degree. Look very closely how Classical thought premiates the way in which you do the most modern of things,
programming. I would heartily suggest that you read both Plato's Republic and Aristotles' Physics with an eye towards programming some time. It will greatly enhance your understanding of programming languages.

希望你下次認為把古典哲學作為必修課與你的電腦科學學位沒一點關係的時候,仔細的瞧下古典的思想是怎麼應用到你做的最現代的事(也就是編程)上的.我衷心的建議你讀下柏拉圖的<<烏托邦>>與亞裡士多德的<<物理學>>,並且看的時候偶爾聯想些編程的事.這會極大的增強你理解程式設計語言的能力.

 

 

讀後感:

這篇文章的作家主要是把一些哲學思想與編程思想簡單的關聯下.並沒有過多的涉及具體的程式設計語言概念.所以我們看的時候也不必去較真了,比如認為作者有些地方可能未必說的準確,比如你認為C++雖然由於相容C有面向過程的特性,但也算是一個物件導向的語言啊.應該算是柏拉圖式的.或者說認為並不是說所有的柏拉圖式的語言系統必須要有個虛擬機器啊.實際上沒有虛擬機器也是可以的,只不過可能會損失一些功能或者實現一些功能比較麻煩.比如像自動記憶體回收這樣的功能啊.

另外柏拉圖和亞裡士多德實際上是從兩上完全不同的角度來看世界,前者是從上到下,認為先在某個"理念世界"(也有人認為這就是一個數學世界,或者上帝的世界)中有萬事萬物的概念,然後參照這些概念就構建出了我們生活的現實世界.而後者從下到上認為本來就只有那麼些簡單的原子,然後通過把這些原子按不同的方式組合起來形成一個複雜的,豐富多彩的世界.

而物件導向和面向過程程式設計語言與此相對應,前者相當於先把現實世界(這裡可以看成"理念世界")的一個個概念拿出來,也就是對我們現實世界做數學建模,構建出一些class來.然後再在電腦世界(可以看成現實世界)構建出一個個對象.而面向過程的話則是認為電腦世界就只有0101這樣簡單的"原子",然後原子再組成int,float,char這樣的稍複雜一點的類型,然後再組成struct,class這樣的更複雜的類型啊.
實際上兩者不一定對立互斥,還是可以和諧的統一起來啊.

哎有時看幾千年前那些古人們寫的書時會很是感慨,雖然它們一些細節的表述上,對一些物理,生物等規律認識上在我們今天看來是錯的,或不準確的.但他們那些大的思想方向,哲學理念.貌似幾千年來仍然沒有被超越.相較科學技術而言,在哲學思想上我們奮鬥了幾千年卻仍然進步不大.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.