Deno (
) is a
runtime for
JavaScript
JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior.
Web browsers have ...
,
TypeScript, and
WebAssembly that is based on the
V8 JavaScript engine and the
Rust programming language. Deno was co-created by
Ryan Dahl, the creator of
Node.js and Bert Belder.
Deno explicitly takes on the role of both runtime and
package manager
A package manager or package management system is a collection of software tools that automates the process of installing, upgrading, configuring, and removing computer programs for a computer in a consistent manner.
A package manager deals wi ...
within a single
executable
In computer science, executable code, an executable file, or an executable program, sometimes simply referred to as an executable or binary, causes a computer "to perform indicated tasks according to encoded instruction (computer science), in ...
, rather than requiring a separate
package-management program.
History
Deno was announced at JSConf EU 2018 by
Ryan Dahl in his talk "10 Things I Regret About Node.js".
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. 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
In physical security and information security, access control (AC) is the action of deciding whether a subject should be granted or denied access to an object (for example, a place or a resource). The act of ''accessing'' may mean consuming ...
.
Deno was initially written in
Go and used
Protocol Buffers for serialization between privileged (Go, with system call access) and unprivileged (V8) sides. However, Go was soon replaced with
Rust due to concerns of double runtime and
garbage collection pressure.
Tokio was introduced in place of
libuv as the asynchronous event-driven platform, and
FlatBuffers was adopted for faster, "zero-copy" serialization and deserialization but later in August 2019, FlatBuffers was 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.
Deno Deploy, inspired by
Cloudflare Workers, was released on June 23, 2021. Announced May 4, 2022 Beta 4 improved the dashboard and added billing functionality.
Deno Fresh 1.0 was announced June 28, 2022.
It features a new full stack web framework for Deno that by default sends zero JavaScript to the client. The framework has no build step which allows for an order of magnitude improvements in deployment times. Version 1.1 was released September 8, 2022.
Deno SaaSKit beta was announced April 4, 2023. It is an open-source, modern SaaS template built with Fresh and Deno.
Deno 2 was released October 9, 2024. It primarily brings Node.js compatibility improvements and removes deprecated features.
Overview
Deno aims to be a productive and secure
scripting environment for the modern programmer.
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 server
A web server is computer software and underlying Computer hardware, hardware that accepts requests via Hypertext Transfer Protocol, HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, co ...
s, perform scientific computations, etc. Deno is
open source software under the
MIT License
The MIT License is a permissive software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts very few restrictions on reuse and therefore has high license compatibility.
Unl ...
.
Comparison with Node.js
Deno and Node.js are both runtimes built on the
V8 JavaScript engine developed by the Chromium Project, the engine used for
Chromium and
Google Chrome web browsers. They both have internal
event loops and provide
command-line interface
A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
s for running scripts and a wide range of system utilities.
Deno mainly deviates from Node.js in the following aspects:
# Supports only ES Modules like browsers where Node.js supports both ES Modules and
CommonJS. CommonJS support in Deno is possible by using a compatibility layer.
# Supports
URLs for loading local or remote dependencies, similar to
browsers, and uses module specifiers like
npm:
and
node:
to import NPM or polyfill Node.JS modules. Node.js supports both URLs and modules.
# Does not require a package manager for resource fetching, thus no need for a registry like
npm.
# Supports TypeScript out of the box, using a snapshotted TypeScript
compiler
In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
or the swc compiler with caching mechanisms.
# Aims for better compatibility with browsers with a wide range of Web APIs.
# Restricts file system and network access by default in order to run sandboxed code.
# Supports a single API to utilize promises,
ES6 and TypeScript features whereas Node.js supports both promise and callback APIs.
# Minimizes core API size, while providing a large standard library with no external dependencies.
# Uses message passing channels for invoking privileged system APIs and using bindings.
Funding
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.
A year on, Deno announced a further $21 million in Series A funding led by
Sequoia Capital.
Examples
Global
Deno
namespaces expose APIs that are not available in the browser.
An implementation of the
Unix cat programsyntaxhighlight lang="typescript">
/**
* cat.ts
*/
for (const filename of Deno.args)
A simple
Web server
A web server is computer software and underlying Computer hardware, hardware that accepts requests via Hypertext Transfer Protocol, HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, co ...
syntaxhighlight lang="typescript">
Deno.serve((req) => new Response("hello world"));
Deno automatically downloads and caches the remote standard library files when the script is run, and then compiles the code.
Similarly, it 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
External links
*
{{JavaScript
2018 software
JavaScript programming tools
Package management systems
Run-time systems
Free software programmed in Rust
Free software programmed in JavaScript
Free software programmed in TypeScript
Software using the MIT license
Cross-platform free software
Free software for Linux
Free software for Windows
Free software for macOS