The time has come, a new stable version of Node.js is upon us! (We have also had a minor release since this article has been written).
Version 4 is special release for the Node community as it is the first stable release since the reunification of Node.js and io.js as the Node.js Foundation. This release contains all of the latest commits from both the Node.js project and the io.js project.
Versioning & Releases
With this new release comes a new versioning scheme, instead of odd numbers being unstable and even numbers being stable; The Node.js project now follows SemVer (also known as Semantic Versioning). With this we will see more frequent releases and easier upgrade paths.
With the addition of releases following SemVer, a Long-term Support (LTS) release plan has been proposed, thus allowing development to continue with breaking changes in versions > 5 (great for our developers), but with critical patches being applied to the LTS release (great for our customers)!
We have also been promised to have new stable releases being pushed out every 6 months, with weekly patches if needed. Using Node.js feels fresh again, with the added bonus of knowing that what you are using will be supported.
Ch-ch-changes!
With a new release come new additions to core. The most noticeable change is the addition of a plethora of ES2015 features, including:
Block scoped variables: let and const
Class based syntax*: class Mything { … }
Iterators and Generators*: function*() {…} yield*
Arrow Functions: x => return 1 * x
Collections: Map WeakMap Set WeakSet Weak* Collections store weak references to stored values so when a stored type is no longer in use, it will be garbaged collected.
Symbols: Symbol(‘YLD’) Typed Arrays: ArrayBuffer Binary and Octal literals: 0o101 0b1010 Promises: new Promise() Template Strings: This is a ${type}
(Node depends on Google’s V8 for its JavaScript engine, so new ES2015 features in node need to be supported by V8 first.) For a full feature list of ES6 features that are available right now you can head over to the https://nodejs.org/en/docs/es6/ site or look at the compat-table.
New from 0.12?
A lot has changed, but with JS applications it should be an easy transition. For a list of breaking changes check here or all API changes since 0.10 here.
The main additions that we believe are worthwhile of your time are:
Buffer: .writeUIntLE, .writeUIntBE, .writeIntLE, .writeIntBE, .readUIntLE, .readUIntBE, .readIntLE and .readIntBE
child_process: Synchronous Counterparts: .spawnSync, .execSync, and .execFileSync.
cluster: Round-robin load balancing.
crypto: Custom values, ECDH, passphrases on keys.
fs: Added .access, deprecated .exists
streams: addition of .cork, .uncork and implementers can now use _writev, we also have perf improvements with small writes.
v8: New module to interface with V8.
vm: Module has been re-written based on the module contextify.
Native Module Developer?
With a big change in versions of V8 from 3.26 to 4.5, a lot of native modules will break, or will already have broken. However, with the creation of the Node.js Foundation, NAN (Native Abstractions for Node.js) is now officially supported! NAN adds a layer on top of the V8 API so that maintainers of native module don’t have to constantly deal with API breakage as often. The more native modules use NAN, the easier it gets to upgrade V8.
Should I use v4?
Yes, absolutely! As developers, we love the latest and greatest. Not only do we get all of the new features above, we also get performance increases, reductions in memory usage and updated, cleaner API’s, but as all of this comes with supported LTS releases, we should all upgrade to Node 4. We all have at YLD.