现在的位置: 首页 > 综合 > 正文

(译文)古典哲学与编程语言

2013年09月08日 ⁄ 综合 ⁄ 共 5990字 ⁄ 字号 评论关闭

英文原文链接 : 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这样的更复杂的类型啊.
实际上两者不一定对立互斥,还是可以和谐的统一起来啊.

哎有时看几千年前那些古人们写的书时会很是感慨,虽然它们一些细节的表述上,对一些物理,生物等规律认识上在我们今天看来是错的,或不准确的.但他们那些大的思想方向,哲学理念.貌似几千年来仍然没有被超越.相较科学技术而言,在哲学思想上我们奋斗了几千年却仍然进步不大.

抱歉!评论已关闭.