天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

JavaScript-世界上誤解最深的語(yǔ)言分析

JavaScript,是世界上最流行的編程語(yǔ)言之一。事實(shí)上世界上的每一臺(tái)個(gè)人電腦都安裝并在頻繁使用至少一個(gè)JavaScript解釋器。JavaScript的流行完全是由于他在WWW腳本語(yǔ)言領(lǐng)域中的地位決定的。


Despite its popularity, few know that JavaScript is a very nice dynamic object-oriented general-purpose programming language. How can this be a secret? Why is this language so misunderstood?

盡管它很流行,但是很少有人知道JavaScript是一個(gè)非常棒的動(dòng)態(tài)面向?qū)ο笸ㄓ镁幊陶Z(yǔ)言。這居然能成為一個(gè)秘密!這門語(yǔ)言為什么被誤解如此之深?



The Name

名字

The Java- prefix suggests that JavaScript is somehow related to Java, that it is a subset or less capable version of Java. It seems that the name was intentionally selected to create confusion, and from confusion comes misunderstanding. JavaScript is not interpreted Java. Java is interpreted Java. JavaScript is a different language.

Java- 前綴很容易使人聯(lián)想到Java,并認(rèn)為它是Java的子集或簡(jiǎn)化版Java。看起來(lái)最初給它選這個(gè)名字是別有用心的,是故意混淆概念、故意制造"誤解"的。JavaScript不是解釋執(zhí)行的JavaJava是解釋執(zhí)行的JavaJavaScript是另外一種語(yǔ)言。


JavaScript has a syntactic similarity to Java, much as Java has to C. But it is no more a subset of Java than Java is a subset of C. It is better than Java in the applications that Java (fka Oak) was originally intended for.

JavaScript的語(yǔ)法和Java有相似之處,這就像Java的語(yǔ)法和C很相像一樣。但是它不是Java的子集,就像Java不是C的子集一樣。它在Java(Oak)最初打算進(jìn)軍的領(lǐng)域中比Java更好。


JavaScript was not developed at Sun Microsystems, the home of Java. JavaScript was developed at NETscape. It was originally called LiveScript, but that name wasn't confusing enough.

JavaScript不是Sun Microsystems的產(chǎn)品,Sun是Java的家JavaScript是在NETscape被開(kāi)發(fā)出來(lái)的。它最初叫LiveScript,嗯……還是這個(gè)名字好。


The -Script suffix suggests that it is not a real programming language, that a scripting language is less than a programming language. But it is really a matter of specialization. Compared to C, JavaScript trades performance for expressive power and dynamism.

-Script后綴讓人認(rèn)為他不是一門真正的編程語(yǔ)言,和一門"編程語(yǔ)言"還有相當(dāng)?shù)牟罹唷5沁@只是應(yīng)用領(lǐng)域的問(wèn)題。和C相比JavaScript是犧牲了性能但換來(lái)了豐富的表現(xiàn)力和靈活的形態(tài)。


Lisp in C's Clothing

披著C皮的Lisp

JavaScript's C-like syntax, including curly braces and the clunky for statement, makes it appear to be an ordinary procedural language. This is misleading because JavaScript has more in common with functional languages like Lisp or Scheme than with C or Java. It has arrays instead of lists and objects instead of property lists. Functions are first class. It has closures. You get lambdas without having to balance all those parens.

JavaScript的類C語(yǔ)法,包括大括號(hào)和語(yǔ)句的形式,讓它看起來(lái)像普通的面向過(guò)程編程語(yǔ)言。這是一種誤解,因?yàn)?a href=/itjie/Javajishu/ target=_blank class=infotextkey>JavaScript和函數(shù)式語(yǔ)言,比如 Lisp 或 Scheme,有更多的相似之處,而不是和C或Java。它使用數(shù)組而不是列表,使用對(duì)象而不是屬性列表。函數(shù)是第一位的,它有閉包(closures),另外你還可以使用lambda表達(dá)式。

 




Typecasting

類型轉(zhuǎn)換

JavaScript was designed to run in NETscape Navigator. Its success there led to it becoming standard equipment in virtually all web browsers. This has resulted in typecasting. JavaScript is the George Reeves of programming languages. JavaScript is well suited to a large class of non-Web-related applications

JavaScript最初被設(shè)計(jì)成在NETscape Navigator中運(yùn)行,它在Navigator中的成功引領(lǐng)它成為事實(shí)上所有web瀏覽器的標(biāo)準(zhǔn)裝備。這就造就了"類型轉(zhuǎn)換"JavaScript是編程語(yǔ)言中的 George Reeves(超人),是大量非web程序的稱職之選。




Moving Target

移動(dòng)

The first versions of JavaScript were quite weak. They lacked exception handling, inner functions, and inheritance. In its present form, it is now a complete object-oriented programming language. But many opinions of the language are based on its immature forms.

JavaScript的最初幾版非常弱,沒(méi)有異常處理,沒(méi)有內(nèi)部函數(shù)和繼承。現(xiàn)如今,它已經(jīng)成為完全面向?qū)ο蟮木幊陶Z(yǔ)言。但是這門語(yǔ)言的許多思想是基于它不成熟的形式的。


The ECMA committee that has stewardship over the language is developing extensions which, while well intentioned, will aggravate one of the language's biggest problems: There are already too many versions. This creates confusion.

ECMA委員會(huì),這門語(yǔ)言的管家,正在對(duì)它進(jìn)行擴(kuò)展,也在蓄意惡化它最大的問(wèn)題:有太多的版本。這是混亂的根源。





Design Errors

設(shè)計(jì)上的錯(cuò)誤

No programming language is perfect. JavaScript has its share of design errors, such as the overloading of + to mean both addition and concatenation with type coercion, and the error-prone with statement should be avoided. The reserved word policies are much too strict. Semicolon insertion was a huge mistake, as was the notation for literal regular expressions. These mistakes have led to programming errors, and called the design of the language as a whole into question. Fortunately, many of these problems can be mitigated with a good lint program.

沒(méi)有什么編程語(yǔ)言是完美的。JavaScript也有它設(shè)計(jì)上的錯(cuò)誤,比如重載的+號(hào)隨著類型的不同既表示"相加"又表示"連接",和本該避免的有錯(cuò)誤傾向的 with 語(yǔ)句。它的保留字策略過(guò)于嚴(yán)格。分號(hào)的插入是一個(gè)巨大的錯(cuò)誤,比如作為字面正則表達(dá)式的符號(hào)時(shí)。這些失誤已直接導(dǎo)致編程中的錯(cuò)誤,也使這門語(yǔ)言的整體設(shè)計(jì)遭人質(zhì)疑。還好,這些問(wèn)題中有許多都可以在良好的 lint 程序中得以緩解。


The design of the language on the whole is quite sound. Surprisingly, the ECMAScript committee does not appear to be interested in correcting these problems. Perhaps they are more interested in making new ones.

這門語(yǔ)言的整體設(shè)計(jì)(上的問(wèn)題)是相當(dāng)明顯的。奇怪的是ECMAScript委員會(huì)并沒(méi)有對(duì)修正其中存在的問(wèn)題表現(xiàn)出太大的興趣,也許他們更熱衷于制造新的問(wèn)題。


 


Lousy Implementations

糟糕的實(shí)現(xiàn)

Some of the earlier implementations of JavaScript were quite buggy. This reflected badly on the language. Compounding that, those implementations were embedded in horribly buggy web browsers.

JavaScript的一些早期實(shí)現(xiàn)有許多bug,這反過(guò)來(lái)對(duì)語(yǔ)言本身產(chǎn)生了很壞的影響。更糟糕的是這些滿是bug的實(shí)現(xiàn)是嵌入在滿是bug的web瀏覽器中的。




Bad Books

糟糕的書

Nearly all of the books about JavaScript are quite awful. They contain errors, poor examples, and promote bad practices. Important features of the language are often explained poorly, or left out entirely. I have reviewed dozens of JavaScript books, and I can only recommend one: JavaScript: The Definitive Guide (4th Edition) by David Flanagan. (Attention authors: If you have written a good one, please send me a review copy.)

幾乎所有的JavaScript書都是相當(dāng)可怕的。它們包含錯(cuò)誤,包含不好的例子,并鼓勵(lì)不好的做法。JavaScript語(yǔ)言的一些重要特性它們要么沒(méi)有解釋清楚,要么根本就沒(méi)有提及。我看過(guò)很多JavaScript的書,但我只能推薦一本:David Flanagan著的 JavaScript: The Definitive Guide (4th Edition)  (《JavaScript權(quán)威指南 第四版》)。(作者們請(qǐng)注意:如果你們寫出了好書請(qǐng)發(fā)給我一份副本,我給你們校對(duì)。)




Substandard Standard

準(zhǔn)標(biāo)準(zhǔn)”的標(biāo)準(zhǔn)

The official specification for the language is published by ECMA. The specification is of extremely poor quality. It is difficult to read and very difficult to understand. This has been a contributor to the Bad Book problem because authors have been unable to use the standard document to improve their own understanding of the language. ECMA and the TC39 committee should be deeply embarrassed.

ECMA公布的官方語(yǔ)言規(guī)范的質(zhì)量極其的差。不僅難讀而且極其難懂。它可為那些"糟糕的書"做出了不小的貢獻(xiàn),因?yàn)槟切┳髡邿o(wú)法通過(guò)這個(gè)標(biāo)準(zhǔn)文檔來(lái)更深地理解這門語(yǔ)言。ECMA和TC39應(yīng)該為此感到非常尷尬。




Amateurs

業(yè)余者

Most of the people writing in JavaScript are not programmers. They lack the training and discipline to write good programs. JavaScript has so much expressive power that they are able to do useful things in it, anyway. This has given JavaScript a reputation of being strictly for the amateurs, that it is not suitable for professional programming. This is simply not the case.

使用JavaScript的人大多不是程序員,他們?nèi)鄙賹懥己贸绦虻?WBR>培訓(xùn)和訓(xùn)練。JavaScript有非常強(qiáng)大的表現(xiàn)力,不管怎樣他們也能使用它做有用的事情。這給了JavaScript一個(gè)”全然適合業(yè)余愛(ài)好者而不適合專業(yè)程序員“的名聲。這很明顯是一個(gè)錯(cuò)誤。




Object-Oriented

面向?qū)ο?/SPAN>

Is JavaScript object-oriented? It has objects which can contain data and methods that act upon that data. Objects can contain other objects. It does not have classes, but it does have constructors which do what classes do, including acting as containers for class variables and methods. It does not have class-oriented inheritance, but it does have prototype-oriented inheritance.

JavaScript是面向?qū)ο蟮膯幔克袑?duì)象,它的對(duì)象可以包含數(shù)據(jù)以及對(duì)數(shù)據(jù)進(jìn)行操作的方法,對(duì)象也可以包含其他的對(duì)象。它沒(méi)有類,但是它有構(gòu)造函數(shù)來(lái)做類的事情,包括聲明類的變量和方法。它沒(méi)有面向類的繼承,但是他有面向原型的繼承。


The two main ways of building up object systems are by inheritance (is-a) and by aggregation (has-a). JavaScript does both, but its dynamic nature allows it to excel at aggregation.

構(gòu)建對(duì)象系統(tǒng)的兩大主要方法是繼承(is-a)和聚合(has-a)。這兩者JavaScript都有,但是它的動(dòng)態(tài)天性允許有比聚合更好的實(shí)現(xiàn)方式。


Some argue that JavaScript is not truly object oriented because it does not provide information hiding. That is, objects cannot have private variables and private methods: All members are public.

一些關(guān)于JavaScript不是真的面向?qū)ο蟮臓?zhēng)論其理由是它沒(méi)有提供信息隱藏。也就是說(shuō)JavaScript的對(duì)象沒(méi)有私有變量和私有方法:它的所有成員都是公開(kāi)的。


But it turns out that JavaScript objects can have private variables and private methods. (Click here now to find out how.) Of course, few understand this because JavaScript is the world's most misunderstood programming language.

但是事實(shí)是JavaScript 的對(duì)象可以有私有變量和私有方法(點(diǎn)擊這里來(lái)看如何實(shí)現(xiàn))。當(dāng)然,之所以很少有人知道這個(gè)是因?yàn)?a href=/itjie/Javajishu/ target=_blank class=infotextkey>JavaScript是世界上誤解最深的語(yǔ)言嘛。


Some argue that JavaScript is not truly object oriented because it does not provide inheritance. But it turns out that JavaScript supports not only classical inheritance, but other code reuse patterns as well.

另一些關(guān)于JavaScript不是真的面向?qū)ο蟮臓?zhēng)論其理由是它沒(méi)有提供繼承。但是事實(shí)是JavaScript不但支持經(jīng)典的繼承,而且支持其他一些代碼重用的模式。

覺(jué)得這篇文章很不錯(cuò),轉(zhuǎn)載過(guò)來(lái)與大家一起分享.

英文地址:http://www.crockford.com/Javascript/Javascript.html

中文翻譯地址:http://blog.csdn.NET/uoyevoli/archive/2006/05/19/744915.ASPx 譯者:袁曉輝

JavaScript技術(shù)JavaScript-世界上誤解最深的語(yǔ)言分析,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 色久悠悠无码偷拍自怕 | 日本熟妇多毛XXXXX视频 | 久久久国产精品免费A片蜜芽广 | 欧美性猛交XXXX乱大交极品 | 国产树林野战在线播放 | 依恋影院在线观看 | 亚洲国产AV精品卡一卡二 | 青春禁区动漫免费观看 | 国产av免费观看日本 | 国产曰韩无码亚洲视频 | 色欲久久综合亚洲精品蜜桃 | 成年女人免费播放影院 | 自慰弄湿白丝袜 | 青草国产超碰人人添人人碱 | 玄幻全黄h全肉后宫 | 色狠狠色狠狠综合天天 | 好满射太多了装不下了视频 | 伊人青青青 | 国产婷婷一区二区在线观看 | 亚洲视频免费观看 | 日韩精品久久久久影院 | a级毛片高清免费视频 | 国产麻豆AV伦| 吃胸亲吻吃奶摸下面免费视频 | 国产成人无码精品久久久影院 | 久久久无码精品亚洲欧美 | 超碰99热在线精品视频 | 日韩免费一区 | 恋夜秀场1234手机视频在线观看 | 亚洲人成网77777色在线播放 | 在线播放日韩欧美亚洲日本 | 波多野结衣教师系列6 | 国产精品视频国产永久视频 | 暖暖 免费 高清 日本 在线 | 精品久久综合1区2区3区激情 | 蜜桃TV成人网站免费打开 | 虫族bl文全肉高h | 亚洲无线码一区在线观看 | 2021精品高清卡1卡2卡3麻豆 | 妹妹好色网| 久久伊人草 |