Home > Web Front-end > JS Tutorial > JavaScript: The world's most misunderstood language

JavaScript: The world's most misunderstood language

伊谢尔伦
Release: 2016-11-23 11:19:11
Original
1189 people have browsed it

 JavaScript, or Mocha, or LiveScript, or JScript, or ECMAScript, is one of the most popular programming languages ​​in the world. Virtually every personal computer in the world has at least one JavaScript interpreter installed and actively used. The popularity of JavaScript is entirely due to its status in the field of WWW scripting languages.

JavaScript: The worlds most misunderstood language

Despite its popularity, few people know that JavaScript is a great dynamic object-oriented general-purpose programming language. This can actually become a secret! Why is this language so misunderstood?

 Name

 Java- The prefix can easily make people think of Java and think it is a subset of Java or a simplified version of Java. It seems that the name was originally chosen for it with ulterior motives, to deliberately confuse concepts and create "misunderstandings". JavaScript is not interpreted Java. Java is interpreted Java. JavaScript is another language.

 The syntax of JavaScript is similar to Java, just like the syntax of Java is very similar to C. But it's not a subset of Java, just like Java is not a subset of C. It's better than Java in the areas that Java (Oak) was originally intended to go into.

 JavaScript is not a product of Sun Microsystems, Sun is the home of Java. JavaScript was developed at Netscape. It was originally called LiveScript, well... that's still a good name.

 -Script suffix makes people think that it is not a real programming language, and there is still a considerable gap between it and a "programming language". But this is only a matter of application domain. Compared with C, JavaScript sacrifices performance in exchange for rich expressiveness and flexible form.

  Lisp in C skin

JavaScript’s C-like syntax, including the form of braces and statements, makes it look like an ordinary process-oriented programming language. This is a misunderstanding, because JavaScript has more in common with functional languages, such as Lisp or Scheme, than with C or Java. It uses arrays instead of lists, and objects instead of property lists. The function comes first, it has closure (how to translate closure??), and you can also use lambda expressions.

  Type Conversion

JavaScript was originally designed to run in Netscape Navigator, and its success in Navigator led it to become standard equipment in virtually all web browsers. This creates "type conversion". JavaScript is the George Reeves (Superman) of programming languages ​​and is a competent choice for a large number of non-web programs.

  Moving target

  The first few versions of JavaScript were very weak, with no exception handling, no internal functions and no inheritance. Today, it has become a fully object-oriented programming language. But many ideas in the language are based on its immature form.

 The ECMA committee, the stewards of the language, is expanding it and deliberately exacerbating its biggest problem: too many versions. This is a source of confusion.

 Design errors

 No programming language is perfect. JavaScript also has its design errors, such as the overloaded + sign that means both "addition" and "connection" depending on the type, and the error-prone with statement that should be avoided. Its reserved word policy is too strict. The insertion of a semicolon is a huge mistake, for example when used as the symbol for a literal regular expression. These missteps have led directly to errors in programming and have called into question the overall design of the language. Fortunately, many of these problems can be mitigated with a good lint program.

 The overall design of this language is quite obvious. The strange thing is that the ECMAScript committee has not shown much interest in fixing existing problems, perhaps they are more interested in creating new ones.

 Poor Implementation

 Some early implementations of JavaScript had many bugs, which in turn had a very bad impact on the language itself. What's even worse is that these buggy implementations are embedded in buggy web browsers.

  Bad books

Almost all JavaScript books are pretty terrible. They contain errors, contain bad examples, and encourage bad practice. Some important features of the JavaScript language are either not explained clearly or not mentioned at all. I have read many JavaScript books, but I can only recommend one: JavaScript: The Definitive Guide (4th Edition) by David Flanagan. (Note to authors: If you write a good book, please send me a copy and I will proofread it for you.)

 Standards of “quasi-standards”

 The quality of the official language specifications published by ECMA is extremely poor. Not only difficult to read but extremely difficult to understand. It has contributed a lot to the "bad books" whose authors were unable to gain a deeper understanding of the language through this standard document. ECMA and TC39 should be very embarrassed about this.

 Amateurs

 Most people who use JavaScript are not programmers. They lack the training and training to write good programs. JavaScript is very expressive and they can do useful things with it anyway. This has given JavaScript a reputation as being more for amateurs than professional programmers. This is obviously a mistake.

 Object-oriented

 Is JavaScript object-oriented? It has objects, and its objects can contain data and methods for operating on the data. Objects can also contain other objects. It does not have classes, but it has constructors to do class things, including declaring class variables and methods. It does not have class-oriented inheritance, but it has prototype-oriented inheritance.

 The two main methods of building object systems are inheritance (is-a) and aggregation (has-a). JavaScript has both, but its dynamic nature allows for better implementations than aggregation.

Some arguments that JavaScript is not really object-oriented are based on the fact that it does not provide information hiding. In other words, a JavaScript object has no private variables or methods: all its members are public.

 But the fact is that JavaScript objects can have private variables and private methods (click here to see how to do this). Of course, the reason so few people know this is because JavaScript is the most misunderstood language in the world.

Another argument that JavaScript is not really object-oriented is that it does not provide inheritance. But the fact is that JavaScript not only supports classic inheritance, but also supports other code reuse patterns.

 Translation: Yuan Xiaohui Original link: http://www.crockford.com/javascript/javascript.html


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template