2.3 Deno core components
In the previous section, we went over the high-level architecture of Deno, listing all the important components, including the third-party ones. Now, let's go deep into Deno, excluding the third-party.
First, in the scope of this chapter or book, Deno core means the part of deno that excludes the third-party libraries. There is another core directory present in the Deno repository on GitHub, and that core is different. These two shouldn't be confused with each other.
Deno core is the one that takes the TS/JS program and runs it. Simple! Deno core takes care of providing the main program, sub-commands, inspector, linter, fetching files, resolving modules, standard library, etc. In other words, Deno core does everything that isn't covered by tokio or v8. Especially v8, which itself runs in a very good sandboxed environment. V8 can run JS code, very fast. But v8 relies on Deno to carry out various important work that is not part of ECMAscript like file, net, io, timers ops.
Again, it is important to note that this Deno core is different from the core directory present in the Deno source. In this context, Deno core means the main Deno program and its associated components (excluding third-party libraries like tokio, v8, rusty_v8, etc.).
Following illustration shows the major components present in Deno core:
In terms of programming language, Deno is heavy on the very popular Rust programming language. Rust is a multi-paradigm programming language designed for performance and safety, especially safe concurrency. Rust is syntactically similar to C++ but can guarantee memory safety by using a borrow checker to validate references.
Deno core is also heavy on rust, except RT and STD. RT is written in pure JS while STD is written in TS.
Let's briefly go over the components. We'll also do a deep dive in the next sections.
CLI is undoubtedly a big part of Deno, of course excluding the third-party v8 engine. As mentioned in the previous section, CLI acts both as an orchestrator and a service provider. CLI is the one that runs the main program of Deno and all the commands.
Runtime is Deno's runtime which consists of Deno's core functionality in pure JS, low-level ops in Rust, and workers.
Core provides important services to CLI like v8 bindings, flags, modules, JsRuntime, shared queue, etc. Core also provides services that can be invoked from both Rust and JS.
These contain the crates for some of the low-level ops like crypto, fetch, etc.
The Deno's standard library implemented in TS.
That was just a brief introduction on the core components. Let's take a deep dive into each of the components and find out what it does.