The State of Node Compatibility in Deno

Rate this content
Bookmark

Deno is a next-generation TypeScript and JavaScript runtime from the original creator of Node.js. Deno is fast, secure by default, and provides a great developer experience, with TypeScript, JSX, testing, linting, and more all included out of the box. And best of all - you can bring many of your favorite to Node modules with you to Deno. In this talk, we'll cover the current state of backward compatibility with Node.js projects and modules in Deno. We'll demonstrate what works with zero configuration, and the available mechanisms in Deno that will let you bring the best of the Node ecosystem along for the ride.

David Sherret
David Sherret
Kevin Whinnery
Kevin Whinnery
23 min
04 Apr, 2024

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk introduces Deno, a next-generation JavaScript runtime with native TypeScript support and improved server-side development features. Deno offers granular permissions for sensitive APIs and includes built-in tools like a test framework and linter. The Talk demonstrates how to use Deno with an existing Node.js project, showcasing compatibility and import features. It also discusses upcoming features like bringing Node modules to Deno and handling file extensions. Overall, Deno provides a seamless transition for Node developers and offers a range of powerful tools and features.

1. Introduction to Deno and Node Compatibility

Short description:

Today, we are here to talk to you about the state of node compatibility in Deno. Deno is a next-generation JavaScript runtime with native support for TypeScript and a number of features that improve server-side JavaScript development. We'll give you a quick demo of Deno and then focus on node compatibility features. We'll show you how to apply these features in an existing node project. Let's get started with a Deno demo, where you'll see the native support for TypeScript and how to set up a Deno server.

What's up, everybody? My name is Kevin Wendray. I'm part of the Deno team. And I'm joined by David Sherritt, who is also part of the Deno team, working on the Deno runtime. And today, we are here to talk to you a little bit about the state of node compatibility in Deno.

So for those of you who haven't heard of Deno before, it's a next-generation JavaScript runtime with native support for TypeScript, lots of nice built-in tooling that we'll get into here in a second, and a number of features that we think kind of improve the state of server-side JavaScript development. But a major thing that you might not know about Deno is how much work has gone into backwards compatibility with Node.js as a kind of a key component of server-side JavaScript development. So in this presentation, we're going to give you just a quick demo of Deno to give you a sense of kind of how it works, how it might differ from Node.js. And then we're actually going to spend the majority of our time digging into some node compatibility features to let you know how those work, how you might apply those in the context of an existing node project.

So we're actually going to be taking a simple Node.js project that uses Express and making some changes to it using some of the node compatibility features that exist in Deno. So let's go ahead and get started. And my friend David, by the way, will be joining us kind of as our color commentator. David's actually the implementer of many of these compatibility features we're going to talk about. So I'm going to ask him some questions, and he's going to be my pair programmer as we implement some of these things. So what do you think, David? You ready to do a quick Deno demo? Definitely. All right, let's do it. So I'm going to jump over to just a sort of a blank Visual Studio code project where I'll do a very quick Deno demo just to give you a sense of how the runtime works.

So one of the things that you'll notice in Deno right away is that there is native support for TypeScript. So without any dependencies to install or anything like that, you can very quickly start writing TypeScript code. And I'll implement sort of a hello world Deno server. And in Deno, that's going to be done using the Deno namespace. And there is a Deno serve command, which is going to allow us to set up a handler function that will take a web standard request object and allow us to handle incoming requests. If you had a Deno JSON, then you'll get the type checking. Yeah, exactly. That's definitely true. So I was going to point out you might notice some of the squiggles and the lack of completion. And the way that I can fix that, as David mentioned, is by adding a deno.json, which will kind of enable my VS Code plugin for Deno to start to give me some hints about Deno serve and the built in Deno namespace, things like that. So as the first argument to Deno serve, again, I'm going to pass in a request object. And in this case, I'm just going to return a new response, which is going to be hello world. And to make the TypeScript linter happy, I'll just add a leading underscore there to indicate that I'm not actually using this request object. So this is kind of, once again, without any third party dependencies, I can write some TypeScript that's going to serve HTTP requests.

2. Deno Runtime Features and Permissions

Short description:

Deno has a unique feature of granular permission to sensitive APIs like network access, file system access, and system environment access. You have to explicitly opt into these permissions as a developer. Deno also offers built-in TypeScript support, an excellent Visual Studio Code plugin, and runtime permissions.

And if I run this with Deno run, you'll notice that I'm actually challenged for permission. And that's another feature of the Deno runtime, which is unique to Deno and doesn't exist in Node in the same way, is granular permission to sensitive APIs like network access, access to the file system, access to the system environment. Those types of permissions you have to explicitly opt into as a developer. So in this case, I'm going to say yes, I'm happy to allow network access. And now I have a server listening on localhost 8000. So if I spin up a new Chrome browser, which I will here just momentarily, and go to localhost 8000, there is my hello world response. So that's just a really quick demo of a couple of things. So we have built-in TypeScript support. We have an excellent Visual Studio Code plugin, which gives you some IntelliSense and other hints in the editing environment. And we have some of these built-in runtime permissions.

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

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?
Javascript Should Come With Batteries
React Day Berlin 2023React Day Berlin 2023
30 min
Javascript Should Come With Batteries
Setting up JavaScript projects is no fun. Getting started involves installing and configuring node, tsc, prettier, eslint, a testing framework, a database driver, and more. Why is JavaScript not batteries included? In this talk we'll talk about how Deno fixes this, letting you focus on building stuff. We explore what benefits full tooling integration unlocks, and remember how fun it is to program if your tools help you, rather than requiring your babysitting.
Deno 2.0
Node Congress 2023Node Congress 2023
36 min
Deno 2.0
Top Content
Deno 2.0 is imminent and it's bringing some big changes to the JavaScript runtime. In this talk, we'll introduce the new features including import maps, package.json auto-discovery, and bare specifiers. We'll discuss how these improvements will help address issues like duplicate dependencies and disappearing dependencies. Additionally, we'll delve into the built-in support for deno: specifiers on the deno.land/x registry and its role in providing a recommended path for publishing. Come learn about how these updates will shape the future of the JavaScript ecosystem and improve backwards compatibility with Node applications.
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
Node Congress 2023Node Congress 2023
29 min
Bun, Deno, Node.js? Recreating a JavaScript runtime from Scratch - Understand magic behind Node.js
Bun, Deno, and many other JavaScript runtimes have been hyped, but do you know why? Is it that easy to make a runtime from scratch?

I've been researching the secret behind Node.js' power and why there are so many new JavaScript runtimes coming up. Breaking down each key component used on Node.js I've come to interesting conclusions that many people used to say whereas in practice it works a bit differently.

In this talk, attendees will learn the concepts used to create a new JavaScript runtime. They're going to go through an example of how to make a JavaScript runtime by following what's behind the scenes on the Node.js project using C++. They'll learn the relationship between Chrome's V8 and Libuv and what makes one JavaScript runtime better than others.

This talk will cover the following topics:
- What's a JavaScript Engine - V8
- Why Node.js uses Libuv
- How to create a JS Runtime from scratch
Writing universal modules for Deno, Node, and the browser
TypeScript Congress 2022TypeScript Congress 2022
25 min
Writing universal modules for Deno, Node, and the browser
This talk will walk you through writing a module in TypeScript that can be consumed by users of Deno, Node, and browsers. I will walk through how to set up formatting, linting, and testing in Deno, and then how to publish your module to deno.land/x and npm. I will also start out with a quick introduction on what Deno is.
Fresh: a new full stack web framework for Deno
Node Congress 2023Node Congress 2023
24 min
Fresh: a new full stack web framework for Deno
Fresh is a web framework based on Deno and Web standards built to run on the edge

Workshops on related topic

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.
Writing Universal Modules for Deno, Node and the Browser
Node Congress 2022Node Congress 2022
57 min
Writing Universal Modules for Deno, Node and the Browser
Workshop
Luca Casonato
Luca Casonato
This workshop will walk you through writing a module in TypeScript that can be consumed users of Deno, Node and the browsers. I will explain how to set up formatting, linting and testing in Deno, and then how to publish your module to deno.land/x and npm. We’ll start out with a quick introduction to what Deno is.