Server-side JavaScript Node.js 14.0 release

Took place Release Node.js 14.0, platforms for executing network applications in JavaScript. Node.js 14.0 belongs to the long support branches, but this status will be assigned only in October, after stabilization. Support for Node.js 14.0 will be be until April 2023. Maintenance of the previous Node.js 12.0 LTS branch will last until April 2022, and the previous 10.0 LTS branch until April 2021. Support for the 13.x staging branch will end in June of this year.

All improvements:

  • The ability to generate on the fly or when certain events occur has been stabilized diagnostic reports, which reflect events that help diagnose problems such as crashes, performance drops, memory leaks, high CPU load, unexpected error output, etc.
  • Added experimental API support Async Local Storage with an implementation of the AsyncLocalStorage class that can be used to create an asynchronous state with handlers based on callbacks and promises. AsyncLocalStorage allows you to store data while a web request is being processed, much like Thread-Local Storage in other languages.
  • Removed experimental feature warning on boot modules ECMAScript 6 connected and exported using the import and export statements. At the same time, the very implementation of ESM modules is still experimental.
  • V8 engine updated to version 8.1 (1, 2, 3), which introduces new performance optimizations and adds new features such as the new logical join operator "??" (returns the right operand if the left operand is NULL or undefined, and vice versa), the "?." for a one-time check of the entire chain of properties or calls (for example, "db?.user?.name?.length" without preliminary checks), the Intl.DisplayName method for obtaining localized names, etc.
  • The Streams API has been overhauled to improve the consistency of the Streams APIs and address differences in the behavior of Node.js core parts. For example, the behavior of http.OutgoingMessage is similar to stream.Writable, and net.Socket is similar to stream.Duplex. The autoDestroy option is set to "true" by default, meaning that "_destroy" will be called upon completion.
  • Added experimental API support WASI (WebAssembly System Interface) that provides programming interfaces for direct interaction with the operating system (POSIX API for working with files, sockets, etc.).
  • Increased requirements for minimum versions compilers and platforms: macOS 10.13 (High Sierra), GCC 6, Windows newer than 7/2008R2.

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 extend the functionality of applications for Node.js, a large collection of modules, 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, connectors to DBMS (MySQL, PostgreSQL, SQLite, MongoDB ), template 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. The library is used for multiplexing connections libuv, which is a superstructure over libev on Unix systems and over IOCP on Windows. The library is used to create a thread pool libeio, to perform DNS queries in non-blocking mode integrated c-ares. 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 an engine developed by Google V8 (Additionally, Microsoft is developing a Node.js variant with the Chakra-Core engine).

At its core, Node.js is similar to frameworks. Perl AnyEvent, Ruby Event Machine, Python Twisted ΠΈ Implementation of events in Tcl, but the event loop in Node.js is hidden from the developer and resembles event handling in a web application running in a 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. .

Source: opennet.ru

Add a comment