An Introduction to Deno for Node.js Developers

Rate this content
Bookmark

Deno and Node.js have a lot in common. They are both non-browser JavaScript runtimes built on the V8 engine. Deno and Node.js are also different in a lot of ways: TypeScript, CommonJS, package management, permission systems, tooling, native addons, browser compatibility. This talk will compare and contrast the two runtimes, focusing on what experienced Node.js developers need to know in order to succeed with Deno.

FAQ

Deno is a JavaScript runtime built on the V8 engine, similar to Node.js, but it incorporates several key differences. It is written in Rust, offers built-in utilities like a linter and formatter, and is designed to be secure by default with a comprehensive permission system. Unlike Node.js, Deno does not use NPM or 'node_modules' but uses imports from URLs.

Yes, Deno has a compatibility mode for running Node.js code. By using the '--compat' flag and potentially the '--unstable' flag, developers can utilize Node.js features like 'require' in Deno.

Deno Deploy is a globally distributed JavaScript VM that allows you to run JavaScript programs at the edge. It is designed for cloud deployment, supporting 32 edge locations with plans for expansion. Deno Deploy is currently in public beta and can deploy code globally in under 10 seconds.

Deno does not have a traditional package manager like NPM. Instead, it imports modules directly via URLs and caches them locally. Deno can also bundle all dependencies locally using the 'deno vendor' command for production environments. For third-party modules, Deno uses its own hosting service at deno.land/x.

Both Deno and Node.js are JavaScript runtimes built on Google's V8 JavaScript engine, used for building server-side applications. Both environments support TypeScript and are used for similar types of projects.

Deno is designed to be secure by default. It operates in a sandbox environment where no file, network, or environment access is allowed without explicit permission. Deno requires specific flags to grant script access to different system resources, enhancing security and preventing unauthorized actions.

In Deno, modules are imported directly from URLs and are cached locally. There is no central package.json file; instead, each module can be versioned independently by specifying version numbers in the import URL. Deno also supports the use of a 'deno.json' configuration file for more complex dependency management.

Yes, Deno has first-class support for TypeScript. The runtime includes a built-in TypeScript compiler, and there is no need for additional tooling or configuration to use TypeScript with Deno.

Colin Ihrig
Colin Ihrig
22 min
20 Jun, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk provides an introduction to Deno for Node.js developers, highlighting the differences in architecture and dependencies between the two runtimes. It discusses the Deno CLI and integrated toolchain, the Deno standard library and dependency management, as well as the Deno runtime and its core features. The Talk also covers Deno's permission system, its focus on web platform compatibility, and its support for TypeScript. Overall, it provides a comprehensive overview of Deno and its advantages over Node.js.

1. Introduction to Deno for Node.js Developers

Short description:

I'm going to be talking about getting started with deno if you are a node.js developer. I've been using node for about 10 years and just recently started working at deno. Node.js has been around significantly longer since around 2009, and then deno came out around 10 years after that. The interesting thing about node.js is that it predates a lot of what we consider to be modern JavaScript. Dno has taken a different approach, where it's much more batteries included. It has an integrated tool chain and a number of other things. Node.js has a huge ecosystem with a lot of legacy code. Having a huge ecosystem is nice, but having to support so much legacy code can actually slow down a lot of progress and actually kind of hinder Node's ability to have standards compliance.

Hi, everybody. Thanks for coming to my talk. I'm going to be talking about getting started with deno if you are a node.js developer. So a little bit of personal background on myself. I've been using node for about 10 years and just recently started working at deno. So it's been, you know, a learning experience trying to switch between these two environments. So I was hoping that this talk could help somebody else who was in my shoes with moving over to deno.

A little bit of background on both run times. They're both JavaScript run times. They're both built on the V8 engine. Node.js has been around significantly longer since around 2009, and then deno came out around 10 years after that. The interesting thing about node.js is that it predates a lot of what we consider to be modern JavaScript. So for example, it still supports CommonJS, even though it has ES modules. It still has its legacy callback APIs, even though it now has support for a lot of promise-based APIs. Node has also historically, although it has changed a lot in recent years, taken a kind of defer everything to user land approach. So the idea was that core would be very minimal, and that user land would implement NPM modules for a lot of other functionality. I would say that Dno has taken a different approach, where it's much more batteries included. It has an integrated tool chain and a number of other things, which I'll talk about later in these slides. Another thing is that Node.js has a huge ecosystem with a lot of legacy code. This can be good and bad, so having a huge ecosystem is nice. But having to support so much legacy code can actually slow down a lot of progress and actually kind of hinder Node's ability to have standards compliance, which is something else I'll get into later in the slides.

2. Deno Timeline, DenoDeploy, and Growth

Short description:

The timeline for Deno, the release of Deno 1.0.0, the announcement of the Deno company, and the introduction of DenoDeploy. DenoDeploy is a globally distributed JavaScript VM for cloud deployment. The growth of Deno in terms of GitHub stars compared to Node.js. Next, the core technologies under the two projects will be discussed.

So the timeline for Dno is roughly shown here. So in June of 2018, Dno was first introduced at JS Conf EU. Later that year in August, Dno 0.1.0 was released, and it was rewritten in Rust. So initially, the native parts of Dno were written in Golang. And they were kind of moved over to Rust because there was kind of concern about having multiple with garbage collectors running in the same process.

So then in May of 2020, Dno 1.0.0 was was finally released. So then in March of 2021, the Dno company was announced. So this is nice, because having a company backing a project can can really help because you can lay out a roadmap. You can allocate workers to work on specific things, and just generally have better control of how the project is going to be developed. On the other hand, Node.js is run by almost all volunteers. So you know, we can't really, on the Node side, control who's going to work on what. We can't tell volunteers to spend their time on certain features. And we've even had initiatives like Node's Benchmarking Working Group, which is doing a lot of useful work, have to be wound down because there just was nobody that was working on them at the time. So having a company backing the project is huge, in my opinion.

So then in June of 2021, DenoDeploy was announced. So DenoDeploy is a very similar runtime to the open source Deno project, except it's meant to be deployed in the cloud. It's more or less a globally distributed JavaScript VM that lets you run JavaScript programs at the edge all over the world. So there's currently 32 different edge locations that are supported and we're constantly adding more. It's nice because you can write your code and have it deployed in less than 10 seconds globally. And then in Q3 of this year, we are aiming to get DenoDeploy to general availability. And right now it's still in a public beta.

So I wanted to talk quickly about the growth here. So this graph shows GitHub stars for the Deno CLI as well as Node.js. The graph would only generate back to around 2015, even though Node actually goes back to 2009. So that arrow shown there should actually be wider. GitHub stars are kind of a proxy metric for adoption. Anyone can star a GitHub repository without actually using the project. But we do have some internal metrics that indicate that this growth is real and not just fluff on GitHub. So I think based on the 10-year age difference in the two projects, the difference in stars is really something that is worth kind of noting. Next, I want to talk about the core technologies that are under the two projects.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Understanding React’s Fiber Architecture
React Advanced Conference 2022React Advanced Conference 2022
29 min
Understanding React’s Fiber Architecture
Top Content
We've heard a lot about React's Fiber Architecture, but it feels like few of us understand it in depth (or have the time to). In this talk, Tejas will go over his best attempt at understanding Fiber (reviewed by other experts), and present it in an 'explain-like-I'm-five years old' way.
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
You can check the slides for James' talk here.
ESM Loaders: Enhancing Module Loading in Node.js
JSNation 2023JSNation 2023
22 min
ESM Loaders: Enhancing Module Loading in Node.js
Native ESM support for Node.js was a chance for the Node.js project to release official support for enhancing the module loading experience, to enable use cases such as on the fly transpilation, module stubbing, support for loading modules from HTTP, and monitoring.
While CommonJS has support for all this, it was never officially supported and was done by hacking into the Node.js runtime code. ESM has fixed all this. We will look at the architecture of ESM loading in Node.js, and discuss the loader API that supports enhancing it. We will also look into advanced features such as loader chaining and off thread execution.
Out of the Box Node.js Diagnostics
Node Congress 2022Node Congress 2022
34 min
Out of the Box Node.js Diagnostics
In the early years of Node.js, diagnostics and debugging were considerable pain points. Modern versions of Node have improved considerably in these areas. Features like async stack traces, heap snapshots, and CPU profiling no longer require third party modules or modifications to application source code. This talk explores the various diagnostic features that have recently been built into Node.
You can check the slides for Colin's talk here. 
Node.js Compatibility in Deno
Node Congress 2022Node Congress 2022
34 min
Node.js Compatibility in Deno
Can Deno run apps and libraries authored for Node.js? What are the tradeoffs? How does it work? What’s next?

Workshops on related topic

Detox 101: How to write stable end-to-end tests for your React Native application
React Summit 2022React Summit 2022
117 min
Detox 101: How to write stable end-to-end tests for your React Native application
Top Content
WorkshopFree
Yevheniia Hlovatska
Yevheniia Hlovatska
Compared to unit testing, end-to-end testing aims to interact with your application just like a real user. And as we all know it can be pretty challenging. Especially when we talk about Mobile applications.
Tests rely on many conditions and are considered to be slow and flaky. On the other hand - end-to-end tests can give the greatest confidence that your app is working. And if done right - can become an amazing tool for boosting developer velocity.
Detox is a gray-box end-to-end testing framework for mobile apps. Developed by Wix to solve the problem of slowness and flakiness and used by React Native itself as its E2E testing tool.
Join me on this workshop to learn how to make your mobile end-to-end tests with Detox rock.
Prerequisites- iOS/Android: MacOS Catalina or newer- Android only: Linux- Install before the workshop
Node.js Masterclass
Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Top Content
Workshop
Matteo Collina
Matteo Collina
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
Build and Deploy a Backend With Fastify & Platformatic
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Matteo Collina
Matteo Collina
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
0 to Auth in an Hour Using NodeJS SDK
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
Building a Hyper Fast Web Server with Deno
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Matt Landers
Will Johnston
2 authors
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
GraphQL - From Zero to Hero in 3 hours
React Summit 2022React Summit 2022
164 min
GraphQL - From Zero to Hero in 3 hours
Workshop
Pawel Sawicki
Pawel Sawicki
How to build a fullstack GraphQL application (Postgres + NestJs + React) in the shortest time possible.
All beginnings are hard. Even harder than choosing the technology is often developing a suitable architecture. Especially when it comes to GraphQL.
In this workshop, you will get a variety of best practices that you would normally have to work through over a number of projects - all in just three hours.
If you've always wanted to participate in a hackathon to get something up and running in the shortest amount of time - then take an active part in this workshop, and participate in the thought processes of the trainer.