DEV Community

Cover image for Why We Chose Node.js Over Deno?
Muly Gottlieb for Amplication

Posted on • Updated on • Originally published at amplication.com

Why We Chose Node.js Over Deno?

After the introduction of Node.js in 2009, it quickly gained strong momentum and wide adoption, making it the de-facto standard for writing server-side JavaScript apps in the 2010s decade. Then, when Ryan Dahl - the creator of Node.js no less - introduced Deno in 2018 in his controversial JSConf EU talk titled "10 Things I Regret About Node.js", it seemed like Node.js' reign was at risk.

When we started Amplication in 2020, focusing on JavaScript backends (well, TypeScript, but that's a story for another blog post, perhaps), we had to decide - are we going with the veteran Node.js, or are we going with the new, shiny and fast-growing kid on the block - Deno.

Our decision may surprise some of you, but it was easy for us to make it - we chose Node.js over Deno. Moreover, in 2020, this was a more obvious choice. However, if I had to go back to that decision today, it's still clear that we would have made the same decision!

This article gives an overview of the platforms, history, performance, security, and all other critical features provided by each runtime environment and shows how Node.js is still the king of JavaScript/TypeScript backend runtime environments.

What is Node.js

Node.js is a server-side JavaScript runtime built on the V8 engine from Chrome, which was introduced in 2009 by Ryan Dahl and has since become one of the popular server-side JavaScript runtimes. Developers have widely adopted Node.js due to its scalability, performance, and vast ecosystem of libraries and frameworks. Most companies prefer Node.js as server-side runtime because JavaScript can also be a scripting language for building client-side applications.

As of 2023, Node.js has evolved well and is a popular and widely used JavaScript runtime environment for building server-side applications. Many companies use Node.js and enjoy strong community support on the Internet. In April of 2023, the latest Node.js version, version 20, was released. The most significant update for Node.js 20 was introducing a Permission model that actually follows Deno, where users can explicitly mention runtime permissions such as filesystem access or restricting worker threads. Node.js comes bundled with the stable version of WebCrpto API, HTTP/1.1 KeepAlive by default, and many other noticeable updates.

The Pros and Cons of Node.js

Noticeable Node.js pros include:

  1. Fast and Scalable: Node.js uses an event-driven, non-blocking I/O model, making it highly performant and capable of handling many concurrent requests efficiently.
  2. Large Ecosystem: Node.js has a vast and mature ecosystem with a wide range of libraries, frameworks (such as Express.js and Nest.js), and tools available, making it easier to build web applications and APIs quickly.
  3. Community and Support: Node.js has a vibrant and active community, with numerous online resources, tutorials, and forums available for help and support. The community actively contributes to developing new tools and libraries, ensuring the ecosystem's growth.
  4. Run Anywhere: Node.js supports cross-platform compatibility with Windows, Linux, and macOS.
  5. NPM and Package Management: Node.js leverages NPM (Node Package Manager), one of the most prominent package registries in software development. NPM provides access to thousands of open-source packages, enabling easy integration of third-party code into your projects.
  6. Enhanced Security Controls: Node.js version 20 introduces improved security controls, including strengthened default configurations and stricter permissions and access controls. These enhancements provide developers with increased protection against vulnerabilities and malicious attacks, resulting in more secure and resilient applications.
  7. Rapid Development: Tools like Amplication make it much easier to use and develop applications on it with less effort and time.

While some cons of using Node.js are:

  1. Single-threaded: Node.js runs on a single thread, so it may not be suitable for computationally intensive tasks requiring heavy parallel processing. Long-running CPU-bound tasks can block the event loop and negatively impact the application's responsiveness.
  2. Callback Hell: In complex Node.js applications, nesting callbacks can lead to callback hell, making the code harder to read, maintain, and debug. Although this can be mitigated by using Promises, async/await, or adopting more modern JavaScript features.
  3. Immaturity of Some Modules: While the Node.js ecosystem is vast, some modules may be less mature or lacking in terms of stability, documentation, or community support. It's important to carefully evaluate the quality and popularity of your chosen modules to avoid potential issues.

In conclusion, Node.js is an excellent choice for building web applications and APIs due to its exceptional speed, scalability, and JavaScript ubiquity. With its vast ecosystem of libraries, frameworks, and tools available via NPM, developers can rapidly create robust applications. The active and supportive community surrounding Node.js ensures ample resources for learning and problem-solving. While some limitations exist, such as single-threaded execution and potential callback complexities, developers can mitigate them with modern JavaScript features and architectural patterns. Overall, Node.js empowers developers to create high-performance applications efficiently, making it a compelling option for modern web development.

What is Deno?

Deno is a newer JavaScript runtime introduced in 2018 by Ryan Dahl, the same creator of Node.js. Deno is targeting some of the shortcomings of Node.js, including security concerns and the lack of built-in support for modern JavaScript features. Deno is built on the Rust programming language (with Tokio runtime), focusing on default security measures. Deno consists of several components Node.js lacks, such as a built-in module system, support for TypeScript out of the box, and the ability to import modules directly from their URL.

The state of Deno as of 2023 is that Deno has gained significant traction and is becoming a popular alternative for developers, even though Node.js is still the dominant player in building server-side applications. Deno is quickly getting the attention of developers and catching up. Its module system allows dependency management and versioning, an advantage for large-scale projects.

The Pros and Cons of Deno

Noticeable Deno pros include:

  1. Security Posture: Deno's security model is a significant advantage over Node.js. Deno's default security settings ensure that the code runs in a sandboxed environment and that developers must explicitly grant permissions, preventing many security issues that have previously dominated Node.js.
  2. Native TypeScript Support: Deno has built-in support for TypeScript; it took a long time for Node.js to support TypeScript, and it still requires additional configuration and setup. Deno has explicit support for TypeScript out of the box, making it a good choice for developers who prefer static typing.
  3. Modern Module System: Deno's module system leverages ES modules allowing developers to import modules directly from URLs or local file paths. This modern module system provides better compatibility with the web platform. It eliminates the need for a separate package manager, simplifying dependency management and enabling easier code sharing and reuse.

While some cons of using Deno are:

  1. Limited Ecosystem: Compared to Node.js, Deno has a relatively smaller ecosystem of libraries, frameworks, and tools available. While it is growing, the ecosystem may be less extensive, limiting the choices and availability of resources for developers.
  2. Less battle-tested: Since Deno is newer to the technology world, there are significantly fewer projects using it. Its lower usage means that some bugs and issues might still need to be fleshed out, and the overall maturity of the platform is lesser than the Node.js maturity.
  3. Community and Support: Although Deno has an active and growing community, it is less extensive than Node.js. This lack of community can result in fewer resources, tutorials, and community support than the well-established and vast Node.js community.
  4. Compatibility with Existing Node.js Code: Deno's adoption of the ECMAScript modules may introduce compatibility issues with existing Node.js codebases that rely on the CommonJS module system. When migrating or integrating existing projects into Deno requires additional effort and potential refactoring.
  5. Limited Multi-core Utilization: Deno, similar to Node.js, operates on a single thread by default, limiting its ability to utilize multi-core processors fully. Although Deno provides features like Workers for concurrent execution, using multiple cores may require additional manual implementation and coordination.

So, what's the big difference between Node.js and Deno?

Node.js and Deno have significant differences in architecture and features. Some key points to look at here are maturity, security, community support, and TypeScript support.

  1. Node.js is built exclusively on the V8 engine, unlike Deno, which uses the Rust programming language and the Tokio runtime.
  2. Node.js uses the commonJS module system, while Deno uses the ECMAScript module system.
  3. Deno also has a dependency management system with a centralized module system that allows developers to import modules directly from the URLs, a highlight feature in Deno. For example, consider the difference in importing modules, as shown below.
  • Importing modules in Node.js
   const fs = require('fs');
Enter fullscreen mode Exit fullscreen mode
  • Importing Modules from URLs
   import { greet } from 'https://example.com/greeting.ts';
Enter fullscreen mode Exit fullscreen mode

Wrapping Up

All in all, both Node.js and Deno are remarkable frameworks for building server-side JavaScript apps. However, Node.js is still the first choice for most developers over Deno to create server-side JavaScript apps. With a vast community and many companies using Node.js, it constantly evolves with new features; Node.js is still the ultimate game changer in building server-side JavaScript apps.

In our case, the bottom line was that the long list of Node.js pros shaped our decision to choose Node.js over Deno - amazing ecosystem, amazing community, mature battle-tested runtime with so many production projects - it seems that the advantages of Node.js are just much more significant than the shortcomings. Coupled with NestJS, we find it fast, stable, and a perfect fit.

Pro tip: If you're building modernized Node.js apps and services, and are looking for a simple way to develop and maintain your application via microservices, consider using tools like Amplication to rapidly improve your development efficiency and productivity to create faster release times!

Thank you for reading!

Top comments (9)

Collapse
 
valeriavg profile image
Valeria • Edited

It’s quite clear to me that the era of monolithic web applications is over: it’s impossible to compete with cloud micro services and edge computing in performance and scalability.

And that’s where Deno shines: with secure scope it’s incredibly easy to containerise it and run anywhere. I personally enjoy Deno Deploy and run all my personal projects there because it’s cheap, easy and works flawlessly, though it’s not the only option nowadays.

The ecosystem is fairly diverse, given the ability to use npm and quite frankly I think that lack of native support from major cloud providers is the only thing that makes Deno seem not “production ready”.

I understand it might be daunting and not always beneficial to rewrite a whole project from scratch, but this article seems to have slightly outdated view on the state of Deno.

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

Deno is nowhere near production grade. Plus, even when they claim to be faster than Node, last year's benchmarks prove quite the opposite.

Collapse
 
alexmario74 profile image
Mario Santini • Edited

Do you have a link of this benchmark?

Collapse
 
webjose profile image
José Pablo Ramírez Vargas

Not at hand, but search for .Net7's presentation. Microsoft used those benchmarks (from a third party company) to advertise .Net as 11 times faster than NodeJS. If you land the presentation, you'll get to the benchmarks.

Thread Thread
 
alexmario74 profile image
Mario Santini

Thanks I'll check it out. But one thing, you was talking about Deno vs Node, and the presentation is .Net vs Node. It is Deno also considered in the benchmark?

Thread Thread
 
webjose profile image
José Pablo Ramírez Vargas

Yes, it is a benchmark of hundreds of systems. To give you an idea, .Net was #9, NodeJS was 212 and Deno was in the 400's.

Collapse
 
norfeldt profile image
Lasse Nørfeldt

I have been fiddling around with deno. In many ways it it just does things more simple. However I must say that the name "deno" and especially the "fresh" (deno web framework) is rediculously names to search for help. It's actually a much bigger turn off than one might think but will become apparent when getting stuck on a feature.

Collapse
 
quaos profile image
QuaOs

You seemingly forgot to mention the node_modules.

Collapse
 
noherczeg profile image
Norbert Csaba Herczeg

Listing "callback hell" as a con, while explaining, that you can just use async/await seems like a negated argument. If someone is relying on 5+ years old APIs, it's not the language's problem IMO.