Deno (software)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Deno
Deno 2021.svg
Original author(s)Ryan Dahl
Developer(s)Deno Land Inc[1] and contributors
Initial releaseMay 13, 2018; 4 years ago (2018-05-13)[2]
Stable release
1.23.0[3] Edit this on Wikidata / 16 June 2022; 16 days ago (16 June 2022)
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, TypeScript, and WebAssembly that is based on the V8 JavaScript engine and the Rust programming language. Deno was co-created by Ryan Dahl, who also created 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".[9] 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 was introduced in place of libuv as the asynchronous event-driven platform,[13] and FlatBuffers was adopted for faster, "zero-copy" serialization and deserialization[14] but later in August 2019, FlatBuffers was 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, Deno Land Inc 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] A year on, Deno announced a further $21 million in Series A funding led by Sequoia Capital.[19]

Deno Deploy, inspired by Cloudflare Workers,[20] was released on June 23, 2021.[21]

Overview[edit]

Deno aims to be a productive and secure 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.[22]

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. Supports only ES Modules like browsers where Node.js supports both ES Modules and CommonJS. CommonJS support in Deno is possible using a compatibility layer.[23][24][25]
  2. Supports only URLs for loading local or remote dependencies, similar to browsers. Node.js supports both URLs [26] and modules.
  3. Does not require a package manager for resource fetching, thus no need for a registry like npm.[27]
  4. Supports TypeScript out of the box,[28] using a snapshotted TypeScript compiler or the swc compiler [29] 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. Supports a single API to utilize promises, ES6 and TypeScript features whereas Node.js supports both promise and callback APIs.
  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[edit]

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
Old version, no longer maintained: 1.10.0 Old version, no longer maintained: 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
Old version, no longer maintained: 1.11.0 Old version, no longer maintained: 1.11.3 2021-06-08 2021-06-29 Official docker images, more web crypto APIs added, BroadcastChannel, abortable fetch, deno lint stabilized
Old version, no longer maintained: 1.12.0 Old version, no longer maintained: 1.12.2 2021-07-13 2021-07-26 Support for generateKey, sign and verify web crypto APIs, native WebSocket server support, TypeScript support in REPL, support for MessagePort and MessageChannel
Old version, no longer maintained: 1.13.0 Old version, no longer maintained: 1.13.2 2021-08-10 2021-08-23 Native HTTP web server stabilization, support for self.structuredClone(), AbortSignal support, support for navigator.hardwareConcurrency API, experimental WebSocketStream API, FFI replaces native plugin system
Old version, no longer maintained: 1.14.0 Old version, no longer maintained: 1.14.3 2021-09-14 2021-10-04 URLPattern, file locking APIs, mutual TLS support in fetch, TypeScript 4.4, URL parsing and std/http performance improvements
Old version, no longer maintained: 1.15.0 Old version, no longer maintained: 1.15.3 2021-10-12 2021-10-25 New crypto APIs, deno uninstall subcommand, nested testing API, FFI improvements, new—compat flag for improved Node compatibility
Old version, no longer maintained: 1.16.0 Old version, no longer maintained: 1.16.4 2021-11-09 2021-12-03 Fetch support for file URLs, new unstable signal listener API, support for specifying a reason when aborting an AbortSignal, improvements to Web Streams API, findLast and findLastIndex array methods, Deno to npm package build tool
Old version, no longer maintained: 1.17.0 Old version, no longer maintained: 1.17.3 2021-12-16 2022-01-12 Import assertions and JSON modules, improvements to the Web Cryptography API, unref timers, unstable support for negotiating ALPN, TypeScript 4.5
Current stable version: 1.18.0 Current stable version: 1.18.0 2022-01-20 2022-01-20 Config file auto-discovery, completion of Web Cryptography API, stabilization of test steps API, FFI improvements, LSP improvements
Legend:
Old version
Older version, still maintained
Latest version
Latest preview version
Future release

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

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. ^ a b Ryan Dahl, Bert Belder (2021-03-29). "Announcing the Deno Company".
  2. ^ "Contributors, denoland/deno, Github". GitHub. Retrieved 5 July 2019.
  3. ^ https://github.com/denoland/deno/releases/tag/v1.23.0.
  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 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. ^ JSConf (2018-06-06), 10 Things I Regret About Node.js - Ryan Dahl - JSConf EU 2018, retrieved 2019-05-17
  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. 3 March 2022.
  18. ^ "Deno 1.0". deno.land. Retrieved 2020-05-14.
  19. ^ "Deno raises $21M". deno.com. Archived from the original on 22 June 2022.
  20. ^ Dahl, Ryan (4 May 2022). "JavaScript Containers". tinyclouds.org. Archived from the original on 4 May 2022.
  21. ^ Krill, Paul (2021-06-24). "Deno Company unveils server-side JavaScript hosting service". InfoWorld. Archived from the original on 27 Jun 2022. Retrieved 2022-04-14.
  22. ^ "Deno Is Ready for Production". InfoQ. Retrieved 2020-07-01.
  23. ^ "Modules: ECMAScript modules | Node.js v17.6.0 Documentation".
  24. ^ "Deno - A modern runtime for JavaScript and TypeScript".
  25. ^ https://deno.land/std/node/README.md
  26. ^ "Modules: ECMAScript modules | Node.js v17.6.0 Documentation".
  27. ^ "Deno - A modern runtime for JavaScript and TypeScript".
  28. ^ "Deno.js in Production. Key Takeaways". Medium.com. Retrieved 16 May 2022.
  29. ^ "Documentation". GitHub. 3 March 2022.
  30. ^ "Releases". GitHub. 2020-12-30. Retrieved 2021-01-14.

External links[edit]