DEV Community

Cover image for 🦕 What is Deno?
Tanmay Patil
Tanmay Patil

Posted on • Edited on

🦕 What is Deno?

This article is a great starting point for beginners to Deno.

Covers:

  • About Deno
  • Key Features
  • Example Code
  • Deno vs. Node.js
  • Why Use Deno?
  • Learning Resources

About Deno

Deno is a modern, secure JavaScript and TypeScript runtime, created by Ryan Dahl, the original creator of Node.js. It addresses some of the design shortcomings in Node.js while providing better security and more modern features. Deno was introduced as an alternative to Node.js, with a focus on modern development practices and security.

Image description


Key Features of Deno:

🔐 Security by Default:

Unlike Node.js, Deno is secure by default. It runs scripts in a sandboxed environment and restricts access to the file system, network, environment variables, and other resources unless explicitly allowed with command-line flags (e.g., --allow-read, --allow-net).

📦 Supports TypeScript Out-of-the-Box:

Deno has built-in TypeScript support without the need for configuration or a separate compilation step. It directly interprets .ts files, making TypeScript development easier and more seamless.

🤯 No node_modules:

Yup you heard it right!
Deno does not use a node_modules folder or a package manager like npm. Instead, it uses standard URLs to import third-party modules. This makes dependency management simpler and reduces the complexity around dependency trees.

import { serve } from "https://deno.land/std@0.105.0/http/server.ts";
Enter fullscreen mode Exit fullscreen mode

🛠️ Built-In Tooling:

Deno comes with several built-in tools, such as a test runner (deno test), a code formatter (deno fmt), a linter (deno lint), and more. This reduces the need for additional tooling.

📀 Single Executable:

Deno is distributed as a single executable binary, making installation simpler across various platforms.

Standard Modules:

Deno provides a standard library of modules hosted on its official platform (deno.land/std). These modules follow consistent and predictable standards for building applications.

🫱🏼‍🫲🏻 Promise-Based APIs:

Many of Deno's APIs are modern and built around promises, eliminating older callback-based patterns that are still prevalent in Node.js.

⚙️ ES Modules by Default:

Deno uses ECMAScript (ES) modules as the default module system, instead of CommonJS used by Node.js. This makes it compatible with modern JavaScript standards and avoids the require and module.exports syntax used in Node.js.

Example Deno Code:

import { serve } from "https://deno.land/std@0.105.0/http/server.ts";

const server = serve({ port: 8000 });
console.log("HTTP server is running on http://localhost:8000");

for await (const req of server) {
  req.respond({ body: "Hello, Deno!" });
}
Enter fullscreen mode Exit fullscreen mode

Differences Between Deno and Node.js:

Security: Deno is sandboxed by default, requiring explicit permission for network, file system, etc., while Node.js runs without such restrictions.

Module System: Deno uses ES modules and URLs for imports, while Node.js uses CommonJS and a node_modules system.

TypeScript Support: Deno has native TypeScript support without configuration, whereas in Node.js, you need to set up TypeScript with tools like ts-node or babel.

No package.json or npm: Deno does not rely on a package manager, and you import modules via URLs instead of a centralized package repository like npm.


Why Use Deno?

Security: If your project requires a secure-by-default environment.

Modern Development: For developers who want to take advantage of TypeScript out-of-the-box, modern JavaScript standards, and native ES module support.

Simpler Tooling: Built-in testing, linting, and formatting reduce the need for external packages.


Let me know what part of this topic would you like me to cover in-depth.


Here are some valuable resources to help you learn more about Deno, along with their full links:

Deno's Official Documentation
A comprehensive guide covering Deno's APIs, setup, tutorials, and examples.
https://deno.land/manual

Deno by Example
A collection of practical, runnable examples that teach you Deno’s important features.
https://examples.deno.land/

Fresh Framework
A modern web framework for Deno designed for speed and simplicity.
https://fresh.deno.dev/

Deno Deploy
Learn how to deploy Deno applications using Deno's serverless hosting platform.
https://deno.com/deploy

Deno KV
Information on building stateful applications using Deno KV, a database system built for Deno.
https://deno.com/blog/kv-release

Better Stack Guide: Deno Overview for Node.js Users
A guide specifically aimed at Node.js developers transitioning to Deno, covering key differences and features.
https://betterstack.com/community/guides/deno-overview

These links provide the essential resources to dive into Deno development!

Last but not the least, do support with a like and share if at all you got to learn something new from this. 🫶🏼

Top comments (2)

Collapse
 
gidr profile image
Gideon Raj

Thanks

Collapse
 
fullstacktanmay profile image
Tanmay Patil • Edited

You're welcome! Also let me know if you have any feedback, thanks!