What’s new in Node.js 12?

Node.js has been a game-changing technology from its initial release in 2009. Basically, it allows developers to use JavaScript to run scripts on the server side producing dynamic web content before the page is sent to the user’s web browser. Subsequently, Node.js represents to a “JavaScript everywhere” paradigm, unifying web web application development around a single programming language, instead of requiring various languages for server-side and client side scripts. 

On April 23rd, 2019, Node.js 12 officially launched. What’s more, let’s get straight to the point, this isn’t only a regular old version update, this is a big overhaul with some significant upgrades, let us see the list of highlights.

New features of Node.js 12-

1. V8 Engine Updated to V8 7.4-

As usual a new version of the V8 JavaScript engine brings performance changes and upgrades to Node. It was initially running on V8 .7.2 (updated on Dec 18) and eventually upgrade to 7.6 in April which included outstanding upgrades with V8 7.4 are performance updates for faster javascript execution, better memory management, and broadened ECMAScript syntax support.

Major Features of V8 version 7.4 –

JIT-less V8-

Version 7.4 allows JavaScript execution without allocating executable memory at runtime it depends heavily on the ability to allocate and modify executable memory at runtime in its default configuration and creating executable memory at runtime is a part of what makes V8 fast.

WebAssembly Threads/ Atomics shipped-

WebAssembly Threads/Atomics are now enabled on non-Android operating systems which allows the use of different cores on a user’s machine via  WebAssembly, enabling new, computation-heavy use cases on the web.

Faster calls with arguments mismatch-

JavaScript engines must give an approach to get to the actual parameters. In V8 this is done by means of arguments adaption, which provides the actual parameters in case of under or over-application. In the most recent version, V8 now totally skips arguments adaption, reducing call overhead by up to 60%.

Check out More of the v8.7.4 New Features Below:

  • Improved native accessor performance
  • Parser performance
  • Bytecode flushing in memory
  • Bytecode dead basic block elimination
  • JavaScript language features include Private class fields
  • Hashbang grammar
  • V8API

2. ES6 Module Support-

The import/export syntax has become the most favorite module syntax for developers since its standardization in ES6, and the Node team has been working on it to enable natively. Generally all major browsers support ECMAScript modules by means of  -Types of import from ES modules files for phase 3 that will work with all built-in Node packages:

// default exports
import module from 'module'
// named exports
import { namedExport } from 'module'
// namespace exports
import * as module from 'module'

Phase 3 for ECAM Script Modules in Node 12 which correspond to a way to the stability of the modules and the plan is to remove the – experimental modules flag into LTS version.

3. Startup time improvements-

Node.js 11 reduces startup time of worker threads almost 60% by using built-in code cache support. Node 12 has built upon this idea to generate the code cache for built-in libraries in advance at build time, enabling the primary thread to utilize the code cache to start up the initial load of any built-in library written in JavaScript. The end result is another 30% speedup in startup time for the main thread, and your applications will load for users faster than ever before.

4. Native modules get easier in Node.js-

Stepping back from the low-level improvements, there’s some cool stuff additionally coming for developers and module makers inside the Node ecosystem. Making and building native modules for Node keeps on improving, with changes that include better support for native modules in combination with worker threads, as well as the version 4 release of the N-API, which makes it simpler to configure your very own threads for native  asynchronous functions. Summarized, this implies creators and maintainers of Node-specific modules have almost as simple a time keeping up these modules as pure JavaScript module creators. The increased complexity that came about because of maintainers expecting to rebuild the distributed binaries for each Node.js version they needed their modules to support is now largely abstracted away courtesy of the N-API.

5. Integrated heap dumps-

Another feature in this release around heaps, sure to accelerate the debugging procedure, is integrated heap dumps, which ships with Node.js 12, already built-in. Presently there’s no need to install new modules to examine memory issues- simply tell Node what kind of JSON-formatted diagnostic summary you need by means of the command line or an API call and parse through all of the information you can deal with.

6. Diagnostic reports on demand-

Changing the discussion to debugging, there’s a new experimental feature  in Node.js 12 enabling users to generate a report on demand or when certain trigger events occur. This kind of real-time reporting can help analyze issues in production including crashes, slow performance, memory leaks, high CPU utilization, unexpected errors, and so forth- the kind of stuff that typically takes hours if not days to debug, analyze and fix.

7. Properly configured default heap limits-

Presently, we should discuss some lower level upgrades. So far, the JavaScript heap size defaulted to the maximum heap sizes set by V8 for use with browsers, except if manually configured generally. With the release of Node.js 12, the JS heap size will be configured based on available memory, which ensures Node doesn’t attempt to utilize more memory than is available and terminate processes when its memory is exhausted. Say goodbye to out of memory errors- probably some of the time- when processing a lot of data. The old – max-old-space-size banner will still be available to set a different limit if needed, yet ideally, this feature will reduce the requirement for setting the flag.

Conclusion-

These are some amazing features in Node v 12 which will help the Node.js Development process and a few features like planning to include Python 3 support, improving startup performance, Core Promise API support, further work on standards, and another Streams API will arrive in the new node release.

You have seen these new features of Node.js V12. There might be few also. Node 12 can be the best choice due to these new features. If you are still confused about server-side development with Node.js, Connect with solace experts and develop the best software that will boost your business to the next level.