The server-side JavaScript platform Node.js 20.0 is now available.

Node.js 20.0 has been released, the platform for running network applications in JavaScript. Node.js 20.0 is classified under the long-term support branches, but this status will only be assigned in October after stabilization. Support for Node.js 20.x will continue until April 30, 2026. The previous LTS branch Node.js 18.x will be maintained until April 2025, and the one before that, 16.x, until September 2023. Support for the LTS branch 14.x will end on April 30, and for the interim branch Node.js 19.x on June 1.

Key Improvements:

  • The V8 engine has been updated to version 11.3, used in Chromium 113. Compared to the Node.js 19 branch, which used Chromium 107, the updates include the functions String.prototype.isWellFormed and toWellFormed, methods from Array.prototype and TypedArray.prototype for working with copies when modifying Array and TypedArray objects, the 'v' flag in RegExp, support for resizing ArrayBuffer and growing SharedArrayBuffer, and tail-call recursion in WebAssembly.
  • Предложен экспериментальный механизм Permission Model, позволяющий ограничить доступ к определённым ресурсам в процессе исполнения. Поддержка Permission Model включается через указание при запуске флага «—experimental-permission». В начальной реализации предложены опции для ограничения доступа на запись (—allow-fs-write) и чтение (—allow-fs-read) к определённым частям ФС, дочерним процессам (—allow-child-process), дополнениям (—no-addons) и потокам (—allow-worker). Например, чтобы разрешить запись в каталог /tmp и чтение файла /home/index.js можно указать: node —experimental-permission —allow-fs-write=/tmp/ —allow-fs-read=/home/index.js index.js

    For access checking, the method process.permission.has() is suggested, for example, 'process.permission.has('fs.write', '/tmp/test')'.

  • Handlers for external ECMAScript modules (ESM) loaded via the '--experimental-loader' option now execute in a separate thread, isolated from the main thread, thus preventing code overlap between applications and loaded ESM modules. Similar to browsers, the method import.meta.resolve() now operates synchronously when called from an application. Support for loading ESM is planned to be transitioned to stable features in one of the upcoming Node.js branches.
  • The module node:test (test_runner), designed for creating and running tests in JavaScript that return results in the TAP (Test Anything Protocol) format, has been moved to stable.
  • A separate development team has been formed to optimize performance, which has worked on speeding up various runtime components while preparing the new branch, including URL parsing, fetch(), and EventTarget. For example, the overhead for initializing EventTarget has been reduced by half, significantly improving the performance of the URL.canParse() method and enhancing timer efficiency. Additionally, a high-performance URL parser — Ada 2.0, written in C++, has been included.
  • The development of the experimental capability for deploying applications as a single executable file (SEA, Single Executable Applications) has continued. Creating the executable file now requires a blob substitution generated from a configuration file in JSON format (instead of substituting a JavaScript file).
  • Compatibility of the Web Crypto API with implementations from other projects has been improved.
  • Official support for Windows on ARM64 systems has been added.
  • Support for WASI (WebAssembly System Interface) extensions for creating isolated WebAssembly applications has continued. The need to specify a special command line flag to enable WASI support has been removed.

The Node.js platform can be used for both server-side support of web applications and for creating standard client and server network applications. A large collection of modules has been prepared to extend the functionality of Node.js applications, where modules with implementations can be found. servers and clients for HTTP, SMTP, XMPP, DNS, FTP, IMAP, POP3, modules for integration with various web frameworks, WebSocket and Ajax handlers, connectors to databases (MySQL, PostgreSQL, SQLite, MongoDB), templating engines, CSS engines, implementations of cryptographic algorithms and authorization systems (OAuth), XML parsers.

To handle a large number of parallel requests, Node.js utilizes an asynchronous code execution model based on event-driven non-blocking I/O and the definition of callback handlers. Multiplexing methods such as epoll, kqueue, /dev/poll, and select are supported for connection multiplexing. The libuv library is used for connection multiplexing, which is a wrapper around libev on Unix systems and IOCP on Windows. The libeio library is employed to create a thread pool, while c-ares is integrated for non-blocking DNS requests. All blocking system calls are executed within the thread pool, and like signal handlers, they pass their results back through an unnamed pipe. JavaScript code execution is ensured through the use of the V8 engine developed by Google (additionally, Microsoft develops a version of Node.js with the Chakra-Core engine).

Essentially, Node.js is similar to the Perl AnyEvent, Ruby Event Machine, Python Twisted frameworks, and the event handling implementation in Tcl, but the event loop in Node.js is abstracted away from the developer and resembles the event processing in a web application running in a browser. When developing applications for Node.js, it is crucial to consider the specifics of event-driven programming. For example, instead of executing "var result = db.query('select...');" and waiting for its completion before processing the results, Node.js employs asynchronous execution, meaning the code is transformed into "db.query('select...', function (result) {process result});" allowing control to pass immediately to the subsequent code, with the query results processed as data arrives.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster