Node.js 16 release: best overview

On April 20, a new 16 version of Node.js was released. Among the main changes are the update of the JavaScript engine V8 to version 9.0, built-in binaries (binaries) for Apple Silicon and several APIs, but first things first.

A complete list of changes can be found here

Node.js 16 will replace Node.js 15 as the “current” release. This status will remain with him for the next 6 months. Then, in October 2021, Node.js 16 will transition to long-term support (LTS) status. Upon transition to LTS status, he will receive the codename ‘Gallium’.

Release details can be found in the repository “Node.js Release Working Group”… For now, let’s go through the best news.

Upgrading V8 to version 9.0

The V8 JavaScript engine update is a performance improvement, as well as providing Node.js support for the latest JavaScript features. By the way, Node.js 15 used V8 version 8.6.

The main changes to the engine include support for regexp match indices, as well as improved (faster) access to the “super” property.

A complete list of changes can be found here

Conformity indices

Matching IDs allow developers to get an array of subarrays containing the start and end positions (indexes) of capture groups in a regular expression when there is a match (or multiple matches). This array is available through the “indices” property of the match object. Note that the regular expression used to find matches must have the “/ d” flag.

const re = /(a)(b)/d // Регулярное выражение. Обратите внимание на наличие флага /d

const m = re.exec('ab') // Объект с совпадениями

console.log(m.indices[0]) // Первый подмассив — это полное совпадение

// [0, 2]

console.log(m.indices[1]) // Второй подмассив — первая группа захвата

// [0, 1]

console.log(m.indices[2]) // Третий подмассив — вторая группа захвата

// [1, 2]

Accessing the “super” property

Access to the super property has been improved through the use of a built-in cache system and optimized code generation in TurboFan (TurboFan is the compiler, Ignition is responsible for interpreting the code in V8). According to the V8 developers, the access speed to super has become almost the same as the access speed to a regular property.

Axis “Y” – the number of operations. Axis “X” – access to the usual property, access to the “super” property (before the update), access to the “super” property (after the update).

Stable Timers Promises API

Timers Promises API provides an alternative set of timers that return a “Promise” object, eliminating the need to use util.promisify ()

import { setTimeout } from 'timers/promises'

async function run() {

  const greet = await setTimeout(3000, 'Hi!')

  console.log(greet) // Hi!

}

run()

The Timers Promises API was introduced in Node.js 15 as an experimental feature. Now it has acquired the status of a stable interface.

Other new features

The nature of the release process is such that new features appear in the “current” release approximately every 2 weeks. For this reason, many of the features were available in Node.js 15, but are still relatively new to the runtime.

Among these possibilities are the following:

  • Experimental implementation of the standard Web Crypto API
  • npm 7 (v7.10.0)
  • Node-API version 8
  • Stable implementation of AbortController based on AbortController Web API
  • Stable implementation Source Maps v3 (NODE_OPTIONS = – enable-source-maps in terminal or {“enable-source-maps”: true} in .mocharc.json)
  • Implementations of atob (buffer.atob (data)) and btoa (buffer.btoa (data)) for legacy API compatibility (encoding / decoding data into Base64 format)

New minimum compiler and platform sets

Node.js provides built-in binaries for several different platforms. For each major release, the minimum set of instruments is evaluated and expanded as possible.

Node.js 16 will be the first release with embedded binaries for Apple silicon… While separate tarballs are provided for the Intel (darwin-x64) and ARM (darwin-arm64) architectures, the “installer” (.pkg) for macOS is a multi-architecture binary.

For Linux based platforms, the minimum level is Gcc to generate Node.js 16 is GCC 8.3.

Details on the supported tools and compilers can be found here

End of support

Node.js developers try to minimize the number of changes that can lead to disruptions in the ecosystem (meaning the work of Node.js libraries). To detect such changes, use GITGM (Canary in the Gold Mine)

However, some features have been deprecated. Some of the most important are access to process.bindings () for some kernel modules, such as process.binding (‘http_parser’) or process.binding (‘url’).

It should be noted that the new major release is the result of the efforts of a large number of people interested in improving and further developing Node.js (contributors and collaborators). Also, in order to prepare a new release for production, a lot of work is done Node.js Build Working Group


Our servers can be used for development with node.js.

Register using the link above or by clicking on the banner and get a 10% discount for the first month of renting a server of any configuration!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *