release , a platform for running network applications in JavaScript. Node.js 14.0 falls under the long-term support (LTS) branches, but this status will only be granted in October, after stabilization. Support for Node.js 14.0 will be until April 2023. Support for the previous LTS branch Node.js 12.0 will last until April 2022, and for the older LTS branch 10.0 until April 2021. Support for the intermediate branch 13.x will end in June this year.
Key :
- The capability for on-the-fly or event-driven generation of , which detail events helpful in diagnosing issues such as crashes, performance drops, memory leaks, high CPU load, unexpected error outputs, etc., has been stabilized.
- Experimental support for the API has been added, implementing the AsyncLocalStorage class, which can be used to create asynchronous state with callback and promise-based handlers. AsyncLocalStorage allows data to be stored throughout the processing of a web request, similar to Thread-Local Storage in other languages.
- The warning message about the experimental feature on loading has been removed. modules that can be imported and exported using import and export expressions. However, the ESM module implementation remains experimental.
- The V8 engine has been updated to version (, , ), which includes new performance optimizations and such innovations as the new logical nullish assignment operator '??' (returns the right operand if the left operand is NULL or undefined, and vice versa), the '?.' operator for checking the entire chain of properties or calls at once (e.g., 'db?.user?.name?.length' without prior checks), the Intl.DisplayName method for obtaining localized names, etc.
- A review of the Streams API has been conducted, aiming to enhance the consistency of the Streams interfaces and eliminate behavioral discrepancies in the core components of Node.js. For instance, the behavior of http.OutgoingMessage is aligned with stream.Writable, and net.Socket with stream.Duplex. The autoDestroy option is set to 'true' by default, implying that '_destroy' will be called after completion.
- Experimental support for the API (), providing programming interfaces for direct interaction with the operating system (POSIX API for file and socket operations, etc.).
- Increased requirements for compilers and platforms: macOS 10.13 (High Sierra), GCC 6, .
It should be noted that the Node.js platform can be used for both server-side support of web applications and for creating regular client and server network programs. A large , which includes modules for implementing HTTP, SMTP, XMPP, DNS, FTP, IMAP, POP3 servers and clients, modules for integration with various web frameworks, WebSocket and Ajax handlers, connectors to databases (MySQL, PostgreSQL, SQLite, MongoDB), template engines, CSS engines, implementations of cryptographic algorithms and authentication systems (OAuth), XML parsers.
To handle a large number of simultaneous requests, Node.js employs an asynchronous model for executing code, based on event-driven, non-blocking processing and the definition of callback handlers. Multiplexing of connections is supported through methods such as epoll, kqueue, /dev/poll, and select. The library used for multiplexing connections is , which is a layer built on top of in Unix systems and over IOCP in Windows. A thread pool is created using the library , and for performing DNS queries in a non-blocking manner, it integrates . All system calls that could block are executed within the thread pool and then, like signal handlers, pass their results back through an unnamed pipe. Execution of JavaScript code is facilitated by leveraging the engine developed by Google, (additionally, Microsoft is developing a Node.js variant with the Chakra-Core engine).
Essentially, Node.js is similar to frameworks like , , and event handling in Tcl, but the event loop in Node.js is abstracted away from the developer and resembles event handling in a web application running in a browser. When writing applications for Node.js, the specifics of event-driven programming must be considered; for instance, instead of writing 'var result = db.query('select..');' and waiting for it to complete before handling results, in Node.js, the principle of asynchronous execution is used, meaning the code transforms into 'db.query('select..', function (result) {handle result});', where control immediately passes to the next code, and the query result is processed as data arrives.
Source: opennet.ru
