What’s New In Node.js 10 | Http2 | Modules |

What’s New In Node.js 10 | Http2 | Modules |

This blog is about NodeJs 10 and I would brief on what’s new the additions & improvements. Obviously, I’m not going through the extensive changelog or anything but I just want to mention the bigger things and you can find this information in various online sites, but I figured that I would just wrap it up into one blog and try to convey it in a simple way, but if you’re a JavaScript developer, I think it’s really important to keep up to date with these things. So, this will be a detailed blog relative to you know my regular blogs.

Node.Js 10 adopted standardized error codes

If you’ve worked with errors and debugging a node, it can be kind of a pain. Before we got some weird string based error messages that we’d have to constantly look up or sometimes guess what they mean but now with node 10, they actually adopted standardized error codes. So we have consistent codes with a repeatable pattern instead just a string with no identifiers and of course this will make debugging and error handling easier and it will remove a lot of the guessing and the searching you on Google looking up from Stack Overflow, ultimately making your applications easier to debug and offering faster development.

HTTP 2 was introduced in NodeJs 8, but it was known to be very buggy in version 10

source: Nodejsforum.de

We also have stable HTTP 2, so HTTP 2 is a higher performing successor to HTTP.  If you really haven’t looked into HTTP 2, it’s not a rewrite of the protocol or anything like that. All the HTTP methods, the status codes, all the semantics those are all the same and you should be able to use the same API is with HTTP 1.X, there will be few additions but everything should be backward compatible. Now HTTP 2 was introduced in node 8, but it was known to be very buggy in version 10.

It is now completely stable and safe to use. As far as frameworks go, the happy JS framework and the KOA framework fully support HTTP 2 right out of the box, as far as express though, at least at the moment for the last time I checked, you just need to use the Express HTTP to work around package, you would think Express would be the first to fully support it but apparently not. So ultimately, this should lead to you building faster API’s, the focus of HTTP 2 is performance, specifically end-user perceived latency and network and server resource usage, so I think having stable HTTP 2 is a pretty nice addition to version 10.

What’s new about Modules in NodeJs 10?

what is new in nodejs 10

Now let’s talk about modules, node offers better support for ESM or Xmas script modules for years. Node has used common-js modules and if you don’t know what that is, it’s we bring in our packages using like Const equals, require expressJs or require whatever module and the equi script modules or es6 modules is where we say import something from something.

For example, react angular and most front-end frameworks they use this syntax with web pack and babel, now understand that native Ecman script modules are not standardized yet and they’re not ready to be used by default in node 10. But they are getting closer and it’s a huge priority it’s just its apparently, it’s very difficult for them to kind of integrate along with the common j/s modules but for now, we can enable the experimental modules flag and any file where you want to use ESM or ECMA script modules.

Why it’s so hard to get native ESM into NodeJs

Whats new in NodeJS 10

You can you have to give it this .mjs extension. I’ll be very happy when we can actually just use es6 modules right out of the box, of course, you can implement like babel on your server side and use them, but it would be nice to not have to do that anymore and just have it right out of the box so that’s something that’s one thing I’m really excited to happen. Now there’s a really great medium article that kind of explains the status of this as well as why it’s so hard for them to get native ESM into nodejs, it’s from January which was before node 10 but it all still applies now. So all in all the support for ESM modules it’s getting better, we can use the experimental modules flag just use the .mjs extension I wouldn’t really suggest doing this in production but you know you can mess around with it and they’re getting closer.

NodeJs API completely independent from the JavaScript runtime, meaning, like v8

Whats new in NodeJS 10

Next, we have the API and this is the next generation of nodejs API for native modules. It is now completely independent from the JavaScript runtime, meaning, like v8 before it was tightly coupled with the runtime, now it’s actually maintained as part of nodejs so this opens up doors for engines like the new like Microsoft chakra which is another javascript engine and this is more for module developers and it allows them to write C and C++ add-ons without having a real deep understanding of the v8 engine itself.

Because now it provides better abstractions that are more true to node js in JavaScript, this is kind of beyond my scope of programming with nodejs writing add-on and so on. But apparently, this will make it not only easier but more stable before writing native modules every time. There was like a node update, developers would have to completely revise a lot of stuff due to its binding to 2 v8,  but now there are higher level abstractions that can make this much easier for them.

With TLS 1.3 we’ll have faster SSL handshakes and even better security

Whats new in NodeJS 10

As far as cryptography open SSL has been updated to version 1.1 so with TLS 1.3 we’ll have faster SSL handshakes and even better security. It’ll also include the chacha 20 cipher which is a high-speed cipher up to three times faster than a ES which is the advanced encryption standard and we’ll also get the poly 1305 Authenticator for authenticated encryption which I don’t really know too much about, but this stuff is going to make node more secure overall so if you’ve worked with node you’ve probably worked with the FS or the file system module which obviously allows you to interact with the file system.

Node 10 we have the experimental FS promises, meaning, that we can now use a synchronous file system methods that return a promise, and we can use this require FS / promises and we’ll get methods where we don’t need to use callbacks and it will make our code much cleaner, more readable especially if you use async await. Also for error handling, we don’t need to use try catch blocks because where it’s promise based we can now use dot catch.

Node.Js is powered by the v8 JavaScript engine

Whats new in NodeJS 10

So, for performance improvements, we should see quite a bit of improvement because as many of you know node is powered by the v8 JavaScript engine which is the same engine that chrome uses and with version 6.6 of v8 which is now included with node 10. We should get a pretty nice performance bump, chrome v6.6 uses the latest version as well and there’s been a 20 to 40 percent reduction in parsing and compiling JavaScript so we should see some nice improvements, it also offers a sync generator and array performance improvements and if all that sounds like gibberish just know that Nodejs’ is getting faster!


Leave a Reply

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