Deno is a
runtime for
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
,
TypeScript
TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. It is designed for the development of large appl ...
, and
WebAssembly
WebAssembly (sometimes abbreviated Wasm) defines a portable binary-code format and a corresponding text format for executable programs as well as software interfaces for facilitating interactions between such programs and their host environmen ...
that is based on the
V8 JavaScript engine and the
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), ...
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
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 w ...
within a single
executable
In computing, 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 instructions", as opposed to a data fil ...
, rather than requiring a separate
package-management program.
History
Deno was announced o
JSConf EU 2018by
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
A promise is a transaction whereby a person makes a vow or the suggestion of a guarantee.
Promise(s) may also refer to:
Places
* Promise, Oregon
*Promise, South Dakota
*Promise City, Iowa
*Promise Land, Tennessee or Promise
Film and TV
* ''Pro ...
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
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data. The method involves an inte ...
, and to provide command line flags for
access control
In the fields of physical security and information security, access control (AC) is the selective restriction of access to a place or other resource, while access management describes the process. The act of ''accessing'' may mean consuming ...
.
Deno was initially written in
Go and used
Protocol Buffers
Protocol Buffers (Protobuf) is a free and open-source cross-platform data format used to serialize structured data. It is useful in developing programs to communicate with each other over a network or for storing data. The method involves an inte ...
for serialization between privileged (Go, with system call access) and unprivileged (V8) sides. However, Go was soon replaced with
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), ...
due to concerns of double runtime and
garbage collection pressure.
Tokio
Tokio may refer to:
* , the capital of Japan, used primarily in non-English-speaking countries
may also refer to:
Music
* Tokio (band), a Japanese pop/rock band
** ''Tokio'' (album), their debut album
* Tokio Hotel, a German rock band
* Toki ...
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
Cloudflare, Inc. is an American content delivery network and DDoS mitigation company, founded in 2009. It primarily acts as a reverse proxy between a website's visitor and the Cloudflare customer's hosting provider. Its headquarters are in San ...
Workers, was released on June 23, 2021. Announced May 4, 2022 Beta 4 improves the dashboard and adds billing functionality. General availability of Deno Deploy is eyed for the third quarter of 2022.
Deno Fresh 1.0 was announced June 28, 2022. It features a new full stack web framework for Deno that sends zero JavaScript to the client. The framework has no build step which allows for an order of magnitude improvements in deployments times. Version 1.1 was released September 8, 2022.
Overview
Deno aims to be a productive and secure
scripting
Script may refer to:
Writing systems
* Script, a distinctive writing system, based on a repertoire of specific elements or symbols, or that repertoire
* Script (styles of handwriting)
** Script typeface, a typeface with characteristics of handw ...
environment for the modern programmer.
Similar to Node.js, Deno emphasizes
event-driven architecture Event-driven architecture (EDA) is a software architecture paradigm promoting the production, detection, consumption of, and reaction to events.
Overview
An ''event'' can be defined as "a significant change in state". For example, when a consume ...
, 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 hardware that accepts requests via HTTP (the network protocol created to distribute web content) or its secure variant HTTPS. A user agent, commonly a web browser or web crawler, initi ...
s, perform scientific computations, etc. Deno is
open source software
Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. Op ...
under the
MIT License
The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology (MIT) in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license co ...
.
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
Google Chrome is a cross-platform web browser developed by Google. It was first released in 2008 for Microsoft Windows, built with free software components from Apple WebKit and Mozilla Firefox. Versions were later released for Linux, macO ...
. They both have internal
event loop In computer science, the event loop is a programming construct or design pattern that waits for and dispatches events or messages in a program. The event loop works by making a request to some internal or external "event provider" (that generally ...
s 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:
# 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 only
URL
A Uniform Resource Locator (URL), colloquially termed as a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifie ...
s for loading local or remote dependencies, similar to
browsers. 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 translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
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
Shasta Ventures is an early-stage venture capital investment firm located in Silicon Valley that invests in enterprise and technology consumer startups. It is located on Sand Hill Road in Menlo Park.
Funds
Shasta's second fund of US$250 milli ...
,
Mozilla Corporation
The Mozilla Corporation (stylized as moz://a) is a wholly owned subsidiary of the Mozilla Foundation that coordinates and integrates the development of Internet-related applications such as the Firefox web browser, by a global community of op ...
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
Sequoia Capital is an American venture capital firm. The firm is headquartered in Menlo Park, California, and specializes in seed stage, early stage, and growth stage investments in private companies across technology sectors. , Sequoia's total a ...
.
Releases Deno
The table above was created using the official Releases page.
Releases Deno Fresh
The table above was created using the official Releases page.
Examples
Run a 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 (similar to Node.js):
console.log("Hello, World!");
Global
Deno
namespaces expose APIs that are not available in the browser.
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
cat program could be implemented as follows:
/* cat.ts */
/* Deno APIs are exposed through the `Deno` namespace. */
const = Deno;
// Top-level await is supported
for (let i = 0; i < args.length; i++)
Note:
Deno.copy
function used above is similar to 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
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
:
deno run --allow-read cat.ts myfile
Deno script for a basic
HTTP server
An HTTP server is a computer (software) program (or even a software component included in an other program) that plays the role of a server in a client–server model by implementing the ''server part'' of the HTTP and/or HTTPS network proto ...
:
// 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 (const req of serve())
Deno automatically downloads and caches the remote standard library files when the script is run, and then compile the code.
Similarly, we can run a standard library script (such as a
file server
In computing, a file server (or fileserver) is a computer attached to a network that provides a location for shared disk access, i.e. storage of computer files (such as text, image, sound, video) that can be accessed by the workstations that are ab ...
) 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
*
Official Deno manual
{{JavaScript
2018 software
Free software
JavaScript programming tools
Package management systems
Run-time systems
Free software programmed in Rust