Top Ten Things I Like About Deno
a review of the javascript runtime
2021-11-21
Contents
- Intro
- Top level async/await
- TypeScript
- Tooling
- Dependencies
- A Standard Library
- Sandboxed By Default
- ES Modules
- Documentation
- Conclusion
Intro
This weekend I spent some time writing a little command line utility in typescript using deno, the next generation javascript runtime from the maker of node.js.
It was pleasant.
Here are my top ten favorite things about using deno.
1. Top level async/await
This is really nice, but itās also kind of a gotcha for me because I
get used to just dropping await
s wherever and whenever I
want, but then you still canāt drop them inside of a function without
first making it async
. Which Iām prone to forget to do
now.
2. TypeScript
To be honest, Iām not very good at TypeScript. Iāve never had to use it extensively. But I like the idea of it, and will probably continue to try to use it more thanks do deno supporting it out of the box. No babel, webpack, etc needed.
3. Tooling
Deno ships as a single binary that includes a date -d -R (prettier), a linter, and a test runner. Itās so nice to be able to just start working on a project and not have to set up and configure all your own tooling.
The tooling also includes a compiler so that you can create a binary for your own architecture or for a target. This is exciting because it makes Java/TypeScript feel more like a ārealā systems language in which you can create little scripts and apps and utilities.
4. Dependencies
I prefer to describe things as what they are as opposed to what they
are not. But in this case, node.js got dependencies / package management
so wrong that thereās really no better way to describe denoās approach
as ānot nodeāsā. There is no node_modules
folder and no
package.json
.
Instead, you import modules directly by their URL just like you would in the browser.
Convention is to create a deps.ts
file at your project
root and fill it with a bunch of exports:
export { module } from "https://unpkg.com/liltest@0.0.5/dist/liltest.js";
Youāll notice that you can lock in a specific version as part of the URL.
Dependencies are downloaded once and then cached until you reload.
You can view your entire dependency tree with
deno info mod.ts
.
5. A Standard Library
Deno has a standard library that puts node.js to shame.
It also has an extensive repo of third party modules.
6. Sandboxed By Default
Deno is a secure runtime that is sandboxed by default. It cannot read or write or access the net. You must intentionally allow these privileges, and you can do so in an incremental way: you can allow read/write access only to specified files.
7. ES Modules
A minor feature, but itās just nice not having to contend with nodeās CommonJS modules.
Consistency is nice. One less thing to worry about. You can just start working.
8. Documentation
The deno.land docs browser is
pretty good. Documentation for exports is generated from jsdoc style
comments using
deno <abbr title="Document">doc
. (See
āToolingā above.)
You can also type check examples in your comments with
deno test --doc mod.ts
to make sure your examples are
always up to date.
The manual also feels very complete.
Conclusion
Thatās it. I guess there are only 8 things that I really like about deno after all. But I like them a lot. Iāve said it a couple times, but the major overall feeling is that deno allows you to just start on a project and not have to configure your project and your transpiler and webpack and wrestle with your dependencies.
It feels like a much more mature and useful platform than node.