2.2 Overall architecture

The architecture of Deno

Deno, much like its counterparts such as Node.js, Bun, Go, and Python, operates as a compact monolith, executing within a solitary process. This design choice is common among major runtime environments, with each process possessing sufficient multi-threading capabilities to efficiently handle tasks demanding substantial computational power. Notably, Go sets itself apart by offering robust support for green threads, enhancing its performance in certain scenarios.

Unlike some of its counterparts, Deno's foundation spans multiple programming languages. Its core components are built using Rust, Typescript, and Javascript. One intriguing aspect is that Deno's primary runtime, which was once predominantly scripted in Typescript, has undergone a transformation. It has been rewritten in pure Javascript, devoid of any ES modules. This evolution underscores Deno's adaptability and the dynamic nature of its development process.

Deno encompasses seven pivotal components that shoulder the brunt of its intricate operations. These components synergize to execute the diverse tasks demanded by Deno's runtime environment. Beyond these core components, the ecosystem is enriched by three pivotal third-party libraries. These external libraries wield immense importance within the Deno framework, playing a crucial role in enabling the execution of Javascript programs while maintaining an asynchronous paradigm across its internal mechanisms. This delicate balance of native components and third-party support cements Deno's capability to seamlessly run Javascript programs, all the while upholding its inherent asynchronous nature. Altogether, the Deno puzzle is composed of approximately 10 blocks, which can be categorized into seven core blocks and three third-party blocks. These blocks, when combined, form the essential building blocks of Deno's functionality and features.

Block diagram

Below is a block diagram illustrating the key building blocks constituting Deno. This diagram provides an overview of the main components developed by the Deno team. However, it's important to note that this diagram specifically focuses on Deno's native components and does not encompass any elements contributed by third-party sources.

Let's start by taking a quick glance at the key components that make up Deno. Don't worry, we'll delve into each of these components more comprehensively in the upcoming sections. This will give you a solid understanding of how Deno functions and the role each component plays in its overall framework.

Major components

CLI

Apart from the crucial third-party elements such as tokio and v8, most of Deno's functions that users interact with are built into the Command-Line Interface (CLI). The CLI functions as both an orchestrator and an executor, playing a central role in connecting various components together.

Runtime

This runtime encompasses Deno's runtime code scripted in Javascript, a substantial portion of fundamental ops at a lower level, an inspector facilitating debugging, metrics to gauge performance, alongside vital functionalities such as the main worker, web worker, and permissions control.

Ext

The ext component comprises compact, modular blocks that offer various web APIs.

Core

On one front, it collaborates with the Rust components of Deno, including the CLI and the runtime. On the flip side, the Core provides a range of services that can be readily accessed from the Deno runtime using JavaScript.

---While CLI acts as an orchestrator, the core provides some of the critical functionality to run TS/JS code and to support interworking between JS and Rust. The core implements important functionalities like v8 bindings, flags, modules, JsRuntime, zero, shared queue, etc. The purpose of the existence of core is to provide some of the low-level functionality.---

Graph

The graph component offers module graph services to the CLI component. The module graph essentially shows the relationships between different modules in a Deno project, outlining how they depend on one another.

NPM

The NPM component offers a range of APIs designed for interacting with NPM modules.

Cache

The cache component plays a crucial role in overseeing the module cache within Deno. These modules might originate from various sources, including the NPM (Node Package Manager) repository, as well as other locations.

Rusty_v8

This marks the final significant element within the Deno project, yet it remains absent from the diagram. The Rusty_v8 component plays a pivotal role by offering top-notch Rust bindings to V8's C++ API, serving as a bridge between the Rust programming language and V8's core functionalities.

Third party components

While Deno comprises several essential core components, it is unable to perform any task using crucial third-party components alone. In order to achieve its full functionality, Deno relies on these critical external components to complement its core features:

Tokio

Tokio plays a vital role as a third-party component, serving as the backbone of Deno. The seamless integration of Tokio is what enables Deno to achieve its full asynchronous potential. Think of Tokio as a powerful engine that drives Deno's async capabilities.

V8

JS programs cannot run without the presence of a V8 engine. V8 represents Google's open-source, high-performance engine designed for JavaScript and WebAssembly. It's crafted using the C++ programming language.

Typescript compiler

The TypeScript compiler stands as the concluding, significant third-party element within Deno (omitted from the diagram above). As highlighted previously, V8 exclusively processes JavaScript code. Deno accommodates both TypeScript (TS) and JavaScript (JS). Prior to presenting code to V8, Deno undertakes the task of transforming TypeScript into JavaScript.

--

That covered the general structure and provided a concise overview of the main parts found within Deno. Moving forward, in the upcoming section, we will delve into a comprehensive examination of each individual component, exploring their functions and characteristics in depth.

Last updated