您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文


2013-11-15 12:19:35  來源: JSP教程 

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


  Design Errors
  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 errorprone 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

  沒有什麼編程語言是完美的JavaScript也有它設計上的錯誤比如重載的+號隨著類型的不同既表示相加又表示連接和本該避免的有錯誤傾向的 with 語句它的保留字策略過於嚴格分號的插入是一個巨大的錯誤比如作為字面正則表達式的符號時這些失誤已直接導致編程中的錯誤也使這門語言的整體設計遭人質疑還好這些問題中有許多都可以在良好的 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


  Lousy Implementations

  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


  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 (th Edition) by David Flanagan (Attention authors: If you have written a good one please send me a review copy)

  幾乎所有的JavaScript書都是相當可怕的它們包含錯誤包含不好的例子並鼓勵不好的做法JavaScript語言的一些重要特性它們要麼沒有解釋清楚要麼根本就沒有提及我看過很多JavaScript的書但我只能推薦一本David Flanagan著的 JavaScript: The Definitive Guide (th Edition) (《JavaScript權威指南 第四版》)(作者們請注意如果你們寫出了好書請發給我一份副本我給你們校對

  Substandard Standard

  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 TC committee should be deeply embarrassed



  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



  Is JavaScript objectoriented? 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 classoriented inheritance but it does have prototypeoriented inheritance


  The two main ways of building up object systems are by inheritance (isa) and by aggregation (hasa) JavaScript does both but its dynamic nature allows it to excel at aggregation


  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


  But it turns out that JavaScript objects canhave private variables and private methods (Click here now to find out how) Of course few understand this because JavaScript is the worlds most misunderstood programming language

  但是事實是JavaScript 的對象可以有私有變量和私有方法(點擊這裡來看如何實現)當然之所以很少有人知道這個是因為JavaScript是世界上誤解最深的語言嘛

  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


  Copyright Douglas Crockford All Rights Reserved Wrrrldwide

[]  []  

    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.