Getting started with Deno

Getting started with Deno

Getting started with Deno. What’s Deno, and how is it different from Node.js? Deno vs Node.js: Deno Will Replace Node.JS? Node.js is Dead – Long live Deno! Deno is a new JavaScript/TypeScript runtime that was designed with all those new capabilities in mind. The goal of Deno is not to replace Node.js, but to offer an alternative.

What is Deno?

Deno is a new runtime for Typescript (and Javascript) written mostly in Rust. It has some great goals and some very interesting "Non-Goals", like not using npm and not having a package.json.

Getting it installed

Installing deno is as easy as running this command:

curl -fsSL | sh

Then copy the export line and add it to your ~/bashrc or ~/bash_profile.

Open a new terminal and run deno. You should get a > prompt. Type exit and let's dig into some features!

Cool features in Deno

Typescript by default

Deno is integrated to run Typescript files by default. It basically makes types in Javascript a first-class citizen. No more compiling through Babel to use Typescript in server-side Javascript.

Importing from a URL

Deno lets you import from the web, just like you can in the browser. Just add a URL where you would usually name a module:

import { bgBlue, red, bold } from ""; 

A Standard Library

Furthermore, Deno has a standard library that is easy to import and use. There are modules that do a couple of different things, like HTTP handling, datetime work, and file system work. You can check it out here.

Uses ES modules

Finally, Deno only supports ES module syntax, which means no more require() statements, just good ole' import x from "y".

Hello World Example

Let's look at a quick Hello World that highlights a few of those features!

Copy this into a hello-world.ts file.

import { bgBlue, red, bold } from "";

const sayHello = (name: string = "world") => {
  console.log(bgBlue(red(bold(`Hello ${name}!`))));



You can now run that with deno hello-world.ts and it should print out some stuff.

Change one of the sayHello calls to sayHello(15); and rerun it. You should see a type error since 15 isn't a string! That's pretty cool!

You'll also notice how to import from a URL - it's getting some console color stuff from the standard library!

Final thoughts

Deno isn't quite ready for the production use - there are a couple bugs, but development is moving forward quickly! This is definitely a cool new open source project and one to keep an eye on!

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Top Node.js Development Companies and Expert NodeJS Developers

A thoroughly researched list of top NodeJS development companies with ratings & reviews to help hire the best Node.JS developers who provide development services and solutions across the world. List of Leading Node.js development Service Providers...