Deno versus Node.js
Deno aims to fix Node.js design mistakes and offers a new modern development environment.
iJS editorial team: How does Deno differ from Node.js?
Krzysztof Piechowicz: Both platforms serve the same purpose, but use different mechanisms. Deno uses ES Modules as the default module system, whereas Node.js uses CommonJS. External dependencies are loaded using URLs, similar to browsers. There is also no package manager and centralized registry, modules can be hosted everywhere on the internet. Contrary to Node.js, Deno executes the code in a sandbox, which means that runtime has no access to the network, the file system and the environment. The access needs to be explicitly granted, which means better security. Deno supports TypeScript out of the box, which means that we don’t need to manually install and configure tools to write TypeScript code. Another difference is that Deno provides a set of built-in tools, like a test runner, a code formatter and a bundler.
Deno – an example
iJS editorial team: Can you pick out a difference and demonstrate it with an example?
Krzysztof Piechowicz: In my opinion, the most important difference is how modules are imported. As I mentioned, Deno doesn’t use the CommonJS format and doesn’t provide a package manager like npm. All modules are loaded directly in code using an URL.
Here is a Node.js example:
At first glance, the Node imports look simpler, but there are a few advantages to using the Deno style. By importing code via URL, it’s possible to host modules everywhere on the internet. Deno packages can be distributed without a centralized registry. There is also no need for the package.json file and a dependency list, because all modules are downloaded, compiled and cached on the application run.
iJS editorial team: What is the current status of Deno? Can it already be used in production?
Krzysztof Piechowicz: Deno is still under heavy development and isn’t production-ready yet. There is also no official date for the release of the 1.0 version.
The future of Deno
iJS editorial team: What’s the next step with Deno? Is it actively being developed? By whom, in which direction?
The goal of Deno is not to replace Node.js, but to offer an alternative.
Krzysztof Piechowicz: Deno is an open-source project and is being developed very actively. The project was started in 2018 by Ryan Dahl. Currently, the project has over 150 contributors. Besides the release of the 1.0 version, there is a plan to provide a command-line debugger and built-in code linter to improve
developer experience. Deno should also serve HTTP more efficiently.
iJS editorial team: What is the core message of your session at iJS?
Krzysztof Piechowicz: The goal of Deno is not to replace Node.js, but to offer an alternative. Some of the differences are quite controversial and it’s hard to predict if they will format in a correct way. I recommend that all Node.js programmers keep an eye on this project. I’m not sure if this project will be a success, but it’s a great opportunity to observe how Node.js could have been implemented differently.
iJS editorial team: Thank you very much!
Deno – a better Node.js?
Watch Krzysztof Piechowicz’s session from iJS 2019: Deno – a better Node.js?