Submitted Successfully!
To reward your contribution, here is a gift for you: A free trial for our video production service.
Thank you for your contribution! You can also upload a video entry or images related to this topic.
Version Summary Created by Modification Content Size Created at Operation
1 handwiki -- 1546 2022-10-12 01:36:51

Video Upload Options

Do you have a full video?

Confirm

Are you sure to Delete?
Cite
If you have any further questions, please contact Encyclopedia Editorial Office.
HandWiki. Deno. Encyclopedia. Available online: https://encyclopedia.pub/entry/30057 (accessed on 10 August 2024).
HandWiki. Deno. Encyclopedia. Available at: https://encyclopedia.pub/entry/30057. Accessed August 10, 2024.
HandWiki. "Deno" Encyclopedia, https://encyclopedia.pub/entry/30057 (accessed August 10, 2024).
HandWiki. (2022, October 19). Deno. In Encyclopedia. https://encyclopedia.pub/entry/30057
HandWiki. "Deno." Encyclopedia. Web. 19 October, 2022.
Deno
Edit

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. Deno explicitly takes on the role of both runtime and package manager within a single executable, rather than requiring a separate package-management program.

webassembly node.js package-management

1. History

Deno was announced on JSConf EU 2018 by Ryan Dahl in his talk "10 Things I Regret About Node.js".[1] 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.[2] 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.[3] However, Go was soon replaced with Rust due to concerns of double runtime and garbage collection pressure.[4] Tokio was introduced in place of libuv as the asynchronous event-driven platform,[5] and FlatBuffers was adopted for faster, "zero-copy" serialization and deserialization[6] but later in August 2019, FlatBuffers was removed[7] after publishing benchmarks that measured a significant overhead of serialization in April 2019.[8]

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

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

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.[11] A year on, Deno announced a further $21 million in Series A funding led by Sequoia Capital.[12]

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

2. Overview

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

2.1. 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:[15]

  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.[17][18][19]
  2. Supports only URLs for loading local or remote dependencies, similar to browsers. Node.js supports both URLs [20] and modules.
  3. Does not require a package manager for resource fetching, thus no need for a registry like npm.[21]
  4. Supports TypeScript out of the box,[22] using a snapshotted TypeScript compiler or the swc compiler [23] 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.

3. Releases

Version Latest patch release Release date Date of last patch release Description
0.1.0 0.1.12 2018-08-23 2018-11-12 Rust rewrite and V8 snapshot
0.2.0 0.2.11 2018-11-27 2019-02-08 Mildly usable
0.3.0 0.3.10 2019-02-18 2019-04-25 Instead of importing a "deno" module, there is now a global variable called "Deno"
0.4.0 0.4.0 2019-05-03 2019-05-03 -
0.5.0 0.5.0 2019-05-11 2019-05-11 -
0.6.0 0.6.0 2019-05-20 2019-05-20 -
0.7.0 0.7.0 2019-05-29 2019-05-29 -
0.8.0 0.8.0 2019-06-08 2019-06-08 -
0.9.0 0.9.0 2019-06-15 2019-06-15 -
0.10.0 0.10.0 2019-06-25 2019-06-25 -
0.11.0 0.11.0 2019-07-06 2019-07-06 -
0.12.0 0.12.0 2019-07-16 2019-07-16 -
0.13.0 0.13.0 2019-07-31 2019-07-31 -
0.14.0 0.14.0 2019-08-09 2019-08-09 -
0.15.0 0.15.0 2019-08-13 2019-08-13 -
0.16.0 0.16.0 2019-08-22 2019-08-22 -
0.17.0 0.17.0 2019-09-04 2019-09-04 -
0.18.0 0.18.0 2019-09-13 2019-09-13 -
0.19.0 0.19.0 2019-09-24 2019-09-24 -
0.20.0 0.20.0 2019-10-06 2019-10-06 -
0.21.0 0.21.0 2019-10-19 2019-10-19 -
0.22.0 0.22.0 2019-10-28 2019-10-28 -
0.23.0 0.23.0 2019-11-04 2019-11-04 -
0.24.0 0.24.0 2019-11-14 2019-11-14 -
0.25.0 0.25.0 2019-11-26 2019-11-26 -
0.26.0 0.26.0 2019-12-05 2019-12-05 -
0.27.0 0.27.0 2019-12-18 2019-12-18 -
0.28.0 0.28.1 2020-01-02 2020-01-03 -
0.29.0 0.29.0 2020-01-09 2020-01-09 -
0.30.0 0.30.0 2020-01-17 2020-01-17 -
0.31.0 0.31.0 2020-01-24 2020-01-24 -
0.32.0 0.32.0 2020-02-03 2020-02-03 -
0.33.0 0.33.0 2020-02-13 2020-02-13 -
0.34.0 0.34.0 2020-02-20 2020-02-20 -
0.35.0 0.35.0 2020-02-28 2020-02-28 -
0.36.0 0.36.0 2020-03-11 2020-03-11 -
0.37.0 0.37.1 2020-03-23 2020-03-23 -
0.38.0 0.38.0 2020-03-28 2020-03-28 -
0.39.0 0.39.0 2020-04-03 2020-04-03 -
0.40.0 0.40.0 2020-04-08 2020-04-08 -
0.41.0 0.41.0 2020-04-16 2020-04-16 -
0.42.0 0.42.0 2020-04-29 2020-04-29 -
1.0.0 1.0.5 2020-05-13 2020-06-03 -
1.1.0 1.1.3 2020-06-12 2020-07-03 -
1.2.0 1.2.3 2020-07-13 2020-08-08 -
1.3.0 1.3.3 2020-08-13 2020-09-04 -
1.4.0 1.4.6 2020-09-13 2020-10-10 -
1.5.0 1.5.4 2020-10-27 2020-11-23 Faster tree-shaking and bundling, refactored REPL
1.6.0 1.6.3 2020-12-08 2020-12-30 Compile standalone binaries via "deno compile", support TypeScript 4.1, experimental support for Mac ARM64
1.7.0 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
1.8.0 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
1.9.0 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
1.10.0 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
1.11.0 1.11.3 2021-06-08 2021-06-29 Official docker images, more web crypto APIs added, BroadcastChannel, abortable fetch, deno lint stabilized
1.12.0 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
1.13.0 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
1.14.0 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
1.15.0 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
1.16.0 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
1.17.0 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
1.18.0 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
{{{2}}}

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

4. 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/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

  1. JSConf (2018-06-06), 10 Things I Regret About Node.js - Ryan Dahl - JSConf EU 2018, https://www.youtube.com/watch?v=M3BM9TB-8yA, retrieved 2019-05-17 
  2. Dahl, Ryan (2018-06-06). "Design mistakes in Node". https://github.com/denolib/awesome-deno/blob/main/resources/design-mistakes-in-node/design-mistakes-in-node.pdf. 
  3. "denoland/deno, branch "golang"". https://github.com/denoland/deno/tree/golang. 
  4. "Suggestion: Look into porting to Rust and using Tokio". https://github.com/denoland/deno/issues/205. 
  5. "Tokio - The asynchronous run-time for the Rust programming language.". https://tokio.rs/. 
  6. "Protobuf seems like a lot of overhead for this use case?". https://github.com/denoland/deno/issues/269. 
  7. "Remove flatbuffers". https://github.com/denoland/deno/pull/2818. 
  8. "Replace flatbuffers". https://github.com/denoland/deno/issues/2121. 
  9. "denoland/deno_std: deno standard modules". 3 March 2022. https://github.com/denoland/deno_std. 
  10. "Deno 1.0". https://deno.land/v1. 
  11. Ryan Dahl, Bert Belder (2021-03-29). "Announcing the Deno Company". https://deno.com/blog/the-deno-company. 
  12. "Deno raises $21M". https://deno.com/blog/series-a. 
  13. Dahl, Ryan (4 May 2022). "JavaScript Containers". https://tinyclouds.org/javascript_containers. 
  14. Krill, Paul (2021-06-24). "Deno Company unveils server-side JavaScript hosting service" (in en). https://www.infoworld.com/article/3622914/deno-company-unveils-server-side-javascript-hosting-service.html. 
  15. "Deno Manual". https://deno.land/manual. 
  16. "Deno Is Ready for Production" (in en). https://www.infoq.com/news/2020/06/deno-1-ready-production/. 
  17. "Modules: ECMAScript modules | Node.js v17.6.0 Documentation". https://nodejs.org/api/esm.html. 
  18. "Deno - A modern runtime for JavaScript and TypeScript". https://deno.land/manual. 
  19. https://deno.land/std/node/README.md
  20. "Modules: ECMAScript modules | Node.js v17.6.0 Documentation". https://nodejs.org/api/esm.html#https-and-http-imports. 
  21. "Deno - A modern runtime for JavaScript and TypeScript". https://deno.land/manual/examples/manage_dependencies. 
  22. "Deno.js in Production. Key Takeaways.". https://medium.com/@sdesalas/deno-js-in-production-main-takeaways-247a2fd2d198. 
  23. "Documentation". 3 March 2022. https://github.com/swc-project/swc. 
  24. "Releases". 2020-12-30. https://github.com/denoland/deno/blob/main/Releases.md. 
More
Information
Contributor MDPI registered users' name will be linked to their SciProfiles pages. To register with us, please refer to https://encyclopedia.pub/register :
View Times: 403
Entry Collection: HandWiki
Revision: 1 time (View History)
Update Date: 19 Oct 2022
1000/1000
Video Production Service