Introduction to Deno
Tags: deno, typescript
Published: 2020-05-22 20:08:28

---
title: Introduction to Deno
published: true
description: Republished from https://wa9ace.net/2020/05/22/introduction-to-deno.html
canonical_url: https://wa9ace.net/2020/05/22/introduction-to-deno.html
tags:
- deno
- typescript
---

Originally published on [WA9ACE.net](https://wa9ace.net/2020/05/22/introduction-to-deno.html)

I've very much enjoyed all of my experiences with Deno and I've wanted to share that experience along with frequent questions I've been asked.

Related:
* [Watch me live code a new high performance Deno webserver](https://wa9ace.net/2020/05/22/deno-live-coding.html)
* [How to Debug Deno in VSCode](https://wa9ace.net/2020/05/21/debugging-deno-projects-in-vscode.html)
* [Deno Command Cheatsheet](https://wa9ace.net/2020/05/20/deno-command-cheatsheet.html)

## How things are (were?)

Imagine if you will a TypeScript node project similar to this [project skeleton](https://github.com/WA9ACE/ts-node-skeleton) I took a few hours to whip together.

This skeleton has:

* TypeScript Express
* TypeScript aware tests with Jest
* TypeScript aware linter with ESLint

To produce that you need upwards of 2k+ packages, and 3 different config files with vaguely similar rules to have them all behave cohesively. This is all not to mention how difficult it is to get debugging in VSCode going with properly mapped files, testing, and breakpoints. Imagine you're a newer developer. You don't have a mentor able to walk you through setting up a new project with a TypeScript stack so you can start writing something, anything, useful. How about from another perspective. Do you trust that your linter isn't silently shipping data off of your machine across the network? If you aren't vetting your dependencies [you](https://wa9ace.net/2020/04/17/example-of-why-you-always-vet-dependencies.html) [should](https://wa9ace.net/2019/08/23/rest-client-hijacked.html) [be](https://wa9ace.net/2019/02/24/perceived-security-trust-and-the-ken-thompson-hack.html).

There are a lot of little things that are vaguely irritating, but not so entirely off-putting that the internet wouldn't use it. After all the [world runs on JavaScript](https://blog.codinghorror.com/the-principle-of-least-power/).

This death by a thousand cuts can be a slog and irritating to keep updated, with packages required just to keep your project's source code compiling, tests passing, and linter fixing, a cluster of issues.

## What Deno Provides

Deno seeks alleviate many of these issues. Deno has a built-in functionality for almost everything we've discussed above. First of all Deno has a TypeScript compiler built in, with plans to [port all of TSC to Rust](https://github.com/denoland/deno/issues/5432)! It has testing built in out of the box with `deno test` along with a built in formatter with `deno fmt`. What's even better is that this requires no extra dependencies, and no configuration to support TypeScript. It Just Works™. Another piece of functionality Deno ships with is the ability to restrict application's abilities with a whitelist permission system. If you're program doesn't need any network access or filesystem access then you can simply run your deno program with `deno run`. If you need network access to specific domains, and filesystem access to specific folders you will need to declare that when invoking the program. Something similar to `deno run --allow-read=/etc --allow-net=github.com,deno.land your_program.ts`. `-A` will blanket allow all permissions, but that's not something that should be used lightly.

## Packages

Deno imports packages via URL and takes a completely different approach from Node's NPM ecosystem. There is no centralized package management system. There is [deno.land/x](https://deno.land/x) however there is [discussion](https://github.com/denoland/deno_website2/issues/406) regarding whether or not it remains to be a good idea to provide a centralized mirror for simple files hosted on GitHub.

I plan to release modules under my own namespace using this sort of structure `https://wa9ace.net/deno/pkg/daro/v0.0.1/mod.ts`.

Deno allows you to produce a lockfile so that if a dependency's hash changes between first use and the next reload you can inspect to see why, as well as providing a way to vendor dependencies so that you don't have to rely on anyone's, including my own, dependencies being available on any given server.

### But I don't want super long imports all over my codebase

Answer: `deps.ts` [as recommended in the deno.land/manual](https://deno.land/manual/linking_to_external_code#it-seems-unwieldy-to-import-urls-everywhere)

### What's the convention for publishing packages if there's no NPM?

Essentially projects have a `mod.ts` file that rexports the public parts of the library you're using. This makes the steps for publishing a package quite easy as all you really need is your TypeScript code, a place to put it online, and a `mod.ts` file that exports the part of your code that you want published.

If you'd like to learn more about Deno and watch a senior engineer live stream building Deno libraries, [join me in Discord](https://discord.gg/GGaHtF8) every Tuesday and Thursday night at 9pm eastern.