Blog

Home / Blog

ECMA, Mozilla, ECMAScript, and JavaScript

Billy Yann
Data Scientist
Deep learning and machine learning specialist, well-versed with experience in Cloud infrastructure, Block-chain technologies, and Big Data solutions.
July 10, 2022


Recently, ECMA (European Computers Manufacturers Association) launched a more permissive JavaScript License that allows forks, which align with W3C Software Licensing; covering both HTML and CSS. This license was proposed by Mozilla. ECMA has an ECMAScript or ES, which is a JavaScript Standard that ensures interoperability of all web pages across various web-browsers. The ECMAScript got standardized by ECMA International as per the document named ECMA-262. The ES gets commonly used to do client-side scripting on the World Wide Web. Moreover, it gets frequently used for writing Server Applications and Services utilizing Node.js.

According to Mozilla, ECMA introduced an alternative JavaScript License to be more permissive regarding derivative works. The ECMA now provides two licenses. Any of these can be adopted depending on the specific needs of a given technical committee as per the statement released by Mozilla. Here, ECMAScript gets licensed by ECMA whereas other Web Technologies like CSS and HTML get permissively-licensed by the World Wide Web Consortium (W3C).

ECMA (European Computers Manufacturers Association)

The available version of ECMAScript supported by modern browsers is ES5 which comes with ample support from ES6. Two other languages TypeScript and CoffeeScript provide syntactic sugar on top of ES5. It then gets trans-compiled into ES5-compliant JavaScript whereas ES6 tackles many of the core-language shortcomings of both TypeScript and CoffeeScript.

ECMA Classes

ECMA has categorized various elements or parameters into classes for ease of understanding. These include the following:

Arrow functions

The features involved in ES6 fundamentally change the way by which JavaScript applications get designed and architected. Although these functions do not change anything fundamentally, they provide two significant features: lexical scoping of this keyword, and minimal ceremony when defining anonymous functions.

Modules

The ECMAScript modules potentially change many JavaScript applications radically. These get structured, standardized, and optimized to facilitate best practices in modular applications. The ES6 modules showcase ways to load and manage dependencies via the new import and export keywords. The goals for ES6 modules include smooth interoperability with existing JS Module Systems, AMD, CommonJS, and Node.js. It also includes fast compilation, simplicity, usability, and compatibility with browser and non-browser environments.

Block Scoping

As scoping in JavaScript get confusing for developers working with C/C#/Java Background, ES5 is used where the variables are either globally or locally function-scoped. In ES6, the developers get to use the new let keyword that achieves block scoping splendidly.

Promises

The promises associated provide mechanisms by which results and errors get handled from asynchronous operations. These get accomplished using callbacks as well. However, promises provide improved readability through method chaining and succinct error handling procedures. The promises get currently used in many JavaScript Libraries and the pattern looks familiar to those programs written in multithreaded C# Code. ES6 standardizes and optimizes these promises while removing the external dependencies currently required to use these promises. These are a list of ES6 Promises: Promise.resolve(value), Promise.cast(Value), and Promise.race(iterable). Promise.resolve(Value) returns a Promise Object that gets resolved with an Open Value. If the value is a method, the returned promise follows it adopting its eventual state. Otherwise, the returned Promise gets fulfilled within the value. In the case of Promise.cast(Value), the cast returns the value, or else the value gets coerced to a Promise. Promise.race(iterable) returns the first promise in an iterable function ready to resolve. The current support available for ES6 is limited with a lot of ES6 spec in draft forms. It is wise to use TypeScript or CoffeeScript to work around the current limitations showcased by ES5.

The New ECMA license

As per the new protocol, the ECMA license seeks to align with the work of the World Wide Web. ECMA is unveiling a more permissive JavaScript License based on the W3C Document and Software License. It provides the legal framework that guarantees the proper development of internet infrastructure, which is independent of any organization. As per Mozilla, the default license of ECMA contains certain restrictions against creating derivative work. However, they do not reflect on the ways by which open-source work for something or anything as foundational as JavaScript.

The ECMA license helps in providing a definitive document and location for a particular set of work on a given standard as per the SOP. It gets done with the intention of preventive forking. For developers, Mozilla wants to make it easy by actively participating in web evolution. The initiative introduces an alternate source for all ECMA International Specifications. The latest version, ECMAScript 2022, got approved by ECMA in the previous weeks.

New features in ECMAScript 2022

As discussed, ECMA unveiled a more permissive JavaScript License, and the following are the new features that include top-level awaits, RegExp Match Indices, and new public & private class fields among others. The newest version, ES13 got launched on June 22, 2022, and it codified the latest batch of new features for JavaScript. With ES13, every technology specification becomes a milestone concerning real-world usage. The ECMAScript Specification responds to this by formalizing these new features, which in turn establish a new baseline for the continuous evolution of JavaScript and ECMAScript. The ES13 specifications illuminate certain new features, which gets discussed below:

Class Fields

An umbrella proposal that encompasses many factors that aid in improving the handling of JavaScript Classes. These classes include Class public & private instance fields, private instance methods & accessories, and Static Class Features.

Public and Private Instance Fields

Introducing to the Constructor was the previously standard approach that declared a member-field inside the Class Keywords. The newest ECMAScript specifications define the number of fields inline as part of the class-body. Various listings get done to define the public and private instance fields.

Listing 1

For example, Listing 1 defines a class song using the class Keyword, with the class containing two members that are title and artist. Here, the artist gets prefixed with a hash (#) symbol that makes it private. The constructor accesses this.#artist with hash (#) prefix to stop the program from over-writing the field with a public member. After these procedures, an instance gets defined that illuminates the song class through setting both public and private instance fields via the Constructor. The output of the fields then gets expressed via the console. Here, the point is that song1.artist is invisible to the outside world with undefined outputs. Private fields cannot be created in the Class later using assignments. Hence, overall this listing leads to the making of cleaner codes.

Listing 2

The hash (#) symbol used works as a prefix on various methods and accessors. This gets defined under listing 2 which deals with private instance methods and accessors.

Listing 3

Static Members

The Class field proposals introduce numbers as well that look and work in similar ways to how they do in Java. For instance, if a member has the static keyword modifier, it exists on the class instead of Object Instances. By adding a Static member, the field gets accessible via the class name, song.label. In ECMAScript, unlike Java, the JavaScript instances do not hold references to the shared static variable. Here, it is notable to have a Static Private Field with the Static #label; that is a Private Static Field.

Listing 4

RegExp Match Indices and Regex Group Indices

The RegExp match got upgraded to include more information about the matching groups. This particular information gets only included if the /d flag gets added to the regular expressions. It causes the Regex engine to include the start and end of all matching substrings. The flag helps with the indices property on the exec results, which contain a 2D Array. Here, the first dimension represents the match and the second dimension showcases the start and end of the match. In the case of the named groups, the indices have a member named groups. The first dimension here contains the name of the group. Code blocks 1,2,3, and 4 help in accessing the details of where groups get matched within a string.

Listing 5

Top-Level Await

The ECMAScript specifications include the ability to package various asynchronous modules. The Top-Level Await proposal showcase that when you import a module wrapped in await, the including module does not execute until all the awaits get fulfilled.

Listing 6

Ergonomic brand checks for private fields

The developers look for codes that are comfortable in the ergonomic private fields from within a class using the in Keyword.

Listing 7

It talks about Negative indexing with .at(), where the .at method gets a built-in indexable that support all negative indices.

Conclusion

Recently ECMA unveiled a more permissive JavaScript License as a way to improve the tools used by developers. It was unveiled through Mozilla on June 22, 2022. Herein, we looked into various benefits of using ECMAScript over JavaScript. The latest version ES13 complies with all requirements needed for developers to optimize the whole JavaScript License. Now ECMA provides two licenses to be more permissive and precise regarding derivative works. As discussed, ECMAScript gets licensed properly by ECMA, which helps all developers.