JavaScript: The world's most misunderstood language
JavaScript, also called Mocha, LiveScript, JScript, ECMAScript, is one of the most popular programming languages in the world. Virtually everyone in the world has at least one JavaScript interpreter installed on their personal computer, and it is widely used. The reason JavaScript is so popular is because of the role it plays as a scripting language on the World Wide Web.
Name
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.
Lisp in C
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.
Language typing
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.
Changing (language design) goals
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.
Design errors
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).
Poor implementation
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.
Bad reference books
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.)
Unqualified standards
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.
Amateur
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.
Object-oriented
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

JavaScript is a programming language widely used in web development, while WebSocket is a network protocol used for real-time communication. Combining the powerful functions of the two, we can create an efficient real-time image processing system. This article will introduce how to implement this system using JavaScript and WebSocket, and provide specific code examples. First, we need to clarify the requirements and goals of the real-time image processing system. Suppose we have a camera device that can collect real-time image data
