Deno v1.0.0 released to solve Node.js design flaws
You can see why: using the same language on the front-end and back-end simplifies things. You can code both front-end and server-side code without knowing multiple languages, and then reuse code in both. Plus, it has garbage collection, so there’s no messing with memory management or any of the underlying machinery. Create your business logic code and let her rip. That scripting simplicity is one of the reasons that Python was and remains so popular.
Plus it popularized event-driven programming (but didn’t really make it easy) at a time when that wasn’t really prevalent. Node.js only does work when it’s called on. It gets a request, fires a callback, and so long as nothing else needs to run, it sleeps. A huge leap for supporting a large number of concurrent users asynchronously. No wonder so many large web applications use it.
But that was 11 years ago, and in computing terms, that is ancient. While the Node.js ecosystem has grown to produce a vast number of libraries—there are over a million on npm alone—it’s based on a technology that itself has gone through 11 years of incredible growth. There’s been hack-arounds, but they’re still imperfect.
Node.js creator, Ryan Dahl, left the Node.js project in 2012 and started working with it again around six years later. In using it again, he found a number of design flaws that bothered him. In a JSConf EU presentation from 2018, he said, “Bugs are never so obvious as when you’re the one responsible for them.” So he decided to create a new implementation of his original idea: Deno. With Deno v1 releasing last week, that new version is available to everyone.
What is the difference between Deno and Node?
Like Node, Deno primarily operates on a command-line interface, which makes calling it from other programs easier. It’s built in Rust to be fast and includes a plugin API. Deno is designed to be a series of Rust crates, with
TypeScript has shot up in popularity recently, in a large part because of the easier maintainability and debugging that comes from a statically typed language, but also because of its adoption by popular front-end frameworks like Angular and React. By taking out the build step, Deno takes away yet another reason not to switch to TypeScript.
For a technology built for events, Node.js didn’t do a great job with them. It came out before the concepts of Promises or the async/await patterns, so had to come up with its own version. Early on in 2009, Node.js actually had a version of the promises abstraction, but it was removed in 2010. Instead, it went with the
EventEmitter pattern. Unless you explicitly called
pause(), any opened TCP sockets threw events at you non-stop, potentially drowning a stalled application.
Deno reverses this. Instead of explicitly stopping the flow from sockets, you have to explicitly read from them. They still operate asynchronously, just not constantly. Combine that with Futures, a Promises-like abstraction built into Rust, and you can manage incoming events much easier.
But no piece of web tech is an island these days, and Deno—like Node.js—will support a vast ecosystem of modules and dependencies. Node.js did this with npm, but though it had a central repository with npm, it was unable to prevent bad actors. Recently, some once useful packages updated and slipped in malicious code, exposing the difficulties in automatic updates.
Deno has been getting some criticism in how they manage dependencies. Instead of routing them through a package manager, Deno specifies each dependency module as a simple URL. You no longer have the protection of a central manager, but there’s no guarantee that this repository provides any more protection than a direct link to that code.
Like any modern browser, Deno executes all code in a sandbox; it can’t access the hard drive, network connections, or I/O peripherals without explicit permissions. Any code has to be executed with a flag that enables non-sandbox activities. And permissions are granular—you can grant access to a single hard drive or network location.
Dahl makes it clear that this isn’t a continuation of Node; it’s a whole new project. As such, it doesn’t currently mesh with the existing Node.js ecosystem. Most packages won’t work and the tooling is incompatible. That may keep people away for now, but as Paul Ford said on our podcast, “I am not bleeding edge anymore, but if you told me that a year from now I’m downloading to Deno instead of Node and using its package management approaches instead of npm anymore, I wouldn’t be surprised.”
Server side was in its DNA and even in its name from the very beginning!
It is really funny when you think about it: the management at Netscape was actually skeptical about whether it makes sense to develop a second scripting language for the browser since they had just signed the deal with Sun to ship Java in the browser. It is easy to forget that Java was designed as a scripting language for Interactive TV and when Interactive TV never became a thing, Sun pushed it into the client-side web space. Nobody saw Java as a server side language.
In the mind of Netscape’s executives, Java was the client side scripting language, and LiveScript was for the server.
Whoa! Thanks for the history lesson. Fascinating how wrong some of the early tech expectations were, even though those technologies still live on.
I wonder why deno why just upgrade nodejs, why two different concepts and I wonder if all this means the death of Node.js
| “You no longer have the protection of a central manager, but there’s no guarantee that this repository provides any more protection than a direct link to that code.”
Node’s central manager, NPM, is run by a private company, and they’ve had a rash of malware infections of late – so the grass is always greener in this case, arguably .
Also, if you watch Mr. Dahl’s Deno talks linked to in the article, you’ll see that the caching mechanism for code-import URLs has been well thought-out by the Deno architects. URL imports function more like canonical resource names, as opposed to dynamic linking (in fact, I believe Deno’s imports are statically processed and cached separately from the program’s execution, to specifically facilitate this sort of use).
Interesting article! A few additions that I think are worth mentioning:
(1) The NodeJS API also supports new language patterns (async iterables, promises, modules), however it has a large problem with backwards compability, that leads to very hacky workarounds (.mjs files, additional promisified APIs like `fs.promise`, …). Starting from scratch allows Deno to get rid of all of that.
(2) I think the most popular npm packages are actually the ones that fill gaps in the standard library (e.g. Express for running web servers, as the NodeJS http module is not that easy to use). Therefore as Deno has a better standard library, the ecosystem doesn’t have to be as large as the one of NodeJS. Therefore starting from scratch is not that bad for adoption.
(3) The great advantage of Deno’s module system is that you have zero configuration. To set up a basic webserver, all you have to do is to copy an example from the docs, and run it. No need to install dependencies, fix conflicts, set up a build step, and so on and so forth. Also it opens up new possibilities for distributing code, e.g. repositories that respond with different modules for development / production, A / B testing, or that have secrets baked in.
In general I think Deno is a great step forward for the JS ecosystem, and I’m really looking forward to use Deno in production somewhen …
Please let’s make sure the discussion isn’t about “Node.js vs Deno”. Deno is at a point where people can contribute and explore so let’s focus on the “building things” and “exploring” parts.
> Like any modern browser, Deno executes all code in a sandbox; it can’t access the hard drive, network connections, or I/O peripherals without explicit permissions.
Suppose, an application requires a network connection and the permission is granted, how do we know that the application will make ‘honest’ use of this granted permission and, therefore, the resource?
The permissions are pretty granular. You can open up network access to specific URLs or IP addresses only.
Crazy, learned something new today, thank you. LiveScript exists but it’s just the same name. It’s very interesting how little we know about history of our own domain, somehow things change so fast that people are not even aware how things got where they are.
I like a lot of the motivations behind Deno but I honestly don’t see it gaining wide adoption, for a few reasons:
1. You mentioned package management, but it bears repeating. Deno has *no* package management. It’s not meant to have any. This is a huge leap backward. Wider stdlib or not, the JS ecosystem has coalesced around the Semver philosophy, and trading that out for static URL imports is not a pragmatic change by any means.
“You don’t need Express anymore,” you say. Well, I don’t see what’s wrong with using packages depending on what you need — I don’t want an advanced routing system baked into my standard library when I’m just trying to write a script. Do one thing, and do it well.
3. The above points wouldn’t be an issue if Deno offered something crucial that Node fundamentally couldn’t offer. However, I’d argue that it does not. It’s been able to implement features that would take Node a long time, but API changes for Node take time for good reason; they’re preserving the aforementioned decade of development. That’s not to say that Node CAN’T implement this kind of thing, just that it takes longer. Mature software is a good thing.
There isn’t anything stopping Node from introducing opt-in command-line security permissions or a wider stdlib. In fact, most of the Node stdlib already HAS promisified alternative methods.
I have never encountered problems with backpressure in Node servers. Do we need to rewrite from the ground up to solve that problem?
TL;DR: I don’t see Deno as anything more substantial than hype.
And Microsoft is going sky rocket!
Ok, TypeScript is open source, but the merchandising is good for them.
Did you know that PHP is an amazing *command-line* scripting language? And it is still being developed today? And you can make async servers in PHP? And has a much smaller resource footprint than Node? If you didn’t know any of those things, then you’ve been out of the loop for the last decade.
And C is still kicking. When you need *real* performance, nothing beats good ol’ C (and assembler). Sure you can find some areas here or there where other languages have a slight edge, but C is an inch away from the metal while any scripting language, no matter how good it is, is a mile away from the metal. Clock cycles still matter.
“Too many Chef spoil the broth”
Many thanks for shining a spotlight on Deno, Ryan.
I’d planned to learn Node.js in 2018, but after making headway only through some of the basics, other projects and technologies diverted my attention.
More recently, I’ve caught up with a few side-projects and I’m ready to resume learning (and eventually mastering) Node.js, once again.
But now that it’s stable, I’m increasing persuaded that I should focus on Deno instead.
Promises? ES Modules? Typescript?
These three considerations, not least, suggest that it’s Deno rather than Node.js which will evolve to become the beyond-the-browser JS runtime of the 2020s.