JavaScript

What is ECMAScript and how is it different from JavaScript

author image

Cloudaffle

Team

6th Jan, 2021   |   1053 Words   |   7 Min Read

What is ECMAScript?

There is a complete story on the history of JavaScript and how it came into existence. To cut a long story short, ECMA in ECMAScript refers to Europen Computer Manufacturers Association, to which JavaScript 1.1 was submitted for standardization back in the year 1997. A technical committee was created to standardize the syntax and semantics of a general-purpose, cross-platform, and vendor-neutral scripting language. The committee consisted of developers from Sun Microsystems, Netscape Communication, Microsft, and various other companies. They came up with ECMA-262, a standard defining a new scripting language and a general-purpose scripting language called the ECMAScript. All the browsers had to adhere to create their own implementations of JavaScript.

Many times developers use JavaScript and ECMAScript synonymously for each other. Though they are very closely linked to each other but do not mean the same thing.

ECMAScript Is Not Tied To Web Browsers

ECMAScript is a cross-platform, general-purpose scripting language and is not tied to web browsers alone. ECMA-262 defines the standards based on which more-robust scripting language may be built. ECMA-262 defines the following parts of the language and does not refer to web browsers at all

  • Syntax
  • Types
  • Statements
  • Keywords
  • Reserved Words
  • Operators
  • Global Objects

JavaScript implements ECMAScript into a more mature and robust scripting language with various input and output methods, which developers can, in turn, use to build various applications.

ECMAScript Conformance

So what does ECMAScript conformance means? When would a programming language be considered conforming to the ECMAScript based on the standards laid down in ECMA-262? You can see the latest ECMAScript Specification, but an implementation's conformance boils down to the following:

  • An implementation should support all the parts of the language as mentioned in the standard and highlighted above.
  • Support the Unicode character standard
  • A conforming implementation may add additional types, objects, functions, etc., which are not specified in the specification document.
  • Extend the built-in regular expression support.

There is a test suite for ECMA-262available on GitHub and used for testing the conformance to the standards.

## The JavaScript EngineA JavaScript engine can be referred to as a program or an interpreter which reads your JavaScript code and converts it into a machine-understandable code. Each web browser runs on a different engine, and the most common of them is Google's V8 Engine which is open source and is implemented by NodeJs. Here are a few common examples of various browsers and the JavaScript engines that they use:

Various Browsers Use Different Engines Here are some examples of various JavaScript engines used by well-known browsers.

  • Google Chrome - V8 Engine
  • Firefox - Spidermonkey
  • Microsoft Edge - Chakra now uses V8 Engine as well.
  • Safari - Nitro, also know as the JavaScriptCore.

The JavaScript Engine works as an interpreter and is sandwiched between the machine code and a JavaScript Runtime (also known as the JavaScript Host). Since now we understand the job of a JavaScript Engine, let’s dive deeper and try to grasp what JavaScript Runtime is.

JavaScript Runtime Or A JavaScript Host

A JavaScript runtime (Or a JavaScript Host) can be understood as a container that uses the JavaScript Engine to generate APIs that software developers can use to create JavaScript applications. Taking an example of a JavaScript runtime in a browser, it would typically contain the implementations of JavsScript, which are more specific to a browser. A runtime for something like NodeJs would have specific implementations that are more specific to running and building a server-side application using JavaScript.

JavaScript Runtime - The Secret Sauce For How NodeJS and Google Chrome Run On The Same V8 Engine

Since we now know what JavaScript Engine and JavaScript Host Environment (JavaScript Runtime) are, we are better positioned to understand how NodeJs and Google Chrome run on the same V8 Engine perform very different functionality. The secret is that they do have the same JavaScript engine but a very different JavaScript runtime. Let's compare the two JavaScript runtime environments.

What is JavaScript RuntimeIn a nutshell, a browser's runtime might have the following basic implementations which are useful for creating web applications:

  • The Core - The base implementation of JavaScript with all the input and output functions that the developers can use. -
  • Document Object Model (DOM) - This is what the browser renders as a hierarchy of nodes displayed to the client or the user for XML and HTML.
  • Browser Object Model (BOM) - This is what allows the developers to manipulate the browser window. Using the BOM, the developers can access the browser features and manipulate them outside the DOM context or the page that is being rendered.

On the other hand, a NodeJs runtime would have implementations that are useful for developing server-side applications. It contains the following implementations as an example:

  • Require
  • Buffers
  • Processes
  • etc

ES6, ES2015, or ES Harmony. What Do They Mean?

It's the sixth edition of ECMA-262, which was released in 2015, known as ES6, ES2015, and ES Harmony.

Essentially all these terms refer to the same edition of ECMA-262. Consequently, ECMA has been publishing a new edition of specifications every year, so the 7th edition came out in 2016.

The sixth edition of ECMA-262 brought in the most desirable and important collection of enhancements to ECMAScript. Hence, ES6 is considered to be a milestone and changes the way we have been using JavaScript. This is why ES6 is considered a major change and a new way of writing JavaScript. It brought formal support for classes, modules, iterators, generators, arrow functions, promises, reflection, and a host of new data types.

So Do Browsers Support Latest Standards Quickly?

The answer is No! The level of ES6 adoption has been inconsistent across all browsers. For example, Internet Explorer 11 only complies with the ES5 standards and not ES6, bringing in a lot of incompatibility and confusion around different browsers supporting different versions of ECMAScript Standards. There is a much elegant way of writing applications using JavaScript's most recent features and still complying with the legacy browsers. But more on that in future articles. \n Please spread some love by giving this article a thumbs up if you liked it. Keep me motivated. You can watch this space for the next article, or you can [subscribe to my Newsletter, and I would notify you as soon as the next article is published. Don't forget to leave a like or share the article if it was helpful!

What Are Your Thoughts About "What is ECMAScript and how is it different from JavaScript". Comment To Let Me Know.

I tried to cover all aspects of "What is ECMAScript and how is it different from JavaScript" and I would love to have a discussion and know your thoughts on the article. Feel free to post your feedback in the comments below and improve upon what we have over here. Happy Commenting 🙂 !