What is the difference between JavaScript and ECMAScript?

Original author: Michael Aranda
  • Transfer
Translation What's the difference between JavaScript and ECMAScript?

Somehow we tried google "the difference between JavaScript and ECMAScript."

As a result, I had to wade through a sea of ​​ambiguous and seemingly contradictory results:

“ECMAScript is the standard.”
"JavaScript is the standard."
"ECMAScript is a specification."
“JavaScript is an implementation of the ECMAScript standard.”
"ECMAScript - Standardized JavaScript."
"ECMAScript is a language."
"JavaScript is a dialect of ECMAScript."
"ECMAScript is JavaScript."


Holding back the desire to cry, we tried to control ourselves and conducted a laborious but productive study.

This article presents our understanding of the differences between JavaScript and ECMAScript. This article is written for those who are familiar with JavaScript, but want a clearer picture of its relationship with ECMAScript, web browsers, Babel, and so on. You will also learn about scripting languages, JavaScript engines, and JavaScript runtimes.

Well, let's go.

JavaScript / ECMAScript Dictionary


The following is a list of definitions, with an emphasis on consistency and clarity. Definitions are not completely complete. They are built in such a way that you are well versed in the connections and kinship between JavaScript and ECMAScript.

Ecma international


An organization that creates standards for technology.


To illustrate an example of a “standard” (though not created in Ecma): think of all the keyboards you've ever used. In the vast majority of cases, the layout was the same? A space, Enter key, cursor keys? The numbers were in the top row? This is because most developers use the QWERTY layout standard when creating keyboard designs .

ECMA-262


This is a standard published by Ecma International. It contains a specification for a general-purpose scripting language.


ECMA-262 is a standard similar to QWERTY, only representing a specification of a scripting language called ECMAScript.

ECMA-262 can be considered an ECMAScript account number.


ECMA-260, ECMA-261, ECMA-262. And here is ECMAScript.

Scripting language


A programming language created to work with an existing object or system.

To understand how a programming language becomes a scripting language, consider the commands "walk", "run" and "jump". Someone must perform them, for example, a person, a dog or a video game character. Without an actor performing a command, all these “walk”, “run” and “jump” do not make sense. This set of actions is similar to the scripting language, which is designed to control an external object.

ECMAScript


The specification for creating a general-purpose scripting language described in ECMA-262.

Synonym : ECMAScript specification.


“ECMA-262” is the name of both the standard and the specification of the ECMAScript scripting language.

ECMAScript contains rules, information and recommendations that the scripting language must follow in order to be considered compatible with ECMAScript.


Excerpt from the ECMAScript 2017 language specification . The document is approximately 900 pages long if you are looking for something to read at your leisure.

Javascript


General-purpose scripting language that complies with the ECMAScript specification.

This is a dialect of ECMAScript.



JavaScript is my favorite programming language soaked in the aroma of coffee. ECMAScript is the specification on which it is based. You will learn how to create a scripting language from the ECMAScript specification , and how to use a scripting language from the JavaScript documentation . When people call JavaScript “a dialect of ECMAScript,” they mean the same thing as mentioning dialects of English, French, or Chinese. The dialect inherits most of its vocabulary and syntax from the parent language, from which it is noticeably different.



As stated in ECMA-262, JavaScript basically implements the ECMAScript specification, but with some differences. Mozilla broadly outlined the properties of JavaScript, not specific to ECMAScript:


Screenshot from 3 September 2017. This is a list of experimentally tested JavaScript features that are not part of ECMAScript (at least for now).

Javascript engine


A program or interpreter capable of understanding and executing JavaScript code.

Synonyms : JavaScript interpreter, JavaScript implementation.


JavaScript engines are commonly used in web browsers, including V8 in Chrome, SpiderMonkey in Firefox, and Chakra in Edge. Each engine is similar to a language module, which allows an application to support a specific subset of the JavaScript language.

For a browser, a JavaScript engine is like a person’s ability to understand speech. If we again turn to our example with “walk”, “run” and “jump”, then the JavaScript engine is part of the “object”, which actually understands what these actions mean.

This analogy helps explain some of the features of the browser:



Different browser performance


Two people will understand the “jump” command, but one of them will react earlier, because he was able to quickly understand and process the command. Similarly, two browsers can understand JavaScript code, but one of them works faster because its JavaScript engine is more efficient.



Different browser support


Consider a large group of English speakers. Someone among them may know certain words, expressions, and syntax rules that are not known to other people, and vice versa. Same thing with browsers. While all browser-based JavaScript engines understand JavaScript, some understand it better than others. There are different ways to support the language of browsers.

Speaking about support in browsers, they usually mention “ECMAScript compatibility” and not “JavaScript compatibility”, although JavaScript engines analyze and execute them in detail ... JavaScript. Sounds confusing, let me explain.


This is part of the ECMAScript browser support table . JavaScript versions are not mentioned in it.

As you may recall, ECMAScript is a specification of how it canlook like a scripting language. The appearance of a new version of ECMAScript does not mean that all JavaScript engines will have new features. It all depends on the groups or organizations that are responsible for updating JavaScript engines based on the latest ECMAScript specification.

Therefore, developers typically ask questions like “ Which version of ECMAScript does this browser support?” "Or" What features does ECMAScript support this browser? »They want to know whether Google, Mozilla and Microsoft have succeeded in endowing JavaScript engines ( V8 , SpiderMonkey and Chakra , respectively ) with the features described in the latest version of ECMAScript.

You will find answers to many questions in the ECMAScript Compatibility Chart..

If a new version of ECMAScript is released, then all the innovations will not appear in JavaScript engines at once. They will be introduced gradually, release by release, as can be seen in the example of the JavaScript change log in Firefox:


Some parts of the ES2015 and ES2017 standards were implemented in the SpiderMonkey JavaScript engine in the Firefox 50 browser. Other parts of ES2015 and ES2017 were implemented earlier. and this continued in subsequent versions.

JavaScript runtime


In this environment, JavaScript code is executed and interpreted by the JavaScript engine. The runtime provides host objects on which and with which JavaScript can work.

Synonyms : Host environment.


The JavaScript runtime is the “existing object or system” mentioned in the scripting language definition. The code passes through a JavaScript engine in which an object or system analyzes the code and parses its work, and then performs interpreted actions. The dog is walking, the person is running, the video game character is jumping (or destroying, as in the picture).

JavaScript scripts can access applications because they provide host objects in the runtime. On the client side, the JavaScript runtime will be a web browser in which host objects such as windows and HTML documents become available for manipulation. Have you ever worked with host objects as a window or a document? Such objects are not part of basic JavaScript. These are web APIs, objects provided by a browser acting as a JavaScript host environment.

On the server side, the JavaScript runtime is Node.js. Node.js provides server-related host objects such as the file system, processes, and requests.

Curiously, different JavaScript runtimes can use the same JavaScript engine. For example, V8 is an engine used in two completely different environments - Google Chrome and Node.js.

ECMAScript 6


This is the sixth edition of the ECMA-262 standard, which has made significant changes and improvements to the ECMAScript specification.

Synonyms : ES6, ES2015 and ECMAScript 2015.


Since 2015, Ecma International has switched to the annual ECMAScript releases, and this version of ECMAScript has been renamed from ES6 to ES2015. Ecma International began to name new versions of the ECMAScript specification in accordance with the year of release. That is, ES6 and ES2015 are one and the same.

Babel


A transporter that converts ES6 code to ES5 code.


In ES6, great new features are available to developers , but we must not forget about inter-browser compatibility. At the time of this writing, Edge and Internet Explorer do not support all of the features in the ES6 specification.

If desired, developers can use Babel to convert - translate - ES6 code into a functionally equivalent version using only ES5 features. All major browsers fully support ES5, so the transpiled code will work without any problems.

Something else


I hope you learned something new for yourself about JavaScript and ECMAScript. Before finishing, I would like to clarify something for novice web developers.

Chicken or egg


JavaScript was created in 1996. In 1997, Ecma International proposed standardizing JavaScript, and as a result, ECMAScript appeared. But since JavaScript complies with the ECMAScript specification, JavaScript is an example implementation of ECMAScript.

It turns out that ECMAScript is based on JavaScript, and JavaScript is based on ECMAScript.

Yes, it looks like a cinematic stamp, when time travelers become their own parents. Funny though a little weird.

We understand that everything said here amused you a little, but we hope that you have received food for thought. Let me take my leave.

Also popular now: