导航

对这篇文章中关于编程语言发展性的观点很感兴趣,不能说完全认同,但可以接受,而且事实往往正如作者所言。(仅翻译部分文字)

原文出处(The World's Most Misunderstood Programming Language Has Become the World's Most Popular Programming Language.) 

A programming language cobbles a model of computation with some sort of expressive syntax. Most languages will have a set of useful values such as numbers and texts (which most languages, strangely, callstrings), and operations that mutate and synthesize values and some form of variation or repetition, and some way of packaging operations into more convenient idioms. The variations that are possible are endless, much like the variations possible in the preparation of a fine meal or a work of music. The art in language design is knowing what to leave out. The features of a good language work together harmoniously. A good language helps us to better understand a problem and to find the best expression of its solution.

编程语言通过对一系列的表达式的组合实现了自身的运算模型。这些编程语言绝大多数都是由一系列数值、字串以及它们之间的赋值运算组成的,这些操作富有可变性和可重用性,并且这一系列的操作能很方便的被打包成更简单的形式。编程语言的这种可变性就如做一顿美味佳肴或者创作一曲好的音乐一样,充满了变数和未知。设计编程语言的艺术在于懂得去保留什么。一个好的编程语言应该保证其各种特性之间协调的工作。一个好的编程语言能够帮助我们更好的理解问题并找到最佳的解决方案。

A good language is composed of a limited set of features. But there is little agreement on which features are best. Programmers can argue endlessly about features and whether they make one language better than another. This does not mean that the features don't matter. They matter greatly. We just don't understand yet how they matter.

一门好的编程语言具有一系列的特性。而人们貌似对哪个特性是最重要的还没有定论。程序员们往往在功能性上进行无休止的争吵,来证明一门语言要比另一们好。我这样的说法这并不意味着认为语言特性不重要,他们很重要,只是我们还不理解它们因何而重要。

Language design has more to do with fashion than technology. It may seem strange that fashion is a major factor in the nerdliest of arts, but it is true. A language with radically different syntax, for example, has no hope of finding broad adoption, regardless of the brilliance of its design. This tends to constrain the rate at which languages evolve.

相比于技术,编程语言的设计更容易受潮流的影响。说潮流是影响艺术的主要因素可能让人感觉怪怪的,但事实就是这样。在不考虑语言亮点之前,一门语法完全不同的新语言是不大可能有很广泛的受众的。这样的事实迫使现有编程语言加快改革的脚步。

Like music and food, a programming language can be a product of its time. The deep problem in language design is not technological, it is psychological. A programming language should equip us with structures that help us to reason more effectively.

和音乐、食物一样,一门编程语言是时间的产物。语言设计的最大问题不在于技术,而是实用性上。一门新的编程语言应该能够更有效的帮助我们解决问题。

Programming languages are like cats. It is easier to get a new cat than to get an old cat fixed. Most successful languages are ultimately replaced by upstarts. Remodeled languages rarely match the glory of the original. Fortran was once the king of languages. It has been revised several times over the years, but the modernized dialects experienced a fraction of the prestige of Fortran IV. Similarly, Pascal was a popular structured programming language, but none of the object oriented dialects ever approached Pascal's glory. Instead, languages tend to be superseded.

开发编程语言跟买一只宠物猫很像。去买一只刚出生的小猫总是比去找一只打过疫苗的老猫容易。很多成功的语言最终都被后来者所替代。而这些改进的语言很少能够有原语言一样的风光。FORTRAN曾经是一门很主流的语言,数年来人们对FORTRAN的改进有很多次,但这些新改进产生的语言怎么也无法跟FORTRAN IV时代的光彩相比。Pascal也曾是一门很流行的结构式编程语言,但也没有一门面向对象语言向Pascal那样风光。当然,无论怎样,旧的语言总是会被取代的。

Specialized languages are fun to make, which partly explains why there are so many. If a language doesn't get too big, it can be managed by a single designer. Most languages can be identified with a single designer. Pascal: Wirth. C: Ritchie. C++: Stroustrup. Java: Gosling. C#: Hejlsberg. Rebol: Sassenrath. Python: van Rossum. PHP: Lerdorf. Perl: Wall. Ruby: Matsumoto. Lua: Ierusalimschy. E: Miller. JavaScript: Eich.

编写特定的语言是一件很有趣的事情,这也部分的解释了为啥现在有这么多种编程语言。如果一门语言的规模不是很庞大,那么它通常只需由一个设计人员管理即可。大多数语言都可以找到一一对应的设计人员。

Most languages die in obscurity. Only a few are able to build a following beyond a single project or company. And only a very small number of languages become important.

大多数语言都会在不知不觉中被淘汰,其中只有一部分语言通过某个项目或者某个公司的支持存活下来,而这当中只有很小一部分成为了很重要的语言。

There are two ways that a language becomes important. The first is as a source or proving ground for important ideas. This includes languages like Smalltalk and Scheme. These languages are not widely used, but are generally recognized as brilliant, but out of fashion. They have a powerful influence on language designers.

一门语言要变得重要有两种途径。一是成为重要技术的基础和支撑,比如Smalltalk和Scheme就属于这种语言,这些语言不会被广泛使用,但是被公认为是优秀的语言,不会过时。这些语言对其设计者本身也产生了重要的影响。

The second way that a language becomes important is by becoming popular.There are many things that a programmer must consider when selecting a program language unless that programmer is writing for web browsers where the only choice currently is JavaScript.

另一种方法就是试图让语言变得流行。程序员通常在选择编程语言时都需要有很多种考虑,除了写Web程序,因为这时他们唯一的选择就是JavaScript。 

JavaScript is an astonishing language, in the very worst sense. Its astonishing nature led to a very bad reputation. JavaScript is also coupled with The DOM, a horrendous API. There is a lot of confusion about where JavaScript ends and the DOM begins. There is lots of chatter about improving JavaScript, but that by itself would do little to improve the lives of web developers. The language is burdened with too many features, including many that interact badly or were poorly designed. It is a language that has, as Emperor Joseph would say, too many notes.

JavaScript是一门非常灵活的语言,这一点让人们对它产生了很多负面的印象。而且JavaScript总是和DOM这个可怕的API一起出现,关于这点,总会有不少关于什么地方是JavaScript什么地方又是DOM的争论。总会有一些声音说要改进JavaScript,但是其本身的改进其实对Web开发者并没有多少帮助。这个语言负载了太多的特性,这其中也包括那些交互性差以及设计糟糕的功能。正如Emperor Joseph所说,这是一门有太多东西的语言。

So how did a language with such obvious deficiencies become the Sole Programming Language of the Web? Brendan Eich convinced his pointy-haired boss at Netscape that the Navigator browser should have its own scripting language, and that only a new language would do, a new language designed and implemented in big hurry, and that no existing language should be considered for that role. The Internet Explorer team at Microsoft wanted to capture Netscape's market share, so they carefully reverse engineered Netscape's language, huge hairy warts and all. The other browser makers followed Microsoft's lead. There is no standard that says that a web browser must implement JavaScript; JavaScript is the only language implemented in all popular web browsers. There was no careful review of the language or its problem domain. There was no review of its suitability or the soundness of its design. It was slapped together at Netscape, and then copied elsewhere. Given the process that created JavaScript and made it a de facto standard, we deserve something far worse.

那么这门有诸多不足的语言为何成为了Web开发语言的唯一选择呢?Brendan Eich在Netscape时,他试图让那个无能的老板确信,浏览器应该有自己的脚本语言,而且只能是一门新的语言,在所有现存语言都还没有注意到这一点之前,很快的设计和实现的这门新的语言。而后来微软的IE团队想跟Netscape分一杯羹,所以他们认真的对Netscape的语言做了反向工程,毫不掩盖的抄袭过来,后来其他的浏览器厂商也开始跟微软一样。所以并没有一个标准要求浏览器必须要实现JavaScript,但JavaScript确实是唯一一个被所有浏览器实现的语言。也并没有人花太多心思去关心这门语言存在的问题,也没有人去留意他的设计是否合适以及稳定。它起先在Netscape迅速流行起来,并被其他浏览器模仿。当我们知道了JavaScript的产生过程以及如何成为标准后,我们应该知道事实应该远比现在这个样子糟糕才对。

But despite JavaScript's astonishing shortcomings, deep down, in its core, it got something very right. When you peel away the cruft, there is an expressive and powerful programming language there. That language is being used well in many Ajax libraries to manage and augment the DOM, producing an application platform for interactive applications delivered as web pages. Ajax has become popular because JavaScript works. It works surprisingly well.

抛开JavaScript的这些缺点,深入到它的核心,其中有一些很正确的设计。当你剥离了它的表面,它便是一门强大而富有表现力的语言。这门语言被很多Ajax的程序库用于管理和完善DOM,创建了基于网页形式的交互性应用程序平台。因为JavaScript的良好表现,Ajax开始流行。

JavaScript was the world's most misunderstood programming language. Its obvious defects, its unfashionable programming model, intentional mispositioning at its introduction, and its ridiculous name caused it to be rejected as unworthy by most knowledgeable programmers. But Ajax gave JavaScript a second chance.

JavaScript是世上最被误解的语言。它诸多明显的缺陷、不流行的编程模型、错误的定位、荒谬的名字,种种不好的印象导致很多有优秀的程序员抵制JavaScript。但是Ajax给了JavaScript第二次生命。

Because JavaScript is the language of the web browser, and because the web browser has become the dominant application delivery system, and because JavaScript isn't too bad, JavaScript has become the World's Most Popular Programming Language. Its popularity is growing. It is now being embedded in other applications and contexts. JavaScript has become important.

因为JavaScript是浏览器的语言,因为浏览器成为了统治性的应用交付系统因为JavaScript并不是那么烂,JavaScript已成为世界上最流行的编程语言。它的流行程度还在递增,它已经被很多程序使用,被嵌入到很多交互内容当中。JavaScript已经愈加重要。

It is better to be lucky than smart.

运气往往比聪明的头脑更重要。

 

(注:网上有很多人喜欢讨论哪门语言更优秀,其实语言并不是关键,我们需要的只是去用它,如果它有足够的运气)