Home > Article > Web Front-end > JavaScript: The world’s most misunderstood language
The hint of the prefix Java makes people always associate JavaScript with Java, thinking that JavaScript is a subset of Java or It is a version with worse functionality than Java. It seems that the name JavaScript is intended to cause confusion, and this confusion leads to subsequent misunderstandings. JavaScript is not interpreted as Java, Java is Java. JavaScript is a different programming language.
The syntax of JavaScript is similar to Java, just like Java is similar to C. However, JavaScript is not a subset of Java any more than Java is a subset of C. JavaScript performs better in applications than Java (Oak) was originally intended to do.
JavaScript was not developed at Sun Microsystems, the birthplace of Java, but at Netscape. It was originally called LiveScript, and the name didn't confuse people very much. The hint of the suffix
Script shows that JavaScript is not a real "programming language". As a scripting language, there is still a gap between it and a programming language. However, this is indeed a professional issue. Compared with the C language, JavaScript sacrifices performance in exchange for richer expressiveness and dynamics.
JavaScript's C-like syntax, including curly braces and bulky for statements, makes it look more like an ordinary Procedural language. This is misleading because JavaScript has more in common with functional languages such as Lisp and Scheme than with C or Java. It uses arrays instead of lists and objects instead of property lists. Functions are of the first type, and functions can have closures. You don't need to balance all those parentheses to use anonymous functions.
JavaScript was originally designed to run on Netscape Navigator. Its success has made it de facto standard in all web browsers. This results in the stereotyping of language types. It can be said that JavaScript is the George Reeves of programming languages. JavaScript is also suitable for many applications that have nothing to do with web pages.
The first version of JavaScript was quite weak. It lacks exception handling, intrinsic functions, inheritance. In its current form, it is a complete object-oriented programming language. However, many of the arguments against the language are based on its immature form.
The ECMA committee responsible for managing the language is developing extensions, which is well-intentioned, but it also exacerbates a larger problem: there are more and more versions. And this caused more confusion.
No programming language is perfect. JavaScript also has its own design errors, such as overloading to represent addition and string concatenation with type conversion. The error-prone with statement should also be avoided. The reserved word policy is too strict. The embedding of semicolons is also a huge mistake, as is the notation of regular expressions. These errors can lead to programming errors while calling into question the design of the language as a whole. Fortunately, many of these problems can be mitigated with a very good lint program.
The overall design of this language is quite sound. Surprisingly, the ECMAScript committee seems uninterested in correcting these errors. Perhaps, they are more interested in creating a new language. (Note: This should be a joke from the author).
Some early implementations of JavaScript were riddled with errors. This is reflected in the language. To make matters worse, these implementations were embedded into even more buggy web browsers.
Almost all books on JavaScript are pretty bad. They are full of mistakes, inappropriate examples, and unhelpful exercises. Important features in the language are poorly explained or ignored entirely. I have revised many books on JavaScript, but I only recommend one: "The Definitive Guide to JavaScript (Fifth Edition)" - Author: David Flanagan. (Author's note: If you write a good book, please send me a free copy.)
JavaScript official Specifications are published by ECMA. The quality of this official specification is quite low. And difficult to read and understand. This is a contributor to the problem of bad books, because authors cannot use standard documentation to improve their understanding of the language. ECMA and the TC39 committee should feel deeply embarrassed and disturbed by this.
Many people who use JavaScript are not programmers. They lack the professionalism and training to write good programs. Regardless, JavaScript is so expressive that they can do a lot of meaningful things using JavaScript. This has given JavaScript a reputation, that is to say, JavaScript is a language designed entirely for amateurs and is not suitable for professional programming. Actually, this is not the case.
Is JavaScript object-oriented? It has objects, and its objects can contain data and methods for processing the data. Objects can contain other objects. It does not have a class, but it has a constructor through which you can do class-like operations, including acting as a container for class variables and methods. It does not have class-oriented inheritance, but it does have prototype-oriented inheritance.
The two main ways to create an object system are through inheritance and through aggregation. JavaScript has both methods, but its dynamic nature makes it even better based on aggregation.
Some argue that JavaScript is not truly object-oriented because it does not support (provide) information hiding. That is, an object cannot have private variables or methods: all members are public.
But there is proof that objects in JavaScript can have private variables and private methods. (Note: In the original article, the author here is a link to the documentation on private variables and private methods of objects) Of course, few people understand this, because JavaScript is the most misunderstood programming language in the world. (Note: The author uses a lighthearted way of ridicule here).
Some argue that JavaScript is not truly object-oriented because it does not support inheritance. But this proves that JavaScript can not only support traditional inheritance but also apply other code reuse patterns. (Note: The original text is still a link here)
Copyright 2001 Douglas Crockford. Copyright Wrrrldwide.
[Recommended course: Javascript video tutorial]
The above is the detailed content of JavaScript: The world’s most misunderstood language. For more information, please follow other related articles on the PHP Chinese website!