project release , offering a platform similar to Node.js for the isolated execution of applications in JavaScript and TypeScript, which can be used to run applications without being tied to a browser, for example, to create server-side handlers. Deno uses the JavaScript engine , which is also used in Node.js and browsers based on the Chromium project. The project's code is licensed under the MIT license. The project is developed by Ryan Dahl (), the creator of the JavaScript platform Node.js.
One of the main goals of creating a new runtime for JavaScript is to provide a more secure environment. To enhance security, the wrapper around the V8 engine is written in Rust, which helps avoid many vulnerabilities arising from low-level memory handling, such as accessing memory after it has been freed, dereferencing null pointers, and buffer overflows. A non-blocking platform is used for handling requests , also written in Rust. Tokio allows the creation of high-performance applications based on event-driven architecture, supporting multithreading and asynchronous network request handling.
Key Deno:
- Focusing on security in the default configuration. File access, network capabilities, and access to environment variables are blocked by default and require explicit enabling;
- Built-in support for TypeScript in addition to JavaScript;
- The runtime is provided as a single self-contained executable file (‘deno’). To run applications with Deno, it is sufficient to for its platform has a single executable file, about 10 MB in size, with no external dependencies and does not require any special installation in the system;
- When running a program, as well as for loading modules, addressable URL referencing can be used. For example, to run the program welcome.js, you can use the command “deno https://deno.land/std/examples/welcome.js”. Code from external sources is downloaded and cached on the local system but is never automatically updated (updating requires explicitly running the application with the flag “—reload”).
- Efficient handling of HTTP network requests in applications; the platform is designed for creating high-performance network applications.
- The ability to create universal web applications that can run both in Deno and in a regular web browser.
- In addition to runtime, the Deno platform also functions as a package manager and allows referencing modules via URL within the code. For example, to load a module, you can specify in the code "import * as log from 'https://deno.land/std/log/mod.ts'. Files loaded from external servers via URL are cached. Version binding of modules is defined through version numbers specified within the URL, for example, 'https://unpkg.com/liltest@0.0.5/dist/liltest.js';
- It includes a dependency inspection system (the 'deno info' command) and a code formatting utility (deno fmt).
- For application developers a set of standard modules that have undergone additional auditing and compatibility testing;
- All application scripts can be bundled into a single JavaScript file.
Differences from Node.js:
- Deno does not use the npm package manager
and does not rely on repositories; modules are addressed via URL or file path, and the modules can be hosted on any site; - Deno does not use 'package.json' to define modules;
- API differences, all asynchronous actions in Deno return promises;
- Deno requires explicit permission definitions for files, network access, and environment variables;
- All errors not equipped with handlers lead to the termination of application execution;
- In Deno, the ECMAScript module system is used, and require() is not supported.
Source: opennet.ru
