In association with heise online

11 March 2013, 17:15

Node.js 0.10 reworks streams in new stable version

  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

Node.js logo The new stable release of Node.js, Node 0.10, brings numerous enhancements to the asynchronous JavaScript framework; most notable of these is a complete new implementation of streams, the I/O component, dubbed streams2. Streams2 is designed to address a number of deficiencies in Node 0.8's implementation.

For example, if you asked Node 0.8 streams to .pause() they didn't, as the call was "advisory-only". Data events also came right away whether the application was ready for them or not and there was no way to only read a specific number of bytes (like a header) leaving the rest for later processing. The implementation complexities of streams also meant it was very difficult to implement your own 0.8 streams and manage to duplicate all the intricate steps of behaving like other streams. This was in part because there were no shared classes between stream implementations.

With streams2 in Node 0.10, everything is now built from the same set of base classes, which makes them behave more consistently, and they have been designed to be extended. As the developers were reimplementing the entire stream system, they also "bit the bullet" and set out to fix the issues around advisory pausing and data not-on-demand. The API is also available in Node 0.8 as readable-stream and packages are already making use of it, allowing them an easier migration to Node 0.10 as well. With a new streams implementation built for extension, it is likely that developers will see more interesting developments using and implementing them.

Other changes see the domain module, used for catching errors, move from "Experimental" to "Unstable" status and being given "more of a first class treatment internally", which suggests it may become the future standard in Node for error handling. Node's runtime has also been worked on, boosting most of the performance benchmarking; at the same time, the runtime characteristics of Node, like how process.nextTick() is handled and how garbage collection is run, have been tuned to be more consistent. For example, the garbage collection previously tried to balance idleness with memory usage, but the functionality could lead to cases of large amounts of time being spent collecting garbage; the developers say they "just ripped that feature out" and got more predictable and stable latency giving applications more reliable response times.

With 0.10 now available, the developers are moving their focus to 0.12 and sorting out the "mess" of a codebase that is Node's HTTP implementation by creating a clean split between client and server and improving the socket pooling behaviour, which is described as "confusing and weird". After 0.12, is released, then Node will move into the final furlong to 1.0.

Source code for Node 0.10 is available to downloadDirect download, as are installers and binaries for 32- and 64-bit Mac OS X, Linux, Solaris and Windows. Documentation, details of changes between 0.8 and 0.10's API and other release files are also available. Node.js is published under the MIT licence.

(djwm)

Print Version | Send by email | Permalink: http://h-online.com/-1820635
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit