Deno is Webby (pt. 2)
The Deno team recently shipped Deno by example:
Deno by example is a collection of annotated examples for how to use Deno, and the various features it provides.
Itâs a pretty neat little reference.
I browsed through each of the examples and one thing I noticed, which Iâve blogged about before, is how âwebbyâ Deno is. Meaning, its APIs are (as much as possible) the web platform JavaScript APIs.
For example, look at the recommendations for doing input prompts: itâs the alert
, confirm
, and prompt
JavaScript APIs. No new APIs, just the ones you know and love.
In other words: are you building a CLI tool and need to capture some input from the user? No need to find, vet, install, and learn some third-party input library. Use what you know.
const name = prompt("Please enter your name:");
console.log("Name:", name);
Continuing on the theme of a CLI tool, what if you need to log some output with a dash of style, like colors or font styles? Again, no need to find, vet, install, and learn a third-party library. You can log and style CLI output the same way you do it in the browserâs developer tools: using what you know with console.log
console.log("%cHello World", "color: red");
The point is: You Might Not Need NPMâ¢. Deno strives to mimic web platform APIs wherever possible. Commands like alert
and console.log
are available as globals in Deno (while non-standard web APIs youâll find under the Deno
global).
It reminds me of Ryan Florenceâs article where he touts one of the benefits of Remix is that you learn the web platform as you learn Remix. Itâs not all proprietary framework knowledge that will one day go extinct.
When you learn how to handle requests and send responses in Remix, you're actually learning the Web Fetch API that's in the browser alreadyâ¦This knowledge transfers!
I find Deno similar: if you learn server-side JavaScript with Deno, you might accidentally learn the web platform along the way. Itâs transferrable knowledge.
So you can:
- Learn the tool and, in the process, learn the platform.
- Or, learn the tool and, in the process, learn nothing else â when the tool fades, so does your knowledge.
This is what I love about Deno: always bet on the web.
Denoâs overarching philosophy is bringing server-side JavaScript closer to browser JavaScript. â Ryan Dahl, creator of Deno