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. It was announced by Dahl in 2018 during his talk "10 Things I Regret About 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.
History
Deno was announced on JSConf EU 2018 by Ryan Dahl in his talk "10 Things I Regret About Node.js". In his talk, Ryan 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. 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 and unprivileged sides. However, Go was soon replaced with Rust due to concerns of double runtime and garbage collection pressure. Tokio is introduced in place of libuv as the asynchronous event-driven platform, and Flatbuffers is adopted for faster, "zero-copy" serialization and deserialization but later in August 2019, FlatBuffers were finally removed after publishing benchmarks that measured a significant overhead of serialization in April 2019. 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. The official Deno 1.0 was released on May 13, 2020.
Overview
Deno aims to be a productive scripting environment for the modern programmer. Similar to Node.js, Deno emphasizes event-driven architecture, providing a set of non-blocking core IO 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.
Redesigns API to utilize Promises, ES6 and TypeScript features.
Minimizes core API size, while providing a large standard library with no external dependencies.
Using message passing channels for invoking privileged system APIs and using bindings.
Example
This runs a basic Deno script without any file system or network permissions : 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; A global Deno namespace exposes APIs that are not available in the browser. A Unixcat program could be implemented as follows: /* cat.ts */ /* Deno APIs are exposed through the `Deno` namespace. */ const = Deno; // Top-level await is supported for The Deno.copy function used above works much like Go's io.Copy, where stdout is the destination Writer, and file is the sourceReader. 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 from "https://deno.land/[email protected]/http/server.ts"; // `serve` function returns an asynchronous iterator, yielding a stream of requests for await ) 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 directly without explicitly downloading, by providing the URL as the input filename : $ 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/