What are some questions about NodeJS interviews

Node 10, multi-threading, N-API and more: Anna Henningsen in an interview on Node.js

Node.js has broken the sound barrier of one billion downloads and is a central part of the JavaScript world. Anna Henningsen is part of the core team at Node.js and has now spoken to us in an interview about how Node has developed further, what the latest features can do and what she would like for the tool.

Developer: Node.js 10 has not yet reached all users. What do you think is the most important change in version 10?

Anna Henningsen: First of all - we don't expect that Node.js 10 has already reached everyone. Many users only decide to upgrade when a version goes into long-term support mode. This will be the case for Node.js 10 in October - but you should definitely test your code with Node.js 10 before! (The schedule for versions and LTS dates can be found on GitHub, by the way.)

In contrast to Node.js 8, there are many small changes rather than a few big changes that make up Node.js 10 - I think the new (still "experimental") multi-threading support is really the biggest novelty in Node.js 10 so far.

Developer: N-API, which is supposed to simplify the upgrade process, is also new. What exactly does this change and how far has the development of N-API for the current LTS versions progressed?

Henningsen: What N-API simplifies is mainly to write native add-ons for Node.js in a way that you don't have to recompile after every upgrade to a higher version. In the past it was the case that version upgrades - for example from Node.js 9.x to Node.js 10.x - changed the ABI and API, especially the API of the JavaScript engine (V8). Add-on developers had to adapt to it.

In comparison, N-API is a stable API; H. Unrestricted compatibility with future Node.js versions is made possible - it is sufficient to compile an add-on once, which can then be used across Node.js versions. Nevertheless, this means that add-ons first have to be rewritten for the N-API if they are currently using the old add-on APIs.

N-API is now marked as "stable", little is added and nothing is removed. In addition, all supported versions, from Node.js 6 onwards, are equipped with N-API support, so nothing stands in the way of use.

Developer: A big topic in the Node.js world this year was the introduction of a multi-threading option for Node, which you already mentioned. At first glance, this contradicts the basic idea behind Node. What is the idea behind this feature, why was it introduced?

Henningsen: The idea behind Node.js to operate I / O primarily asynchronously is of course retained. One problem with the one-thread model, however, is that CPU-intensive work holds up everything else, including the event loop. Worker threads aim precisely at this: CPU-intensive tasks that can be outsourced to other threads. The feature is not intended to outsource I / O to these threads - in the end, in the end, that would simply be less efficient than the Node.js event loop regulates itself.

Developer: How advanced is the implementation of multi-threading in Node.js now?

Henningsen: The implementation is currently in the "experimental" state and will probably remain in it for some time, that is, changes (including non-compatible ones, if necessary) can be made at any time. From a practical point of view, however, not much has changed since the original implementation - feedback is primarily sought.

Developer: How will things continue in this area, in which direction should the feature develop?

Henningsen: That is a little open. On the one hand, there will certainly be better integration with other changes and parts of Node.js (ES6 modules and native add-ons, for example). On the other hand, it is unclear how close we z. B. want to work on the WebWorker API of the browser - there are some similarities, but also some differences. E.g. Node.js unfortunately uses a different model for EventEmitter than web APIs do. So we have to see whether it is enough for us that a WebWorker API can be built on the existing (more flexible) API or not.

If there is feedback in this direction, one could also consider providing a built-in thread pool. At the moment, starting a worker also means starting a whole Node.js instance and V8 instance (albeit in the same process), so it usually doesn't make sense to start a worker per task - it will assumed that pooling makes the most sense, similar to B. the existing support for load balancing in the 'cluster' module provides.

Developer: What do you think personally, does Node.js need multi-threading?

Henningsen:Well, as the developer who implemented most of it - I'm already behind the feature. 🙂 As I said, it closes a gap in Node.js, namely parallelizable, CPU-intensive use cases. So in my opinion the feature should be there - whether you need it for an average web application is of course another question.

Developers: ES6 modules are another big topic for many developers. How is the implementation of modules in Node currently? In December 2017, the Technical Steering Committee reported that there was no consensus for a final implementation. Has anything changed in the meantime?

Henningsen:In principle, experimental support is also available for this, but there is still a lot of discussion, especially with regard to the details of the connections to the already existing module types (CommonJS, JSON, add-ons).

Developer: Node 11 and beyond: What features would you like for the future of Node?

Henningsen:At the moment, I tend to work a lot on things that happen in the background and that developers don't necessarily see much of directly. If I had one wish for Node.js "free", it would be that we would support real sandboxing at some point - after all, JS engines are written precisely for this purpose, and it's a bit of a shame that Node.js doesn't do it itself also supported.

Thank you for the interview!

Interview: Anna Henningsen

Over the past 2 years, Anna has become one of the most active developers in the Node.js core team with a lot of passion for the project and, above all, its community. She is currently working as a Node Core Maintainer for nearForm Ltd., and is approaching her Masters in Mathematics.