Deno is a JavaScript and TypeScript runtime build in Rust. It was created by Ryan Dahl, who is also the original creator of Node.js.

Eventually Deno might take over Node.js but at the moment, it’s not there yet. Node.js is too popular and is already used in many projects. It has a much bigger community and much more modules/packages available.

Deno does not provide a strong enough incentive for companies to decide to make the switch. At least not yet.

Performance-wise it is comparable to Node.js, another reason not to switch.

So why am I writing an article about it? And what does Deno have that Node.js doesn’t?

Well, I believe that if Ryan Dahl decided to build a new JS runtime, he must have had a good reason. He actually gave a talk about this.

In his talk he mentions multiple things he regrets about Node.js. Two big ones are that Node.js is insecure, by default it has access to everything (filesystem, network, etc) and NPM, the default package manager (bundled with Node.js) is centralized and private.

Deno by default does not have access to your network or your filesystem. It also allows you to use modules from anywhere without relying on a 3rd party tool, you just need to provide the full URL pointing to the module.

Another nice thing about Deno is that it runs TypeScript out of the box, you don’t need a transpilation step nor a complicated configuration.

#What are we going to build?

Now that I’ve introduced Deno, I will show you how to build a simple API with it. I will reproduce the example I made in my Rust guide.

We will create an API with the following endpoints

  • GET / This endpoint will simply return a text message Hello World!.
  • GET /items This endpoint will return the list of items we have in the database in a JSON format.
  • POST /items This endpoint will allow us to create a new item in the database.

#deno #typescript #javascript #mongodb #nodejs #node

Introducing Deno: A JavaScript and TypeScript Runtime Build in Rust
1.80 GEEK