Deno (software)

Print Print
Reading time 11:40

Deno
Deno.svg
Original author(s)Ryan Dahl
Developer(s)The Deno Company[1] and contributors
Initial releaseMay 13, 2018; 3 years ago (2018-05-13)[2]
Stable release
1.10.2[3] Edit this on Wikidata / 17 May 2021; 27 days ago (17 May 2021)
Repositorygithub.com/denoland/deno
Written inTypeScript, JavaScript, Rust, C++(V8 bindings)
Operating systemLinux, macOS, Microsoft Windows
TypeRuntime environment
LicenseMIT License[4][5]
Websitedeno.land Edit this on Wikidata

Deno is a runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language. It was created by Ryan Dahl, original creator of Node.js, and is focused on productivity.[6] It was announced by Dahl in 2018 during his talk "10 Things I Regret About Node.js".[7] Deno explicitly takes on the role of both runtime and package manager within a single executable, rather than requiring a separate package-management program.[8][9]

History

Deno was announced on JSConf EU 2018 by Ryan Dahl in his talk "10 Things I Regret About Node.js".[7] In his talk, Dahl mentioned his regrets about the initial design decisions with Node.js, focusing on his choices of not using promises in API design, usage of the legacy build system GYP, node modules and package.json, leaving out file extensions, magical module resolution with index.js and breaking the sandboxed environment of V8.[10] He eventually presented the prototype of Deno, aiming to achieve system call bindings through message passing with serialization tools such as Protocol Buffers, and to provide command line flags for access control.

Deno was initially written in Go and used Protocol Buffers for serialization between privileged (Go, with system call access) and unprivileged (V8) sides.[11] However, Go was soon replaced with Rust due to concerns of double runtime and garbage collection pressure.[12]Tokio [Wikidata] was introduced in place of libuv as the asynchronous event-driven platform,[13] and FlatBuffers is adopted for faster, "zero-copy" serialization and deserialization[14] but later in August 2019, FlatBuffers were finally removed[15] after publishing benchmarks that measured a significant overhead of serialization in April 2019.[16]

A standard library, modeled after Go's standard library, was created in November 2018 to provide extensive tools and utilities, partially solving Node.js' dependency tree explosion problem.[17]

The official Deno 1.0 was released on May 13, 2020.[18]

On March 29, 2021, the Deno company was announced, with backing in millions of dollars from Shasta Ventures, Mozilla Corporation and a few others. It was established to further the development of Deno and provide a commercial offering to users.[1]

Overview

Deno aims to be a productive scripting environment for the modern programmer.[8] Similar to Node.js, Deno emphasizes event-driven architecture, providing a set of non-blocking core I/O utilities, along with their blocking versions. Deno could be used to create web servers, perform scientific computations, etc. Deno is open source software under the MIT License.[19]

Comparison with Node.js

Deno and Node.js are both runtimes built on Google's V8 JavaScript engine, the same engine used in Google Chrome. They both have internal event loops and provide command-line interfaces for running scripts and a wide range of system utilities.

Deno mainly deviates from Node.js in the following aspects:[8]

  1. Uses ES Module as the default module system, instead of CommonJS.
  2. Uses URLs for loading local or remote dependencies, similar to browsers.
  3. Includes a built-in package manager for resource fetching, thus no need for npm.
  4. Supports TypeScript out of the box, using a snapshotted TypeScript compiler with caching mechanisms.
  5. Aims for better compatibility with browsers with a wide range of Web APIs.
  6. Restricts file system and network access by default in order to run sandboxed code.
  7. Redesigns the API to utilize promises, ES6 and TypeScript features.
  8. Minimizes core API size, while providing a large standard library with no external dependencies.
  9. Uses message passing channels for invoking privileged system APIs and using bindings.

Releases

Version Latest patch release Release date Date of last patch release Description
Old version, no longer maintained: 0.1.0 Old version, no longer maintained: 0.1.12 2018-08-23 2018-11-12 Rust rewrite and V8 snapshot
Old version, no longer maintained: 0.2.0 Old version, no longer maintained: 0.2.11 2018-11-27 2019-02-08 Mildly usable
Old version, no longer maintained: 0.3.0 Old version, no longer maintained: 0.3.10 2019-02-18 2019-04-25 Instead of importing a "deno" module, there is now a global variable called "Deno"
Old version, no longer maintained: 0.4.0 Old version, no longer maintained: 0.4.0 2019-05-03 2019-05-03 -
Old version, no longer maintained: 0.5.0 Old version, no longer maintained: 0.5.0 2019-05-11 2019-05-11 -
Old version, no longer maintained: 0.6.0 Old version, no longer maintained: 0.6.0 2019-05-20 2019-05-20 -
Old version, no longer maintained: 0.7.0 Old version, no longer maintained: 0.7.0 2019-05-29 2019-05-29 -
Old version, no longer maintained: 0.8.0 Old version, no longer maintained: 0.8.0 2019-06-08 2019-06-08 -
Old version, no longer maintained: 0.9.0 Old version, no longer maintained: 0.9.0 2019-06-15 2019-06-15 -
Old version, no longer maintained: 0.10.0 Old version, no longer maintained: 0.10.0 2019-06-25 2019-06-25 -
Old version, no longer maintained: 0.11.0 Old version, no longer maintained: 0.11.0 2019-07-06 2019-07-06 -
Old version, no longer maintained: 0.12.0 Old version, no longer maintained: 0.12.0 2019-07-16 2019-07-16 -
Old version, no longer maintained: 0.13.0 Old version, no longer maintained: 0.13.0 2019-07-31 2019-07-31 -
Old version, no longer maintained: 0.14.0 Old version, no longer maintained: 0.14.0 2019-08-09 2019-08-09 -
Old version, no longer maintained: 0.15.0 Old version, no longer maintained: 0.15.0 2019-08-13 2019-08-13 -
Old version, no longer maintained: 0.16.0 Old version, no longer maintained: 0.16.0 2019-08-22 2019-08-22 -
Old version, no longer maintained: 0.17.0 Old version, no longer maintained: 0.17.0 2019-09-04 2019-09-04 -
Old version, no longer maintained: 0.18.0 Old version, no longer maintained: 0.18.0 2019-09-13 2019-09-13 -
Old version, no longer maintained: 0.19.0 Old version, no longer maintained: 0.19.0 2019-09-24 2019-09-24 -
Old version, no longer maintained: 0.20.0 Old version, no longer maintained: 0.20.0 2019-10-06 2019-10-06 -
Old version, no longer maintained: 0.21.0 Old version, no longer maintained: 0.21.0 2019-10-19 2019-10-19 -
Old version, no longer maintained: 0.22.0 Old version, no longer maintained: 0.22.0 2019-10-28 2019-10-28 -
Old version, no longer maintained: 0.23.0 Old version, no longer maintained: 0.23.0 2019-11-04 2019-11-04 -
Old version, no longer maintained: 0.24.0 Old version, no longer maintained: 0.24.0 2019-11-14 2019-11-14 -
Old version, no longer maintained: 0.25.0 Old version, no longer maintained: 0.25.0 2019-11-26 2019-11-26 -
Old version, no longer maintained: 0.26.0 Old version, no longer maintained: 0.26.0 2019-12-05 2019-12-05 -
Old version, no longer maintained: 0.27.0 Old version, no longer maintained: 0.27.0 2019-12-18 2019-12-18 -
Old version, no longer maintained: 0.28.0 Old version, no longer maintained: 0.28.1 2020-01-02 2020-01-03 -
Old version, no longer maintained: 0.29.0 Old version, no longer maintained: 0.29.0 2020-01-09 2020-01-09 -
Old version, no longer maintained: 0.30.0 Old version, no longer maintained: 0.30.0 2020-01-17 2020-01-17 -
Old version, no longer maintained: 0.31.0 Old version, no longer maintained: 0.31.0 2020-01-24 2020-01-24 -
Old version, no longer maintained: 0.32.0 Old version, no longer maintained: 0.32.0 2020-02-03 2020-02-03 -
Old version, no longer maintained: 0.33.0 Old version, no longer maintained: 0.33.0 2020-02-13 2020-02-13 -
Old version, no longer maintained: 0.34.0 Old version, no longer maintained: 0.34.0 2020-02-20 2020-02-20 -
Old version, no longer maintained: 0.35.0 Old version, no longer maintained: 0.35.0 2020-02-28 2020-02-28 -
Old version, no longer maintained: 0.36.0 Old version, no longer maintained: 0.36.0 2020-03-11 2020-03-11 -
Old version, no longer maintained: 0.37.0 Old version, no longer maintained: 0.37.1 2020-03-23 2020-03-23 -
Old version, no longer maintained: 0.38.0 Old version, no longer maintained: 0.38.0 2020-03-28 2020-03-28 -
Old version, no longer maintained: 0.39.0 Old version, no longer maintained: 0.39.0 2020-04-03 2020-04-03 -
Old version, no longer maintained: 0.40.0 Old version, no longer maintained: 0.40.0 2020-04-08 2020-04-08 -
Old version, no longer maintained: 0.41.0 Old version, no longer maintained: 0.41.0 2020-04-16 2020-04-16 -
Old version, no longer maintained: 0.42.0 Old version, no longer maintained: 0.42.0 2020-04-29 2020-04-29 -
Old version, no longer maintained: 1.0.0 Old version, no longer maintained: 1.0.5 2020-05-13 2020-06-03 -
Old version, no longer maintained: 1.1.0 Old version, no longer maintained: 1.1.3 2020-06-12 2020-07-03 -
Old version, no longer maintained: 1.2.0 Old version, no longer maintained: 1.2.3 2020-07-13 2020-08-08 -
Old version, no longer maintained: 1.3.0 Old version, no longer maintained: 1.3.3 2020-08-13 2020-09-04 -
Old version, no longer maintained: 1.4.0 Old version, no longer maintained: 1.4.6 2020-09-13 2020-10-10 -
Old version, no longer maintained: 1.5.0 Old version, no longer maintained: 1.5.4 2020-10-27 2020-11-23 Faster tree-shaking and bundling, refactored REPL
Old version, no longer maintained: 1.6.0 Old version, no longer maintained: 1.6.3 2020-12-08 2020-12-30 Compile standalone binaries via "deno compile", support TypeScript 4.1, experimental support for Mac ARM64
Old version, no longer maintained: 1.7.0 Old version, no longer maintained: 1.7.5 2021-02-05 2021-02-19 Cross compilation and 60% smaller binaries for deno compile, a DNS resolver API, support for data URLs in import statements and web workers
Old version, no longer maintained: 1.8.0 Old version, no longer maintained: 1.8.3 2021-03-02 2021-04-02 Experimental support for WebGPU API, built-in internationalization APIs enabled, support for fetching private modules, revamped coverage tooling, support for TypeScript 4.2
Old version, no longer maintained: 1.9.0 Old version, no longer maintained: 1.9.2 2021-04-13 2021-04-23 Native HTTP/2 web server, Faster calls into Rust with serde_v8, Blob URL support & improvements to fetch api, Import completions in the LSP, Interactive permission prompt
Current stable version: 1.10.0 Current stable version: 1.10.2 2021-05-11 2021-05-17 Improvements to the built in test runner, structured clone support in Web Workers, Web Storage API, support for remote import maps
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release

The table above was created using the official Releases page.[20]

Example

This runs a basic Deno script without any file system or network permissions (sandbox mode):

deno run main.ts

Explicit flags are required to enable permissions:

deno run --allow-read --allow-net main.ts

To inspect the dependency tree of the script, use the info subcommand:

deno info main.ts

A basic Hello, World! program in Deno looks just like it would in Node.js:

console.log("Hello, World!");

A global Deno namespace exposes APIs that are not available in the browser. A Unix cat program could be implemented as follows:

/* cat.ts */

/* Deno APIs are exposed through the `Deno` namespace. */
const { stdout, open, copy, args } = Deno;

// Top-level await is supported
for (let i = 0; i < args.length; i++) {
    const filename = args[i]; // Obtains command-line arguments.
    const file = await open(filename); // Opens the corresponding file for reading.
    await copy(file, stdout); // Performs a zero-copy asynchronous copy from `file` to `stdout`.
}

The Deno.copy function used above works much like Go's io.Copy, where stdout (standard output) is the destination Writer, and file is the source Reader. To run this program, we need to enable read permission to the filesystem:

deno run --allow-read cat.ts myfile

The following Deno script implements a basic HTTP server:

// Imports `serve` from the remote Deno standard library, using URL.
import { serve } from "https://deno.land/[email protected]/http/server.ts";

// `serve` function returns an asynchronous iterator, yielding a stream of requests
for await (const req of serve({ port: 8000 })) {
    req.respond({ body: "Hello, World!\n" });
}

When running this program, Deno will automatically download and cache the remote standard library files, and compile the code. Similarly, we can run a standard library script (such as a file server) directly without explicitly downloading, by providing the URL as the input filename (-A turns on all permissions):

$ deno run -A https://deno.land/std/http/file_server.ts
Download https://deno.land/std/http/file_server.ts
Compile https://deno.land/std/http/file_server.ts
...
HTTP server listening on http://0.0.0.0:4500/

References

  1. ^ a b Ryan Dahl, Bert Belder (2021-03-29). "Announcing the Deno Company".
  2. ^ "Contributors, denoland/deno, Github". Retrieved 5 July 2019.
  3. ^ "Release 1.10.2". 17 May 2021. Retrieved 21 May 2021.
  4. ^ "deno/LICENSE at main". GitHub. Retrieved 5 July 2019.
  5. ^ "The MIT License". Open Source Initiative. 17 September 2018. Retrieved 17 September 2018.
  6. ^ "Deno: Secure V8 TypeScript Runtime from Original Node.js Creator". InfoQ. Retrieved 2019-05-17.
  7. ^ a b JSConf (2018-06-06), 10 Things I Regret About Node.js - Ryan Dahl - JSConf EU 2018, retrieved 2019-05-17
  8. ^ a b c "Deno Manual". deno.land. Retrieved 2019-05-17.
  9. ^ Paul Krill (2018-06-21). "Ryan Dahl's Node.js regrets lead to Deno". InfoWorld.
  10. ^ Dahl, Ryan (2018-06-06). "Design mistakes in Node" (PDF). Github.
  11. ^ "denoland/deno, branch "golang"". Github.
  12. ^ "Suggestion: Look into porting to Rust and using Tokio". GitHub.
  13. ^ "Tokio - The asynchronous run-time for the Rust programming language". Tokio.rs.
  14. ^ "Protobuf seems like a lot of overhead for this use case?". Github.
  15. ^ "Remove flatbuffers". GitHub.
  16. ^ "Replace flatbuffers". GitHub.
  17. ^ "denoland/deno_std: deno standard modules". Github.
  18. ^ "Deno 1.0". deno.land. Retrieved 2020-05-14.
  19. ^ "Deno Is Ready for Production". InfoQ. Retrieved 2020-07-01.
  20. ^ "Releases". 2020-12-30. Retrieved 2021-01-14.

By: Wikipedia.org
Edited: 2021-06-18 12:37:03
Source: Wikipedia.org