Node.js version 8 - New Features and improvements

    Sep 8, 20176 min read13264 viewsUpdated:Nov 27, 2024
    Node.js version 8 - New Features and improvements

    Version 8 is the newest release of Node, and it’s packed with features. Popular by the code name Carbon, Node.js v8 was original to be released in late April but was delayed in favor of the release of Ignition and TurboFan for the V8 JavaScript Engine. Node 8 will use V8 5.8 with ABI compatible with V8 6.0. This will provide better performance, a stronger support contract with V8, and a smaller delta between Node 8 and 9 as indicated by the Node.js Collection. Node.js will go into Long Term Support (LTS) in October 2017 and will be maintained till December 31st, 2019.

    The new improvements and features of this release create the best workflow for Node.js developers to date. Highlighted updates and features include adding Node.js API for native module developers, Async_hooks, JS bindings for the inspector, zero-filling Buffers, util.promisify and more.


    "Those who need stability and have complex production environments (i.e. medium and large enterprises) should wait until Node.js 8 goes into LTS before upgrading it for production."


    Node JS features


    Now, we'll go through the most important features and improvements of the new Node.js 8 release.


    1. Async Hooks API:

    The Async Hooks (formerly known as AsyncWrap) API has got a notable upgrade to the latest version. This API allows you to get structural tracing information about the life of handle objects.

    The API emits events that inform the consumer about the life of all handle objects in Node.js. It tries to solve similar challenges as the continuation-local-storage npm package, just in the core.

    Formerly, a package called ‘co’ was used to utilize generators to write better asynchronous code to create a more readable control flow. Now, this control flow can be implemented without the need of a third-party library.


    2. The Advantage of Having N-API 

    This API will be Application Binary Interface (ABI) stable across versions of Node.js. It is intended to insulate Addons from changes in the underlying JavaScript engine and allow modules compiled for one version to run on later versions of Node.js without recompilation. The API is currently experimental. It is independent of the underlying JavaScript runtime (ex V8) and is maintained as part of Node.js itself.


    • util.promisify

               util.promisify() allows developers to wrap callback APIs to return Promises. The function works with little overhead and follows a standard API.


    • JS Bindings for the Inspector

               The new inspector core module enables developers to leverage the debug protocol used by the Chrome inspector in order to inspect currently running JavaScript code. 


    3. Buffer security improvements in Node 8

    There are two numbers, the first the zero filling Buffer and the second is a new Buffer. Both are added by default. However, earlier, the memory space was not initialized with zero because of which one had to face security issues as the Buffer instance had sensitive information.

    The upgrading of the new version has enabled people to secure their privacy. However, it is advisable for the Node.js 8 users to first be aware of the risks factor involved in function and only then use to avoid the leakage of secure information. Though, there is an also a problem that you have to take performance hits. But it is better to move on to buffer.allocUnsafe ().


    4. Upgrade V8 to 5.8: Preparing for TurboFan & Ingnition

    With Node.js Version 8, the underlying V8 JavaScript engine gets updated as well.

    The biggest change it brings to Node.js users is that it will make possible the introduction of TurboFan and Ignition in V8 5.9.Ignition is V8's interpreter, while TurboFan is the optimizing compiler.


    "The combined Ignition and TurboFan pipeline have been in development for almost 3½ years. It represents the culmination of the collective insight that the V8 team has gleaned from measuring real-world JavaScript performance and carefully considering the shortcomings of Full-code gen and Crankshaft. It is a foundation with which we will be able to continue to optimize the entirety of the JavaScript language for years to come."

    Currently (well, with V8 versions older than 5.6, so anything below Node.js version 8) this is how the V8 compilation pipeline looks


    pipeline view
    The biggest issue with this pipeline is that new language features must be implemented in different parts of the pipeline, adding a lot of extra development work.

     Simplified pipeline looks, without the FullCode Generator :

    pipeline view 2

    pipeline view 2Photo credit: Benedikt Meurer


    Other notable Addition in Node.js Version 8


    Buffer

    • Buffer methods now accept Uint8Array as input


    Child Process

    • Argument and kill signal validations have been improved
    • Methods accept Uint8Array as input


    Console

    • Error events emitted when using console methods are now suppressed


    Domains

    • Native Promise instances are now Domain aware


    Errors

    • Node has started assigning static error codes to errors generated


    File System

    • The utility class fs.SyncWriteStream has been deprecated
    • The deprecated fs.read() string interface has been removed


    HTTP

    • Improved support for userland implemented Agents
    • Outgoing Cookie headers are concatenated into a single string
    • The httpResponse.writeHeader() method has been deprecated
    • New methods for accessing HTTP headers have been added to OutgoingMessage


    Lib

    • The legacy linkedlist module has been removed.


    REPL

    • REPL magic mode has been removed


    Src

    • The —-debug command-line argument has been removed


    Stream

    • Stream now supports destroy()  and _destroy() APIs
    • Stream now supports the final() API


    TLS

    • The rejectUnauthorized option now defaults to true


    Util

    • Symbol keys are now displayed by default when using util.inspect()
    • toJSON errors will be thrown when formatting %j
    • Convert inspect.styles and inspect.colors to prototype-less objects


    Zlib

    • Support Uint8Array in Zlib convenience methods
    • Zlib errors now use RangeErrorand TypeError consistently


    URL:

    • The WHATWG URL implementation is now a fully-supports Node.js API


    Conclusion:-

    Node.js version 8 surprises us with a lot of interesting improvements, including the Async Hooks API which is hard to grasp with the current (but ever evolving) state of its documentation. Node.js is proud to associate with world renowned companies including Microsoft, Yahoo, Netflix, LinkedIn etc as its esteemed clients.

    Those were some of the best features that come with NodeJS latest version which will assist in fulfilling various Single Page Application Development  . Node.js just released it's latest update v8.1.1, and we will get back to you with more detailed explanations of these features soon.


    Also refer Comparison Between: AngularJS Vs Node JS 

    24

    Related articles

    This website uses cookies to analyze website traffic and optimize your website experience. By continuing, you agree to our use of cookies as described in our Privacy Policy.