立即注册 登录
eNewsTree.com 返回首页

大实话的个人空间 https://www.enewstree.com/discuz/?388 [收藏] [复制] [分享] [RSS]

日志

如果哲学家是程序员

热度 1已有 2484 次阅读2013-8-30 20:19 |个人分类:科技文摘

尽管没那么明显,但至少对我而言,哲学与编程有很深刻的关系。你想想看,软件代码无非是反应了开发者看问题的视角和解决方案。在开始编码之前,开发人员会花时间反复思考待解决的问题,明确该问题的要点以及它们之间关系,这种过程正好反应了他们看待这个世界的哲学。同样地,哲学家们都在不停地琢磨他们所关心问题的重要特征,比如生命、意识或者上帝。

那么依此来看,我们可以将程序语言背后的思维与哲学家们多年的思想很好地关联起来。我们完全有足够的理由将程序语言视为一个虚拟世界中的各种不同流派的哲学,在这个虚拟世界中存在交互的实体。即使是最基本的哲学命题都有有趣的转换:比如,“什么是自我意识?”转换为“什么是反射?(reflection)

接下来是更有趣的问题:“如果哲学家们是程序员?那么他们会使用那种程序语言呢?”好吧,下面是我的答案!

 

苏格拉底:硬派汇编程序员


苏格拉底是哲学的奠基者之一,但这并不是唯一相同之处(汇编是一切程序语言之祖)。苏格拉底自创了一种明智的方法论,可以赢得每次辩论。他依靠不断地提问,直到(回答者)自相矛盾。比如,当有人声称“道德是重要的”,苏格拉底则问道“那么,你如何来定义道德呢?”

同样地,汇编程序中的任何(符号)都意味着问题。没有什么是预先设定好的(至少对纯汇编而言,而不是那些混杂了库和其他东西的汇编),并且所有的东西一定有非常清晰的含义。如果你和程序员苏格拉底在一块工作,并且给他看了类似这行的代码“var x = null;”,你的这位搭档一定会开始问到“什么是var”!

 

亚里斯多德:大牛 程序员


亚里斯多德对西方哲学有巨大的影响,创建了很多科学领域,从物理学到生物学。他第一个仔细研究实体是万物之本质命题;与柏拉图的抽象形成了对比。他的哲学采用了中庸的方法去获得道德或者是理解生活(物质与形式)

C语言对其他程序语言有着同等规模的重要影响,在语法层面尤其如此。而且,在70年代早期的时候,C语言被视为所谓的高级语言和汇编语言的中庸之道:既可以编写机器独立的程序,也具备访问底层的能力。

 

柏拉图:理想的 C++ 传教士


 

柏拉图是哲学中一个大人物,他是苏格拉底的学生,也是亚里斯多德的老师。那么,我要向你解释一个明显的疑问:C++(柏拉图)怎么会在C(亚里斯多德)之后?让我来解释。柏拉图以他的形式或理念而闻名,引出了我们周遭万物所存在的理念世界。因此,你桌子上的茶杯不过是理念世界中具有椭圆形状的对象的一个影子。用编程的行话来讲就是,它是茶杯类的一个实例。

同样地,C++作为C的扩展,是第一门尝试在任何实现之前,就提供给程序员抽象问题的能力的语言。这本身是巨大的进步,即使解决问题的代码未写一行,对问题的分类和建模显得易懂且有用。你也许奇怪为什么柏拉图不用Java,他当然可以,不过这个故事另有隐情:柏拉图对用符号去表达他的形式理念不是那么有信心,而且他偏爱对话体(参见斐多)。同样地,C++不是很自信它的发展方向,所以仍然保留C作为其子集,并完全地向后兼容不那么理想的C语法。

 

斯多葛学派:快乐的 Perl 学派


斯多葛和他们的哲学(斯多葛学派)对西方哲学,乃至世界哲学和文化都有着潜移默化而且深远的影响。有意思的是,他们不是一个人,而是相互协作的群体。斯多葛拒绝任何非物质的东西,并且试图使用命题逻辑解释这个世界。因此,斯多葛学派拒绝任何理念,而专注于道德:他们让我们远离任何无法控制的事物,而不是通过自我审思获得真智慧。斯多葛学派拒绝政治体制和形式主义,并提倡苏格拉底的公民社会。人们要成为兄弟,消除差别,为友爱的社会贡献自己(世界各国之共同法律)。你应当注意到他们对大宗教,比如基督教和佛教的影响。

最有意思的是,Perl是在80年代发明的,在这个年代里面逻辑/函数式编程最终找到了它们在程序语言世界中的位置。然而,Perl社区(和语言)和斯多葛学派有着惊人的相似。Perl作为一门语言,易扩展又灵活。事实上Perl世界中最流行的话是“不止一种方式”,简称为TIMTOADY(there is more than on way to do it)。Perl背后的哲学拒绝语法上的约束,给程序员们编码时足够自由的风格,但同时鼓励他们共享和参与社区。Perl的强大源于CPAN社区的存在,里面的模块和软件被全球的Perl程序员快乐地分享着。这门语言一直在默默影响编程世界,其深远非立见。可以一提的是Perl对脚本编程、动态类型编程和函数式编程的强烈影响,但总之可以简单地归结为一句在Perl粉中广为流传的笑话:下一轮市场崩盘将由某个Perl脚本中的bug所引发。

 

勒奈·笛卡尔:真正的 Java 大师


笛卡尔是反对经典古希腊哲学的第一位西方哲学家。他的核心思想在他的《哲学原理》中著名的第七章有所提及,该书基于我思(理性自我)这一概念。笛卡尔相信怀疑是存在的证明,我思是怀疑的起因,因此得出了著名的“我思故我在”。我思并不是我们进行的一项活动,而是我们的所有活动。所以,我们所要、所想和所感,通过我思都可以直接获得,笛卡尔几乎“证明”了上帝的存在,理由是人们能够思考上帝存在之必要这一问题。事实上,任何理念或者形式都可以通过我思来获得。笛卡尔在哲学中的另一重要贡献是:从他开始,哲学尽量避免模糊的抽象之论,去追求简练而近于几何理论的形式。笛卡尔以近乎定理的形式阐述了他的思想。

 

笛卡尔绝对是完美的Java大师。Java是第一门强类型语言,它的每一样东西在使用之前必须有一个类型(或哲学地说,它们共享一种形式),这非常符合笛卡尔关于他精确言谈的努力。笛卡尔的我思是柏拉图形式的再现,区别在于,笛卡尔认为理念存在,是因为我们思考,而且它并不存在于另一个宇宙。他的哲学可以说是纯面向对象的,是我们得到的解决方案,也是我们智慧的直接产物。

 

伊曼努尔·康德:首位 Python 程序员


康德找了通往哲学殿堂的“简易”方法:放弃采用笛卡尔的我思和经验主义这两种对立、相反的学说中的任何一种,而大喊“都要”。康德审视了人类的理性,声称被先验理性过滤的经验能通向真理。当他的哲学成熟后,开始研究美学,试图理论化解释人的审美。康德极端精准的性格,痴迷于整洁和精确,在每天固定的时刻做固定的事情,以至于他的熟人竟然将他“用于”计时。

同样地,Python是一门尝试将各种解决方案组合在一起的新程序语言。它是多范式的程序语言,从面向对象编程到基于契约的编程。Python程序员拒绝像Perl一样自由表达的形式,同时又从它借鉴了不少特性。Python强调简洁和清晰的代码。Python太“痴迷”于此,以致将空白缩进作为代码块的分隔符。在“Python之禅”的19条教义中首条便是“美胜于丑”。康德对美和艺术的追求,让他成为名副其实的首位Python程序员。

 

路德维希·维特根斯坦:天才 Haskell 程序员


维特根斯坦犹如苏格拉底的辩经,深刻地革命了西方哲学。他的札记般的哲学著作《逻辑哲学论》堪比逻辑学艰深的研究生数学读本。维特根斯坦指出语义和符号形式是一切这些问题的根源,剩下的都可明确地归为科学的范畴。依靠纯逻辑,他推导出语言内在的歧义性决定了哲学不过是在重复它自己,并且以这句“但凡不可言所,务必保持沉默”的旷世名言结束了本书,同时声称解决了所有的哲学问题。

 

维特根斯坦是天生的 Haskell 程序员。Haskell 不是第一门函数式编程语言,而是在80年代后期出现的,并被视为最为重要的函数式语言。Haskell 并不是适合所有人,就像《逻辑哲学论》一样。如维基百科中所写,它有严格的数学和逻辑形式。Haskell 是纯函数式程序语言,它重新定义了程序员使用抽象数据类型的方式,正如维特根斯坦像苏格拉底的辩论法一样,革新了现代西方哲学。

上面这些听起来也许有点奇怪,但是对程序员来说,很容易意识到它们之间深层次的联系,但我不确定哲学家们是否持有相同的观点。无论如何,至少是现在可以理解,为什么在维基百科中每一篇关于程序语言的文章中,都有“语言哲学”这特别的一节。
原文出处: ElectricTheater 译文出处: 译言-紫牛


====================================================================================

Wednesday, April 15, 2009
If Philosophers Were Programmers
Although not obvious, philosophy actually has a strong relation with programming, at least for me. If you think about it, software code reflects much of how the developer perceives the problem and its solution. Before starting to program, developers spend some time thinking over the problem,



identifying important properties and their underlying connections, a process that reveals their philosophy as the way they perceive real-word situations. Likewise, philosophers are constantly trying to identify the most important properties of the issues they reflect on, like life, conscience or God.

Under this perspective one might be able to make a consistent mapping of the ideas behind programming languages and the ideas that philosophers have come up over the years. It is perfectly reasonable to consider the programming languages as the different philosophies of a virtual world, in which entities do exist and interact with each other. To this respect, even the fundamental philosophical questions receive an interesting transformation: For example "What is self-conscience?can be rephrased as "What is reflection?".

To the fun part, one might ask: "What if philosophers were programmers? What programming language they would use?". Well, here are my answers!


Socrates : The Hardcore Assembly Programmer

Socrates was one of the founders of philosophy but this is not where the connection ends. Socrates had devised a clever methodology to win every debate. He kept asking questions until a contradiction was reached. So, when someone would claim "morality is important", Socrates would ask "How do you define morality?".


In a similar manner, everything in Assembly begs for a question. There is nothing pre-assumed (at least in pure Assembly, not the distros filled with pre-processed libraries and other junk) and everything has to be as succinct as possible to have a meaning. If you were to work with the programmer Socrates and shared something like "var x = null;", your partner would start by asking "What is var?" !



Aristotle : The Influential C Programmer



Aristotle had a huge impact on Western philosophy, founding many scientific areas, from physics to biology. He was the first to closely examine real entities as the real essence of everything, in contrast to Plato's abstractions. His philosophy is driven by the golden mean as the key to reaching morality or understanding life (matter andform). 

The C programming language was equally influential to the design of all other "programming philosophies", most obviously in the syntactical level. In addition, by the time of its writing in the early 70's, C was supposed to be the golden mean between the so-called high-level languages and the Assembly language,combining the capability to write machine-independent code combined with the power of low-level access.



Plato : The Idealistic C++ Evangelist



Plato is a huge figure in philosophy, student of Socrates and teacher of Aristotle. That said, I owe you an explanation about the obvious anomaly: How come that C++ is coming after C? Let me explain. Plato is famous for his Formor Ideas, that refer to the archetypical versionsof the things around us. So, the cup in your desk has is ashadow of a similar oval-shaped archetype in the world of Ideas. In programming words, it is an instancof the Cupclass.

Similarly, C++ , as an extension of C, is the first language that tries to capture this idea of forms by giving the developers the capability to abstract the problem before doing anything else. This is a major step by itself, since even if no actual code solving the problem is provided, the classification and the problem modelling are evident and valuable to others. You might wonder, why Plato would not program in Java. Well he could, but there is another parameter to the story: Plato is not so confident how symbols can represent his Forms, and clearly prefers the spoken dialogue (as mentioned in Phaedrus). In a similar manner, C++, not entirely confident in its direction, remains a superset of C, being fullybackwards-compatible with the more non-ideal syntax of C.



Stoics : The Happy Perl Community
Stoics and their philosophy (Stoicism) had silently, a far-reaching impact not only to Western philosophy but to

the philosophy and the global culture as a whole. Interestingly enough, there is no single man behind it, but it was actually a collaborative intellectual achievement.Stoicism denies anything immaterial and tries to explain the world through propositional logic. So, Stoics reject everything Ideal and concenrate in morality, in which they call us to get free fromanything we can't control, but rather appreciate thefreedom to self-introspect and reach true wisdom. Stoicism rejects political systems and other formalities, and promotes Socrates' citizen of the world for everyone. People are meant to be brothers, away from distinctions, aiming to contribute happily to a society of friendship and love (jus commune gentium). You should already notice the influences to most widespread religions, like Christianism and Buddism.

Most interestingly, Perl was created in the 80's, a decade in which finally logic/functional programming had found its place in the programming

languages world. However, the Perl community (and language) shares much more striking similarites with the Stoics and their philosophy. Perl as a language is to the best possible extent, free of form. Actually the most common phrase in the Perl world is "there is more than one way to do it" or TIMTOADY for short. The philosophy behind Perl rejects syntactical constraints, giving the freedom to its programmers to code in their style, but at the same time encouraging sharing and contribution to the community. Perl's power lies to a great extent to the existence of CPAN, the archive of modules and software happily shared by Perl programmers all around the globe. The language's influence to the programming world has been silent, but much more far-reaching than what is immediately observable. One could mention its strong influence to scripting, dynamic typing and functional programming, but it could be summarized to a joke which is familiar to Perl fans: The next market's crash will be triggered by a bug in someone's Perl script.



Rene Descartes : The True Java Guru

Descartes was the first philosopher of the Western culture to stand up against the Classical Ancient Greek philosophy. His core philosophy as mentioned in his famous Article 7 of the "Les principles de la philosophie" is based on the concept of cogito (=intellectual ego). Descartes believes that doubt is a proof of existence, and cogito is the cause of doubt, arriving to the famous"cogito ergo sum" (=I think therefore I exist). The cogito is not just another process we do, but actually all we do. So, what we want, imagine or feel is directly accessible through it. Descartes nearly 'proves' the existence of God, by the fact that we are able to think about the necessity of his existence. In fact any Ideal or Form can be directly accessible by our cogito. Descartes also marks another landmark in the history of philosophy: Beginning from his work, philosophy is trying to avoid confusing


abstractions and to establish a succinct, almost geometrical form. Descartes presents his ideas nearly in the form of theorems. 

Descartes would be the perfect Java guru. Java was the firststrongly-typed language, in which everything must have a type (or share a Form) before it is being used, matching perfectly the Descartes' efforts to be always exact for what he is talking about. Descarte's cogito is in fact a revisit of Plato's Forms, with a slight variation in which ideals exist because we think about them and not in another universe. To that respect, his philosophy is purelyobject-oriented, as the solutions in which we arrive, are direct products of our intellects.




Immanuel Kant: The First Python Programmer



Kant found the 'easy' way to the pantheon of philosophy by rejecting two prevailing and opposing methodologies, Descarte's cogito and the empiricismby shouting 'It's both!'. Kant investigated how humans reason, claiming that experience offers the truth, but which has already been filtered by intellectual judgement (a priori). At his mature years, he examined aesthetics, and the theory trying to explaining the way we perceive beauty. Kant was an extremely concise personality, being obsessed with tideness and exactness, doing the same things, exactly at the same time every day, to the extent that his acquaintances were 'using' him to calculate time!

Similarly, Python is a programming language that tries to combine different solutions and promote it as a new one. As a language it accepts multiple programming paradigms, from object-oriented to contract-based programming. Python programmers reject the free formats of languages such as Perl, and although they borrow several features from it, they emphasize on simple andexplicit code. Python becomes so 'obsessive' that imposeswhitespace identation as delimiters for code blocks to its users. In the "Zen of Python", the first out of the 19commandments, the first one is "Beatiful is better than ugly". Kant's obsession to beauty and aesthetics, makes him triumphantly the first Python programmer ever.



Ludwig Wittgenstein: Natural Born Haskell Programmer

Wittgenstein reformed Western philosophy going as deep as to examine Socrates' 'recipe' for debate success. His monumental work, the Tractatus Logico-Philosophicus, can be compared to a hard graduate mathematical book in Logic. Wittgenstein identifies the semantic and symbolic forms as the root of all philosophical problems, leaving the rest that can be explicitly defined as the subject of science. Using pure logic, he deducts that language inherent ambiguity is what makes philosophy repeat itself, and closing his book with the famous 'What we cannot speak of, we must pass over in silence', claims to have solved,..., all philosophical problems.


Wittgenstein is a natural born Haskell programmer. Haskell was not the first functional programming language in town, but from late 80's and onwards, it has prevailed as the most important among the group. Haskell is not meant to be accesible by anyone, and just like the austere and succinct Tractatus, as Wikipedia states, it has a strict mathematical and logical form. Haskell, being purely functional, goes as deep as redefining the way we treat abstract data types, the same way Wittgenstein goes back to Socrates' dialectic to reform modern philosophy.


These all may sound weird, but for programmers, it is easy to realize these deeper connections. I am not quite sure if the same holds for philosophers. Anyway, at least by now, it should make much more sense why in every article in Wikipedia, presenting a programming language, there is special section named "Language philosophy".



路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

小黑屋|Archiver|手机版|消息树

GMT-8, 2024-5-7 11:44 , Processed in 0.023357 second(s), 16 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

返回顶部