Original author(s) | Ryan Dahl |
---|---|
Developer(s) | The Deno Company[1] and contributors |
Initial release | May 13, 2018[2] |
Stable release | 1.10.2[3]
/ 17 May 2021 |
Repository | github |
Written in | TypeScript, JavaScript, Rust, C++(V8 bindings) |
Operating system | Linux, macOS, Microsoft Windows |
Type | Runtime environment |
License | MIT License[4][5] |
Website | deno |
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]
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 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]
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]
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]
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 |
Legend: Old version Latest version Future release |
The table above was created using the official Releases page.[20]
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/
By: Wikipedia.org
Edited: 2021-06-18 12:37:03
Source: Wikipedia.org