Javascript and ECMAScript: The relationship between

1

Question

Have you ever tried google with the keyword “Difference between JavaScript and ECMAScript” ?
The result will be a sea of ​​definitions that will not be read for the first time because of their ambiguity and non-uniformity.

“ECMAScript is a standard.”

“JavaScript is a standard.”

“ECMAScript is a specification.”

“JavaScript is an implementation of the standard ECMAScript.”

“ECMAScript is standardized JavaScript.”

“ECMAScript is a language.”

“ECMAScript is JavaScript.”

In order for you to go after not falling into a state of panic, we will plunge into this mess to find the most reasonable and accurate explanation to no longer be confused when talking about ES6, ECMAScript 2015 or JavaScript too.

Object of the article

This article is for those of you who are familiar with JavaScript and want to understand most clearly the relationship between ECMAScript, web browser, Babel and a few other things. In addition, we will understand more about scripting languages ​​in general, JavaScript engine and JavaScript runtimes.

Okay, let’s get started! 👌👌

Key terms

ECMA International

ECMAScript
An organization that creates standards (standards) for technologies.

What is the standard? To understand this concept, think about the keyboard that you often use on your phone, laptop or PC. Although these types of keyboards vary from manufacturer to manufacturer, they still share a layout (the position of the letter keys, number keys, function keys, Enter are all on the same positions). That’s because keyboard manufacturers are following QWERTY layout standard .

Thus the standard can be interpreted as a text published by a reputable organization in a community and requires all related products to be born and then follow the rules of the this material.

ECMA-262

ECMA-262
This is a standard published by ECMA International, which contains specifications or regulations for scripting languages in general.

But why is the number 262?

Assuming you are in a fairly large organization, this organization writes a lot of standards for technology in general, every time an organization needs to write down a document, it creates a schedule, in that schedule each The task is organized to give it a code as an ID to distinguish, this case ECMA-262 is the ECMAScript document creation task code

Scripting language

Scripting language
A type of language designed to reuse already defined "entities or systems" from scratch.

This is like this, when you have a library already available functions such as “walk”, “run”, “jump”, these functions have the function of moving an object or moving a character in the game. However, these functions cannot be executed if there is no place to call them. At that time, the set of scripts invoking these functions is called scripting-language, which is a language that focuses on reusing libraries already in the system .

ECMAScript

Equivalent keyword: ECMAScript specification

ECMAScript And JavaScript

This specification defined in the ECMA-262 aims to create standards for Script languages ​​in general, which provides a set of rules, specifications, and guidelines that force scripting languages ​​to monitor and weigh. The prompt during the process is deployed if the authors of these languages ​​want to be recognized as compliant with the ECMAScript standard.

JavaScript

JavaScript Coding

This is a Script language that has been implemented based on the instructions in the ECMAScript documentation.

JavaScript is dialect of the ECMAScript language

A language is considered “dialect” of another language when it inherits most of its predecessor’s declarations and syntax but still has a few features enough to make it different. distinct from other languages.
JavaScript is a variant of the ECMAScript language.
Developers of Javascript have relied on ECMAScript standards to create, update and develop this language. So, we can come to the conclusion, if we read the specification in the ECMAScript document, we will know how to create a Script language. But if we read JavaScript documents, we will know how to use a script language.

A JavaScript engine

Similar keywords: JavaScript interpreter, JavaScript implementation.

JavaScript engine
A program that understands and executes code written in JavaScript.

JavaScript engines are often found in Web browsers such as V8 (Chrome), SpiderMonkey (Firefox), Chakra (Edge’s) . Each engine is similar to a language-module that corresponds to its application, allowing support for a subset of the JavaScript language.

Javascript performance on browsers

It is similar to the difference between people who speak and understand the same language (some people may know some new words, some expressions and some rules that others do not know and vice versa). ), so are browsers.

Although the browser JavaScript engines understand JavaScript, some browsers have a better understanding of JavaScript.

Regarding browser support, people often talk about ECMAScript compatibility, despite the JavaScript engines parsing and executing JavaScript rather than ECMAScript.
This paragraph may not sound very relevant, but there is a reasonable explanation for this:
ECMAScript is a specification that contains a series of requirements that require the publisher of the Script language to follow.

The release of a new version of ECMAScript does not mean that the entire JavaScript engines of existing software companies are required to have these new features . It depends on the groups or organizations responsible for the JavaScript engines that must be the latest version of the latest ECMAScript specifications. They do not update all new features at a time but only update gradually as planned

JavaScript runtime

The environment in which JavaScript code is run is interpreted by the JavaScript engine.

The runtime environment provides host-objects(host environments) , which are objects that JavaScript will control and manipulate on it. The JavaScript runtime itself is the “entity or system” mentioned in the above Scripting Language definition.

JavaScript Runtime Enviroment
The code is included in the JavaScript engine, the JavaScript engine analyzes these code sections to see what actions are defined in the JavaScript runtime and executes these actions.

Applications that want to support the JavaScript language must create “host objects” at runtime. Specifically:

  • With the client side:
    • JavaScript runtime: Web browser
    • Host objects: window, document, objects contain in them methods to control logic to display components in the browser
  • On the server side:
    • JavaScript runtime: Node.js
    • Host objects: system, processs, requests files in Node.js

Do you have each JavaScript code for Web applications for sure at least once using document or window . window and document not a default feature provided by JavaScript. They are just Web APIs provided by the browser and appear as JavaScript-host-environment . There is an interesting point:

Different JavaScript runtime can share a JavaScript engine.

For example, V8 is the JavaScript engine used on both Google Chrome and Node.js – These are two different environments.

ECMAScript 6

Similar keywords: ES6, ECMAScript 2015

ECMAScript 6

This is the 6th version of the ECMA-262 standard with major changes and an improvement of the ECMAScript specification text. The ECMAScript version changes from ES6 to ES2015 because in 2015, ECMA International decided to publish this document annually. Accordingly, the ECMAScript specification is based on the year in which they are published.

Babel

Transpiler (transforming + compiler) is a way to call tools that convert code from version A to version B for each language.

Babel is a transpiler that converts ES6 code to ES5 code.
Babel converts ES6 code to ES5 code

Babel is for developers who want to bring the latest ES6 features to their apps but still need to run these features on most browsers. Babel will help developers convert ES6 code to ES5, because ES5 version has been supported on almost all browsers.

Conclusion

Before posting, I want to share a little more information for young developers who don’t have much experience like me:

Chicken or egg story

JavaScript was created in 1996, then sent to the ECMA International organization in 1997 to write the ECMAScript text. Logically speaking, at this moment, JavaScript has just satisfied all of the written specifications of ECMAScript, as well as an example for the best implementation of this specification language.

Thus, ECMAScript is built based on JavaScript and JavaScript also built on ECMAScript ???

This is probably an explanation I feel satisfied with the question: ECMAScript, JavaScript, which is first?

Hopefully the information in this article helps you feel confident every time you talk about JavaScript or ECMAScript.

Source: https://techtalk.vn/moi-lien-he-giua-javascript-va-ecmascript.html

Share This:

Powered by FrontNet