What is Node.js?

By | September 28, 2021

Node.js is a platform for developing standalone JavaScript programs that run independently of host applications such as web browsers. It can be used to program server-side scripts, network tools and web apps, among other things.

Story and motivation

Originally, JavaScript was only designed as an integrated scripting language for web browsers and other applications. Under the catchphrase “JavaScript everywhere”, Node .js wants to standardize web development by also providing the language for server-side programming .

According to FUN-WIKI, Node.js was developed in 2009 by programmer Ryan Dahl. He was dissatisfied with the inefficient way that Apache and PHP based web applications handle many simultaneous connections. Ultimately, he decided to use JavaScript for server-side programming because he liked the language’s asynchronous event system. This enabled him to execute a large number of input / output functions in parallel and efficiently without complicated multi-threading architectures.

In 2012, Dahl handed over management to an employee so that he could turn to other projects. The OpenJS Foundation has been responsible for further development since 2019. It releases a new version every six months, usually in April and October. A version with long-term support appears once a year and is maintained for up to 30 months. Node.js is completely free open source software and is under the MIT license.

How Node.js works

Node.js is based on Google’s JavaScript engine V8, which is also used in the Chrome web browser. V8 is a process-based virtual machine that uses a JIT compiler to translate the JavaScript code at runtime into the machine language of the underlying hardware. Just-in-time compilers not only support many of the static optimizations of common ahead-of-time compilers. Because they translate the code while the program is running, they can optimize the code dynamically.

Unlike many server-side languages ​​such as PHP, Node.js uses “non-blocking I / O”. Programs do not have to wait for input / output functions to return. With the help of callback functions, they notify the calling function of their termination and thus enable asynchronous and parallel execution. This means that many simultaneous client requests can be processed more quickly and more smoothly.

Node.js can be expanded as required with modules. The Node Package Manager , or npm for short, can search for, install, remove, compile and update modules and their dependencies. In October 2020 there were already over a million packages in the Node.js repository. Modules cannot only be written in JavaScript. With the help of the N- API , binary packages can be programmed in C / C ++ and compatible languages. It is also possible to load external libraries (DLL, SO, DYLIB) via a Foreign Function Interface (FFI). In addition, Node.js supports WebAssembly modules.

Areas of application of Node.js

Although Node.js is mainly used for server programs and network tools, the platform is not limited to this. In addition to network-oriented command line tools, general tools for system administration are also possible. With the help of modules such as node-ncurses or drawille, full-screen terminal programs such as the vtop system monitor can be programmed.

Node.js can serve as a backend for web applications such as content management systems or forums, but also for web apps and desktop applications. Among other things, the Electron framework is based on the combination of Chromium and Node.js. Several popular desktop applications were developed with Electron. These include the code editors Atom and Visual Studio Code, Microsoft Teams as well as the Messenger Signal and Skype.

Classically structured desktop applications that do not follow the WebApp architecture are also possible with Node.js. The NodeGUI module can be used to program graphical interfaces based on the Qt5 GUI framework. There are packages such as nodegl and sdl2-link for games and 3D graphics.