Server-side JavaScript Node.js 16.0 release

The release of Node.js 16.0, a framework for executing network applications in JavaScript, has taken place. Node.js 16.0 has been assigned to the long support branches, but this status will not be assigned until October, after stabilization. Support for Node.js 16.0 will continue until April 2023. Maintenance of the previous Node.js 14.0 LTS branch will last until April 2023, and the previous 12.0 LTS branch until April 2022. Maintenance of the 10.0 LTS branch will be discontinued in 10 days.

Main improvements:

  • The V8 engine has been updated to version 9.0 (Node.js 15 used release 8.6), which allowed Node.js 16 to implement features such as the β€œindices” property for regular expressions (includes an array with the start and end positions of match groups), the Atomics method .waitAsync (asynchronous version of Atomics.wait), support for the use of the await keyword in modules at the top level. Function calls have been accelerated when the number of arguments passed does not match the parameters defined in the function.
  • The Timers Promises API has been stabilized, providing an alternative set of timer functions that return Promise objects as output, eliminating the need for util.promisify(). import { setTimeout } from 'timers/promises'; async function run() { await setTimeout(5000); console.log('Hello, World!'); } run();
  • An experimental implementation of the Web Crypto API has been added, designed to perform basic cryptographic operations on the side of web applications, such as manipulating cryptographic hashes, generating and verifying digital signatures, encoding and decoding data using various encryption methods, and generating cryptographically strong random numbers. The API also provides functions for generating and managing keys.
  • N-API (API for add-on development) has been updated to version 8.
  • Migration to the new release of the NPM 7.10 package manager has been made.
  • The implementation of the AbortController class, which is based on the Web API AbortController and allows you to cancel signals in selected APIs based on Promise, has been stabilized.
  • Support for the third version of the Source Map format, which is used to map generated, processed, or packaged modules to the original source code, has been stabilized.
  • The buffer.atob(data) and buffer.btoa(data) methods have been added for compatibility with legacy Web APIs.
  • The formation of assemblies for new Apple devices equipped with the M1 ARM chip has begun.
  • On the Linux platform, the compiler version requirements have been raised to GCC 8.3.

Recall that the Node.js platform can be used both for server maintenance of Web applications and for creating ordinary client and server network programs. To expand the functionality of applications for Node.js, a large collection of modules has been prepared, in which you can find modules with the implementation of HTTP, SMTP, XMPP, DNS, FTP, IMAP, POP3 servers and clients, modules for integration with various web frameworks, WebSocket and Ajax handlers , DBMS connectors (MySQL, PostgreSQL, SQLite, MongoDB), templating engines, CSS engines, implementations of crypto algorithms and authorization systems (OAuth), XML parsers.

To ensure the processing of a large number of parallel requests, Node.js uses an asynchronous code execution model based on non-blocking event handling and the definition of callback handlers. Supported methods for multiplexing connections are epoll, kqueue, /dev/poll, and select. For connection multiplexing, the libuv library is used, which is an add-on for libev on Unix systems and IOCP on Windows. The libeio library is used to create a thread pool, and c-ares is integrated to perform DNS queries in non-blocking mode. All system calls that cause blocking are executed inside the thread pool and then, like signal handlers, transfer the result of their work back through an unnamed pipe (pipe). The execution of JavaScript code is provided through the use of the V8 engine developed by Google (in addition, Microsoft is developing a version of Node.js with the Chakra-Core engine).

At its core, Node.js is similar to the Perl AnyEvent, Ruby Event Machine, Python Twisted frameworks, and the Tcl event implementation, but the event loop in Node.js is hidden from the developer and resembles event handling in a web application running in browser. When writing applications for node.js, you need to consider the specifics of event-driven programming, for example, instead of doing "var result = db.query("select..");" with waiting for completion of work and subsequent processing of results, Node.js uses the principle of asynchronous execution, i.e. the code is transformed into "db.query("select..", function (result) {result processing});", in which control will instantly pass to further code, and the query result will be processed as data arrives.

In addition, it can be noted that Deno, founded by the creator of Node.js to develop the new generation platform Deno, received $4.9 million in investments. Deno is similar in purpose to Node.js, but it tries to address the conceptual mistakes made in the Node.js architecture and provide users with a more secure environment. It is noted that Deno's business solutions will be built on fully open products, and the Open Core model with the allocation of separate paid functionality is perceived as unacceptable for the Deno platform.

Source: opennet.ru

Add a comment