Lesson 1: Introduction to Deno
In this first lesson, we will cover the basics of Deno, including what it is, its key features, how to install and set it up, and how to write your first “Hello World” example in Deno.
What is Deno and why use it?
Deno is a secure, modern, and JavaScript/TypeScript runtime designed to build scalable and maintainable web applications. It was created by Ryan Dahl, the same developer who created Node.js, with the goal of addressing some of the limitations and security concerns of Node.js.
Key features of Deno and how it differs from Node.js
Some of the key features of Deno that make it different from Node.js include:
- Secure by default: Deno provides a secure runtime environment without needing additional configurations.
- Built-in TypeScript support: Deno allows developers to write code using TypeScript instead of JavaScript.
- No package manager needed: Deno allows developers to import modules directly from URLs and caches them locally to prevent repeated downloads.
- Enhanced module system: Deno’s module system allows for more flexible and efficient code organization and loading.
Installation and setup
To use Deno, you will need to install it on your operating system. Here are the steps to follow:
- Go to the Deno website at https://deno.land/
- Click on the “Installation” button on the homepage.
- Follow the installation instructions for your operating system.
Once you have installed Deno, you can check the installation by running the following command in your terminal:
deno --version
This will display the version of Deno that you have installed.
Writing a “Hello World” example in Deno
Now that you have Deno installed, let’s write our first Deno script. In Deno, scripts are written using JavaScript or TypeScript and are run using the deno command.
Here’s an example “Hello World” script in Deno:
console.log("Hello, Deno!");
To run this script, save it as a .ts
file, for example, hello.ts
, in a directory on your computer.
Then, navigate to that directory in your terminal and run the following command:
deno run hello.ts
This will execute the script and output the message “Hello, Deno!” in the terminal.
Wrap-up
Congratulations, you have written and executed your first Deno script!
In this lesson, we covered the basics of Deno, including what it is, its key features, how to install and set it up, and how to write your first “Hello World” script in Deno.
In the next lesson, we will explore Deno’s runtime architecture and how it works.