⬆️ ⬇️

What is the difference between JavaScript and ECMAScript?

Translation Whats the difference between javascript and ecmascript?



Somehow we tried to google "the difference between javascript and ECMAScript".



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

')

"ECMAScript is a 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 an ECMAScript dialect."

"ECMAScript is JavaScript."





Restraining the desire to cry, we tried to get a hold of ourselves and conducted a laborious, but productive research.



This article presents our understanding of the differences between JavaScript and ECMAScript. The article is written for those who are familiar with JavaScript, but want to get 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, drove.



JavaScript / ECMAScript dictionary



Below is a list of definitions drawn up with an emphasis on consistency and clarity. Definitions are not entirely complete. They are designed in such a way that you understand the connections and affinity between JavaScript and ECMAScript.



Ecma international



An organization that creates standards for technology.





To illustrate an example of a “standard” (although not created in Ecma): think of all the keyboards you have ever used. In most cases, the layout was the same? And the spacebar, the Enter key, the cursor keys? The numbers were in the top row? This is explained by the fact that most developers use the QWERTY layout standard when creating a keyboard design.



ECMA-262



This is a standard issued by Ecma International. It contains the specification of 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 designed to work with an existing object or system.



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



ECMAScript



ECMA-262's general purpose scripting language specification.



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 must be followed by the scripting language in order to be considered compatible with ECMAScript.





An excerpt from the ECMAScript 2017 language specification . The document consists of about 900 pages, if you are looking for something to read at your leisure.



Javascript



A general purpose scripting language conforming to the ECMAScript specification.



This is an ECMAScript language dialect.







JavaScript is my favorite programming language, imbued with the aroma of coffee. ECMAScript is the specification on which it is based. From the ECMAScript specification, you will learn how to create a scripting language, and from the JavaScript documentation , how to use a scripting language.



When people call javascript “ECMAScript language dialect,” they mean the same thing when they mention English, French, or Chinese dialects. 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 outlined JavaScript features that are not specific to ECMAScript:





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



Javascript engine



A program or interpreter that can understand and execute 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 that 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 of “walk,” “run,” and “jump,” then the JavaScript engine is part of an “object,” which actually understands what these actions mean.



This analogy helps explain some features of the browser:







Different browsers 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 is faster because its JavaScript engine is more efficient.







Different browser support



Consider a large group of people who speak English. Someone among them may know certain words, expressions and syntactic rules that are not known to other people, and vice versa. The same with browsers. Although all browser-based JavaScript engines understand JavaScript, some understand it better than others. Different ways to support language browsers.



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





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



As you remember, ECMAScript is a specification of what a scripting language might look like. The appearance of a new version of ECMAScript does not mean that all JavaScript engines will have new functions. It all depends on the groups or organizations that are responsible for updating the JavaScript engines, taking into account the latest ECMAScript specification.



Therefore, developers usually 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 can find answers to many questions in the ECMAScript Compatibility Chart .



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





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



JavaScript runtime



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



Synonyms : Host environment.





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



JavaScript scripts can access applications because they provide “host objects” at 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 a host object in the form of a window or a document? Such objects are not part of basic javascript. These are web APIs, objects provided by the browser acting as the host JavaScript 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, making significant changes and improvements to the ECMAScript specification.



Synonyms : ES6, ES2015 and ECMAScript 2015.





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



Babel



A transporter that converts ES6 code to ES5 code.





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



If desired, developers can, with the help of Babel, transform - transpose - the ES6 code into a functionally equivalent version using only ES5 functions. 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 I finish, I would like to explain something to novice web developers.



Chicken or egg



JavaScript was created in 1996. In 1997, Ecma International proposed to standardize JavaScript, and as a result ECMAScript appeared. But since JavaScript conforms to 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 an overwhelmed cinematic stamp, when time travelers become their own parents. Funny, albeit a bit strange.



We understand that everything here said a little amused you, but we hope that you received some food for thought. Let me bow out.

Source: https://habr.com/ru/post/342904/



All Articles