日前, 我提到 Python 程序员要比使用 Java 工作的程序员更聪明。大家也许会有点疑惑吧。 我并没有 "Java 程序员何其盲目" 的意思, 我只想说 Python 程序员是很聪明的。学习一种新的编程语言都是需要花点工夫的 ──── 而 Python 并不能用来找工作。人们学习 Python 只是因为他们率真地喜欢编程, 而目前所有已知的编程语言都不能使他们满足。 这使得这种程序员成为软件公司心目中最为理想的雇员。介于此, 目前还没有一个更好的词, 我姑且叫它 Python 悖论吧: 如果公司选用一种颇为曼妙的编程语言, 他能雇到好的程序员, 因为好的编程语言总是能够吸引到优秀的程序员。然后悖论就来了: 这种语言会很快流行, 会有许多工作机会, 然后这种语言 (比如 Java) 就堕落成程序员的敲门砖了。 只有少数公司能够清醒地认识到这一点。但是还有另一种可能, 就是公司里的程序员都非常热爱他们的编程工作于是一拍即合, 从而逃离这个悖论的影响。Google, 比如说。当他们刊登招聘 Java 程序员的广告时, 同时也要求有 Python 的编程经历。 我有一个几乎懂得所有编程语言的朋友, 几乎所有的项目他都在使用 Python。据他自己说主要是因为, "他喜欢 Python 源代码在视觉感官上的体验"。对于语言的选择, 这是一个看似非常轻佻的理由。但它实际上并没有听上去那么卤莽: 当你编程时, 比起书写代码你得花更多的时间去阅读它们。如同雕塑家将泥一块一块地涂到艺术品上, 你的代码被一行一行地添加上去。因此, 如果一种语言写出的代码不那么漂亮, 它会让严谨的程序员抓狂, 恰如一位雕塑家看到一个充满瑕疵的作品一样。 既然提到了丑陋的代码, 许多人理所当然地会想到 Perl。但是 Perl 代码的丑陋只是表象, 并不是我所说的那种丑陋的类型。真正的丑陋不是肤浅地从字面代码上来评判, 而是你被迫基于一种错误的观念来架构你的程序。也许看上去 Perl 像是 "$%^&$#@! ...", 但是有许多案例证明他其实拥有比 Python 更先进的理念。 迄今为止, 不管怎么说。这两种语言尽管设计的目标不同, 但是它们, 包括 Ruby (以及 Icon, Joy, J, Lisp, 和 Smalltalk) 都是为那些真正关心程序的人创建, 并给他们使用的。这是事实。这些程序员总会试图去做得更好。 The Python Paradox August 2004 (原文地址: http://www.paulgraham.com/pypar.html) In a recent talk I said something that upset a lot of people: that you could get smarter programmers to work on a Python project than you could to work on a Java project. I didn't mean by this that Java programmers are dumb. I meant that Python programmers are smart. It's a lot of work to learn a new programming language. And people don't learn Python because it will get them a job; they learn it because they genuinely like to program and aren't satisfied with the languages they already know. Which makes them exactly the kind of programmers companies should want to hire. Hence what, for lack of a better name, I'll call the Python paradox: if a company chooses to write its software in a comparatively esoteric language, they'll be able to hire better programmers, because they'll attract only those who cared enough to learn it. And for programmers the paradox is even more pronounced: the language to learn, if you want to get a good job, is a language that people don't learn merely to get a job. Only a few companies have been smart enough to realize this so far. But there is a kind of selection going on here too: they're exactly the companies programmers would most like to work for. Google, for example. When they advertise Java programming jobs, they also want Python experience. A friend of mine who knows nearly all the widely used languages uses Python for most of his projects. He says the main reason is that he likes the way source code looks. That may seem a frivolous reason to choose one language over another. But it is not so frivolous as it sounds: when you program, you spend more time reading code than writing it. You push blobs of source code around the way a sculptor does blobs of clay. So a language that makes source code ugly is maddening to an exacting programmer, as clay full of lumps would be to a sculptor. At the mention of ugly source code, people will of course think of Perl. But the superficial ugliness of Perl is not the sort I mean. Real ugliness is not harsh-looking syntax, but having to build programs out of the wrong concepts. Perl may look like a cartoon character swearing, but there are cases where it surpasses Python conceptually. So far, anyway. Both languages are of course moving targets. But they share, along with Ruby (and Icon, and Joy, and J, and Lisp, and Smalltalk) the fact that they're created by, and used by, people who really care about programming. And those tend to be the ones who do it well.