Deno

Tuhin Das
3 min readMay 21, 2020

--

A better nodejs ?

It’s been only one week since Deno arrived, and every one in javascript is talking about it.

What is Deno ?

“A simple, modern and secure runtime for JavaScript and TypeScript.”

Developed by the creator of the nodejs, Ryan Dahl. First version(1.0) was released on 13th May 2020.

Why Deno exists ?

Long time after nodejs was released, Ryan Dahl expressed some of his regrets and things he thought were not right with nodejs. Hence, Deno made its way with all those corrections.

What’s new in Deno ?

Talking about ‘new’, there are many interesting features which have been introduced in Deno. Following are some of the features of Deno :

No npm

Deno is not using npm for package management. Infact, it is not using any package manager at all. You can directly import any library from anywhere. This type of import opens way for decentralized package management and yes, this also means no package.json file for your project.

import { serve } from "https://.../http/server.ts";

More secure

In Deno, you need to define the permissions of read-write operations from command line which makes your code more secure in different environment with different use cases.

deno install --allow-net --allow-read https://.../file_server.ts

Support for Typescript

This is big for all the fans of typescript. Deno supports both javascript and typescript as first class languages at runtime. You can also provide custom configurations for your typescript using tsconfig.json and tell Deno to use it.

deno run -c tsconfig.json mod.ts

More Work Less Code

Code in Deno looks very simple and compact. In some places it even looks like a shorthand of nodejs. So, you can do a lot in Deno with less code.

const listener = Deno.listen({ port: 8080 });
console.log("listening on 0.0.0.0:8080");
for await (const conn of listener) {
Deno.copy(conn, conn);
}

Inbuilt Libraries

Deno offers a lot of built-in functionalities and hence, you don’t need to import a lot of packages for everything. In the following example, you can see that Deno instance has been used to open and copy a file without the need to import any file utility library such as fs.

let file = await Deno.open(filename);
await Deno.copy(file, Deno.stdout);

Library Caching

While Deno lets you import libraries from anywhere, It also imports them only once and caches it. If you need to get the newer versions of imports, you need to reload them explicitly.

--reload=https://deno.land/std/fs/copy.ts,https://deno.land/std/fmt/colors.ts

Is it better than Nodejs ?

When we discuss so much about Deno, I think the important question that matters the most is ‘is it better than nodejs ?’ . But first lets understand why everyone is asking this question. When nodejs came, it immediately created a place for itself because of all the features it offered at that time and since then nodejs evolved at its own pace with no one to compete. But, even after so many years nodejs feels like it has hardly evolved from the time it was born and it meant a bigger evolution was due. Finally, Deno gives that feeling of evolution and future ready.

There is no denying that Deno does pack a punch of amazing features and it’s a step in right direction but far from where people actually starts to solve problems with Deno. Also, nodejs is a very old and trusted player with huge community support and people who are used to nodejs rules. Even with Deno’s new exciting features, to come and set new rules is a steep road. And next couple of years may actually decide the fate for both nodejs and Deno.

--

--

Tuhin Das

Front End Engineer (L5) @ Amazon | Solving Customer Problems In E-Commerce Domain