DEV Community

Cover image for Node 15 vs. Node 16
Nextlink Labs
Nextlink Labs

Posted on

Node 15 vs. Node 16

On April 20, 2021, OpenJS released the latest major version of Node.js, Node 16.

With this even-numbered release, we see a few changes to the V8 engine, support for the new Apple Silicon processors, and a stable Timers/Promises API. We can also expect to see long-term support for this version.

High Level Changes

"Even number" vs. "Odd number" releases

As an even-numbered release, we can expect to see Node 16 move to long-term support status, which guarantees that critical bugs will be fixed for a total of 30 months. Also, because Node 16 is an even-numbered release, Node 15 has officially become unsupported.

ONe of the quirks of Node worth remembering is that odd-numbered releases – those literally ending in an odd number -- will go End-of-Life as soon as the next Semantic Version release line ships. According to NodeSource, a blog covering all things Node, Semantic Versions, or SemVers as they are called, include:

  • Major Release: Major Releases are for incompatible API changes, from version to version. Major releases can also include changes that would normally be included as Minor or Patch releases.
  • Minor Release: Minor Releases include backward compatible functionality changes. Minor releases can also include changes that would normally be included as Patch releases.
  • Patch Release: Patch releases include non-breaking bug fixes and security patches.

Conversely though, even-numbered releases become Long-Term Support, which is say they will be supported and maintained by the Node.js project for an extended period of time.

From a support standpoint, it's worth understanding the implications which version of Node version you're business is running.

Node JS release schedule

timers/promises API

Starting with version 16.0, the timers/promises API officially moves from experimental to stable. This API simply gives gives a way to define a timer as a Promise object.

import { setTimeout } from 'timers/promises';

const main = async () => {
  console.log(new Date().toTimeString());
  await setTimeout(1000);
  console.log(new Date().toTimeString());
}

main();
Enter fullscreen mode Exit fullscreen mode

Running the following example correctly await's the Promise returned from setTimeout, and prints out the following:

16:45:41 GMT-0700 (Pacific Daylight Time)
16:45:42 GMT-0700 (Pacific Daylight Time)
Enter fullscreen mode Exit fullscreen mode

V8 Upgraded to V8 9.0

The V8 JavaScript engine is updated to V8 9.0, up from 8.6 in Node 15. With this upgrade comes some performance improvements, and the ECMAScript RegExp Match Indices, which provide the start and end indices of a string through a new .indices property on certain match objects.

const matchObj = /(Node) (16)/d.exec('Node 16');
Enter fullscreen mode Exit fullscreen mode

Given a match object defined above, we get the following when logging out matchObj.indices, outlining the start and end indices of each match.

[[0, 7], [0, 4], [5, 7], groups: undefined]
Enter fullscreen mode Exit fullscreen mode

Apple Silicon support

In order to support Apple's new Apple Silicon M1 chip, the macOS installer (.pkg) will be shipped as a multi-architecture binary. This means that Node 16 will work on the new M1 Macs.

Breaking Changes

None coming from Node 15.

Conclusion

Node 16 will be supported next 30 months, while simultaneously discontinuing support for Node 15 immediately. This makes this a "must" upgrade for those currently on Node 15, and definitely something to consider coming from Node 14 in order to stay on the current LTS version for the longest.

This post originally appeared this blog where we cover devops consulting services.

Top comments (0)