Deno First Look

Installing Deno & Deno Basics

Burke Holland

Burke Holland

Deno First Look

Check out a free preview of the full Deno First Look course

The "Installing Deno & Deno Basics" Lesson is part of the full, Deno First Look course featured in this preview video. Here's what you'd learn in this lesson:

Burke installs Deno, briefly demonstrates running JavaScript in the Deno REPL, and discusses the native bindings of Deno being rooted in Rust. The performance of Deno and other environments is also briefly looked at.


Transcript from the "Installing Deno & Deno Basics" Lesson

>> So we've taken a look at, and, in fact, spent quite a bit of time talking about the philosophical ideas behind Deno. I didn't cover all of them. I just covered the ones that I felt were most applicable to why Deno is the way that it is. And try to lay some ground work for how Ryan sees things.

I highly encourage you to watch that video because I don't wanna speak for Ryan. I tried to summarize his ideas and show you how it plays out, but really you should listen to it in his own words. Okay. So, installing Deno it's one commands, cURL or PowerShell, your choice.

We're not gonna regurgitate the docs here today. I'll let you do that on your own. It's not a very hefty install, it should be relatively quick. But once you have Deno installed, then we can start by taking a look at the rappel. So let's do that. Rappel stands for run, what does it run execute, run in print loop.

Yeah. Yeah, I always have to look that up. So let's do that. So let's just hit Deno and then that's gonna put us into the rappel and you can see where Deno 1.6.1. And actually it just came out. In fact, I showed up yesterday to tech check. And [LAUGH] I saw that the version of Deno had changed.

So it's changing rapidly, but it is considered stable in so much is like the main API isn't going to change on you. Which is good. Okay, so inside of the rappel we can do something simple like console log. Hello World. There you go. And you'll notice that like, we get syntax highlighting, which is kinda cool.

I think Deno's doing that, because no doesn't do that. Anyway, that works. And then it returns undefined, because everything in JavaScript has returned value. Even if you don't specify one, it just returns undefined. So that's just how JavaScript works. You can do multi line things inside the Deno rappel right?

So we could do function hello, take a name. And then when you open this brace like it just knows not to execute it knows that you're gonna do a multi line here. And then we can continue and just log out name. And then when we close the brace, it will exit.

And then we can call this function, right? And pass in, let's pass in World, right? And then, it just says world. It's just echoing back whatever we pass in. So that's the Deno repple. The node repple by the way, Ctrl D to exit does the same thing. One of the big differences in the node repple is that the node repple has this thing called editor where you can just type dash dot editor.

And then you're in this multi line editor mode where it's the same kinda thing or it's like function Hello name. But you see you're not getting the syntax highlighting which is strange. I guess Deno's doing that. But it's not gonna until we actually, it says Ctrl Ctrl + D to exit, yeah, and then undefined and then we can actually call this function.

But Deno doesn't have this idea of this editor mode. But it doesn't matter because honestly, we don't spend a lot of time in the repple. I don't know that any of you have I don't I have been coding for 15 years. I don't hang out in reppels just know that that's the repple is there, that's how it works.

So by the way, any guesses on which language Deno is written in? Both Deno and node use v8 for executing the JavaScript. That's where the JavaScript is actually executed. That's the Google's JavaScript engine. But when they need to reach out to the operating system to do things like read files, then that needs to be native code.

And Deno, it actually says on the website what is written in but it's more fun to go spelunking into their repo. So let's do that and go into the core on Denos repo and look at these files here and you can see they have .rs extension and these are rust files.

Rust is a language that was created by Mozilla. And it was created to be for highly safe concurrent systems. And what they mean by that it's like C++, except for the fact that it doesn't allow for things like no pointers and no pointer exceptions which are common. And, so another interesting aspect of rust is, it was also written in part with contributions from Brendan Eich, who also wrote JavaScript.

So the very tight circle here that we're revolving in where Brendan Eich created JavaScript also worked on rust and Deno sort of bringing these two things back together. Node, by contrast, has native bindings that are in a combination of C and c++. So you might remember that earlier we talked about Ryan being very, very interested in IO performance when he created node.

As he says he was obsessed with it. And so this idea of highly performant HTTP systems. And so the question then becomes, what is the difference between Deno and node? And so this is from their own benchmarks here, and in fact, we might wanna take a look at it just in case it's been updated.

And you can see all the relative disclaimers about bench, it has been updated okay. This is execution time. Let's get down to what I really wanna look at is HTTP Server Throughput. And so you can see here it's kind of hard to tell because a lot of the colors are the same but that blue line at the bottom, the very bottom, that's Deno's HTTP performance.

And that green line that's just sort of like hovering above it. That's nodes HTTP performance. And so you can see that node is more performance than Deno is currently in terms of HTTP requests. And that's something that people will tend to point out about Deno's that it's not as performant.

But it looks to me, just as a casual observer and not an expert in performance metrics or HTTP systems that, that difference is kind of small, right? It doesn't appear to be extremely large here between the blue dot and the green dot. Also, those of us that are writing programmes, we are probably not building systems that are that concerned about performance to where we would say, well, I can't use Deno because it's simply isn't performant enough.

But it is important to note that as of the time of this writing node still faster in terms of being an HTTP server. Also, I wanna know what Hyper is. I didn't even know what this is. I tried to look this up, but whatever this is, let's do that.

Look at this line. Looks amazing. She sees that.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now