Deno (software)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Deno
Deno.svg
Original author(s)Ryan Dahl
Developer(s)Various
Initial releaseMay 13, 2018; 2 years ago (2018-05-13)[1]
Stable release
1.8.0[2] Edit this on Wikidata / 2 March 2021; 3 days ago (2 March 2021)
Repositorygithub.com/denoland/deno
Written inTypeScript, JavaScript, Rust, C++(V8 bindings)
Operating systemLinux, macOS, Microsoft Windows
TypeRuntime environment
LicenseMIT License[3][4]
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.[5] It was announced by Dahl in 2018 during his talk "10 Things I Regret About Node.js".[6] Deno explicitly takes on the role of both runtime and package manager within a single executable, rather than requiring a separate package-management program.[7][8]

History[edit]

Deno was announced on JSConf EU 2018 by Ryan Dahl in his talk "10 Things I Regret About Node.js".[6] 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 GYP building system, node_modules and package.json, leaving out file extensions, magical module resolution with index.js and breaking the sandboxed environment of V8.[9] 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.[10] However, Go was soon replaced with Rust due to concerns of double runtime and garbage collection pressure.[11] Tokio is introduced in place of libuv as the asynchronous event-driven platform,[12] and FlatBuffers is adopted for faster, "zero-copy" serialization and deserialization[13] but later in August 2019, FlatBuffers were finally removed[14] after publishing benchmarks that measured a significant overhead of serialization in April 2019.[15]

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.[16]

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

Overview[edit]

Deno aims to be a productive scripting environment for the modern programmer.[7] 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.[18]

Comparison with Node.js[edit]

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:[7]

  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. Allows file system and network access in order to run sandboxed code.
  7. Redesigns API to utilize promises, ES6 and TypeScript features.
  8. Minimizes core API size, while providing a large standard library with no external dependencies.
  9. Using message passing channels for invoking privileged system APIs and using bindings.

Releases[edit]

Version Latest micro version Release date Date of last micro version 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
Current stable version: 1.8.0 Current stable version: 1.8.0 2021-03-02 2021-03-02 Experimental support for WebGPU API, built-in internationalization APIs enabled, support for fetching private modules, revamped coverage tooling, support for TypeScript 4.2
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release

Via the official Releases[19] page


Example[edit]

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/std@v0.21.0/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[edit]

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

External links[edit]