DEV Community

Greg Fletcher
Greg Fletcher

Posted on

What is Deno.js and why should you care?

TL;DR

  • Deno was created by Ryan Dahl, the creator of Node.js.
  • Deno is secure by default. Without permission, it cannot access files, network, or the environment.
  • Deno has TypeScript built-in with no external configuration needed.
  • External packages are pulled in via urls (much like Go)
  • Deno is an anagram for Node and it's pronounced Deeno (long e).

Introduction

Deno.js is arriving its 1.0.0. release date on May 13th, 2020, so I decided I collate the top information about the project.

Let's start!

The Beginning

In 2018 Ryan Dahl did a talk at JSConf EU where he talked about his top 10 regrets with Node.js. His talk was excellent and you can watch it below.

In his talk, Ryan mentioned he had concerns with the node_module system and other legacy API's that will never change. He noted that JavaScript has changed a lot since Node.js came out and that he could see a way to make a better version of Node.js. He wanted it to be compatible with the browser AND the server environment. Security was also something that he wanted to focus on.

May 13th --> Release Date

A lot has happened since Ryan's talk at JSCONF 2018. Many people have joined the project, it already has 48k stars on Github, and the project is beginning to raise a lot of attention in the community prior to its official 1.0.0. release on May 13th.

Time will only tell whether Deno will continue to grow but if the initial reaction is anything to go by, it's very positive.

Top Syntax Features

Top Level Await

No more wrapper async functions. Just use top-level await syntax

const data = await fetch('someapi/data');

Import and URLs

You can use import and you don't need to NPM install all your packages. Much like GoLang, you can import from URLs.

import stuff from 'https://package/url'

TypeScript Built In

No need to set up TypeScript. It's all built-in. Just start writing your code!

Secure By Default

Deno has restricted access to files, the network, and the environment. This is a big difference to Node.js which has access immediately to everything.

ES6 and beyond

Unlike Node, Deno has the opportunity to incorporate modern JavaScript syntax which can remove the callback hell that Node can lead to.

Compatible with the Web

Deno's API is meant to be compatible with the web.

Web Assembly

Deno has support for wasm binaries.

There's more planned with Web Assembly so keep an eye on the project.

Interesting Resources

Creator Talks

Videos of Conference talks by Deno creator Ryan Dahl and fellow project contributors Kitson Kelly and Bert Belder.



Introductions from the Community

Jeff from Fireship does a short informative rundown of Deno (with super cool graphics).

Harry goes in-depth about Deno and what it could mean for the future of JavaScript. He has more great Deno tutorial videos that you should check out.

Articles

Ryan Dahl did an interview with the organizers of the HolyJS Conference. Read it here.

Summary

Deno is an exciting project that you should definitely check out!

I would like to be clear that this article isn't bashing on Node.js. Node.js is amazing, I love using it and will continue to. It's just nice to have a new and improved version out there for the future.

Let me know what you think of Deno. Are you excited, surprised, or horrified? Let me know in the comments!

Top comments (22)

Collapse
 
sxurik profile image
sxurik • Edited

Unlike Node, Deno has the opportunity to incorporate modern JavaScript syntax which can remove the callback hell that Node can lead to.
The problem with callback hell in Node has been solved a long time ago. Most features of modern js has been or are being incorporated in node. For example, It is possible to use top-level await with Node (with some set up) even though it is still ECMAScript proposal.

I see extensive use of callbacks only in training videos as an example of how not to do it. What version of Node are using?

Collapse
 
gregfletcher profile image
Greg Fletcher

Thanks for your comment.

Yes, Node.js has updated a lot recently and with some configuration can bring in more modern JavaScript syntax. I just appreciate that Deno has all of this by default. Whereas, as you mentioned, features like top-level await in Node.js require some set up.

Also, some people still use the callback style. It will take a while for everyone to catch up and for people to take on new programming styles. Deno just provides a way to skip that process and work with a more modern API without legacy issues.

Either way, I'm excited for the Deno project :)

Collapse
 
hungluong profile image
Hung Luong

I don't think "don't need to NPM install all your packages" is solving anything, or am I misunderstanding something? You don't get the benefit from a management mechanism AND have to reference dependencies over and over again in your files?

Collapse
 
gregfletcher profile image
Greg Fletcher

Great question.

It does follow the standard of using URLs for pulling in packages that GoLang employs and what the Web is built upon. The versioning can be solved by deps.ts file which Deno is currently using also. Deno is following in the footsteps of other projects and learning from them to create a (hopefully) better third-party package system.

I understand the concern that you might have, it's understandable. The good news is that the Deno project is very deliberately going in this direction. So a lot of thought has gone into it.

I highly recommend watching Ryan Dahl's talk announcing Deno. He talks about his reasons and you learn a lot about Node.js along the way. Definitely worth a watch. You can see it here

Collapse
 
ribizlim profile image
Mark Magyarodi

I'm still curious (and doubtful):

  • how the download of 100s of *.ts files is optimized (HTTP request overhead, HTTP/2 is a solution here? or bundling?)
  • how semver works (e.g. to use common version for the different versions of the same module): does cache support semver?
  • what about gzipped packages, will it be possible in the future? or bundling is the idea? So indirect deps are included multiple times in different modules?
  • what if a module is hosted from different sources, but it is the same. this is common practice with browser JS CDN hosting (jsdelivr, cdnjs, unpkg). if deno.land/x is the answer isn't it centralized like npm?

This discussion mostly covers all my concerns: github.com/denoland/deno/issues/47

Collapse
 
sirseanofloxley profile image
Sean Allin Newell

I've started using deno for my one off scripts, was very pleasant. Love top level async/await.

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

I just use TypeScript with ts-node where I can find more libraries.

Collapse
 
soremwar profile image
Steven Guerrero

Most Node libraries work with Deno. Check PIKA.DEV and JSPM.IO, or follow the tutorials on how to make conversion of packages.

Technically, any package that is valid JavaScript (and not NodeJS JavaScript) is a valid Deno module.

Thread Thread
 
jianwu profile image
jianwu

Jspm.io sounds interesting,

Collapse
 
eatsjobs profile image
Pasquale Mangialavori

How do you publish a package with deno?

Collapse
 
sirseanofloxley profile image
Sean Allin Newell

There's a package repository deno land, but you could just push to a git repo on GitHub or GitLab

Collapse
 
eatsjobs profile image
Pasquale Mangialavori

Seems we can also use the pika PKG CDN around npm packages👍

Collapse
 
gregfletcher profile image
Greg Fletcher

Thanks Sean! 🙌

Collapse
 
eatsjobs profile image
Pasquale Mangialavori

Yes but can we get the package with semver?

Collapse
 
elisealcala profile image
Elizabeth Alcalá

Seems interesting, I love the Typescript support out of the box, thanks for the article!

Collapse
 
gregfletcher profile image
Greg Fletcher

Glad you liked it!

Collapse
 
judecodes profile image
Cool

Next JS Runtime
Done

Collapse
 
gregfletcher profile image
Greg Fletcher

Node.js and Deno.js are run times for JavaScript. So if you can write JavaScript you'll be ready to go!

Collapse
 
barzi92367868 profile image
Barzi

Didn't know about the project. Very interesting! Thank you. I'm gonna give deno a try. BTW how is it pronounced? Deeno? 🤔

Collapse
 
gregfletcher profile image
Greg Fletcher

Haha yeah, there has been some confusion about the pronunciation. It started as Deno (short 'e') and now is Deeno (long 'e'). It has a lot to do with the logo of the Dinosaur. You can watch Ryan Dahl (the creator) talk about it here. I've time stamped it so you can skip straight to where he starts mentioning it.

Collapse
 
magarcia profile image
Martin Garcia

I heard about Deno some time ago. I think is time to investigate a bit more. Thanks for the article, the collection of resources you posted is perfect to start learning about.

Collapse
 
gregfletcher profile image
Greg Fletcher

You're welcome! Enjoy your journey in Deno!