Return to blog

Node.js 12 is coming!

hero image for Node.js 12 is coming!

Those are good times for Node.js Developers. In a few days, Node.js 12 (codenamed Erbium) will be going into LTS (Long Term Support) and will be maintained until April 2022. A lot of improvements and new features will be released with this version. It’s very important information because production applications should only use Active LTS or Maintenance LTS releases. I’m excited because we will be able to update our services to the latest version of Node.js.

Node.js 12 features

Engine V8 updated to version 7.4

The V8 engine that is the runtime for Node.js, has been updated to version 7.4 and includes performance tweaks and improvements. Notable improvements are faster JavaScript execution, better memory management and extended ECMAScript syntax support.

  • Async stack trace
  • Faster parsing of JavaScript
  • Faster calls with arguments mismatch
  • Faster async/await implementation

Improved Startup Performance

In Node 12 the startup time has been reduced by 30% for the main thread. Node 12 generates the code cache for built-in libraries before build time, allowing the main thread to use the code cache to start up the initial load of any built-in library written in JavaScript.

It means that your apps will load faster than ever before.

Experimental Diagnostic Reports

Node 12 offers the ability to diagnose issues in applications (crashes, slow performance, memory leaks, high CPU usage) by providing an experimental diagnostic report feature.

HTTP parser switched to LLHTTP

HTTP has updated its default parser to be LLHTTP. The current http_parser library used in Node has been difficult to maintain and improve upon, which is why LLHTTP was born. The LLHTTP is faster than http_parser by 156%, it’s written in fewer lines of code, and all performance optimizations are generated automatically, as opposed to http_parser’s hand-optimized code.

Heap Size Improvements

In the previous version, the JavaScript heap size was either 700MB (for 32bit) or 1400MB (for 64bit). With new changes, JS heap size will be configured based on available memory which will ensure it does not use more than the resources allowed. This is very useful when processing large data-sets. Still, it will be possible to set — max-old-space-size to use a different limit if the default is not appropriate for your application.

Private class fields

As Developers, we have always struggled to protect some data in our classes/functions from the outside, but In JavaScript, we could always somehow access almost everything. Node.js 12 ships with the new V8 engine and so we’ve got access to one awesome feature – private properties in the class. Private class field variables are only accessible within the class itself and they are not available outside. A private class field is declared by prepending a variable with the # symbol.

class User {
  #name = 'Test User';
  get name() {
    return this.#name;
  }
}
const user = new User();
user.name // Test User
user.#name // SyntaxError

If you try to access #name outside of the class, you will receive a syntax error.

TLS 1.3

In Node.js 12, TLS gets an upgrade to version 1.3 and it offers enhanced security and performance. TLS 1.3 is more secure, easier to configure, and quicker to negotiate sessions between applications than TLS 1.2. The protocol also got safer cypher options and modes while also improving the performance of requests by reducing the time required for the HTTPS handshake.

TLS 1.3 is now the default max protocol supported by Node.js. In addition, TLS 1.0 and 1.1 have been disabled by default, the crypto library has removed deprecated functions and support for RSA has been removed because of its history of bugs.

TLS 1.3 has been a huge update to the protocol and is actively being integrated across the web.

Other Notable Improvements

  • Worker Threads no longer require a flag
  • New compiler and platform minimums
  • The experimental version of support for ES6 modules
  • Assert validates required arguments and adjusts loose assertions
  • Buffer improvements to make it more stable and secureas

Conclusion

Big thanks to the Node team for providing us with improvements and features to Node.js and the overall JS ecosystem. If you would like to read more about the Node.js 12 release, you can check the complete list of features on GitHub and additional details on the official release article.

As a reliable software company we’re focused on delivering the best quality IT services. However, we’ve discovered that programming skills give us a very particular opportunity...

Reach Us

65-392 Zielona Góra, Poland

Botaniczna 70

© 2015-2024 Codetain. All rights reserved.

cnlogo