I haven't found any other developers on YouTube with a channel the size of codedamn (100K+ subscribers) who are not not "super excited" about the release of Deno.
Mehul Mohan
What is Deno?
Have you heard all the buzz about the new backend javascript framework called deno? To know what Deno is, you first need to know a little about where it came from - enter node.
History of Node
The Node project was started back in 2009, to bring javascript out of the browser and put it on the server. It's used by essentially all front end frameworks and in someway or another every website is using node.
It leverages the broad adoption of javascript by developers to help front end developers work with the backend code. With wonderful tools like node package manager (NPM) built in, it allows installing and creating projects that would otherwise be painful or time intensive with a "plugin" like feel but there are security concerns as well as lack of built in support for the latest and greatest.
Since 2009, the javascript landscape has improved a ton with things such as ArrayBuffer, async/await, ES modules, WASM, and TypeScript most of which require packages on packages installed from npm to work around.
In 2018, the creator of Node.js Ryan Dahl, had been working on improving this system and developed an alternative called "deno".
Why deno?
Like Node, it allows you to execute javascript outside of the web browser, leverages the open source chrome V8 engine and it's designed to appeal to the broadest audience of developers with standard APIs.
Instead of being written in c++ it's written in rust and has built-in development tools like testing, linting, formatting, document gen.
Deno is a simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust.Secure by default. No file, network, or environment access, unless explicitly enabled.
Supports TypeScript out of the box.
Ships only a single executable file.
Has built-in utilities like a dependency inspector (deno info) and a code formatter (deno fmt).
Has a set of reviewed (audited) standard modules that are guaranteed to work with Deno: deno.land/std
Source: https://deno.land/
Like node, it was created by Ryan Dahl and you can see him give a virtual talk on it here: https://www.youtube.com/watch?v=doug6st5vAs
Is Node Dead?
In my personal opinion, I don't see node going any where any time soon due to it's:
- broad adoption
- resistance to change from systems already in place
- Education (people don't know it or about it as broadly - yet).
Learning this framework will likely open up new opportunities at startups or provide a secure foundation for creating new applications in the future but not likely worth trying to change everything over to from node if you are already established there.
Deno seems like a big undertaking for a small benefit with a huge debt of transferring existing npm modules and codebases.
@mehulmpt
I would say, if you are starting out in your coding journey, start with node as more jobs will be looking for it as a skillset but don't write this off - it will be valuable later and learning it now may put you ahead of the game.
My thoughts revolve around imagining being an early adopter of node and how many jobs would have opened up around that skill set earlier on.
Why should we use it?
If you boiled it down, deno is:
- TypeScript
- Node (minus NPM)
- A docker container that is correctly configured
- Single executable binaries
- Formatting tools (among others)
- No centralized package manager (like NPM which comes with node)
Deno is a browser for command line scripts (a command line utility). It makes programming easy by letting you import and run code straight from the internet instead of having to run npm i express
then at the top of a javascript file having to write import react from 'react';
you actually just use the actual URL for the from statement which is much faster.
That sounds cool but how can you trust this? The same argument comes with pulling from a random npm package. The real benefit here is that you are pulling code from an explicit end point so it's important to note that Deno is also a secure sandbox which can optionally reach into the operating system files when explicitly given permissions.
You can see this in action at about the 7 minute mark in Ryan's talk.
Installation
Install Brew
This guide was written for mac users. See deno_install for more installation options.
If you haven't already got it, I recommend installing home brew. Open up a terminal and run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
After that installs, run brew install deno
.
You can open up finder and press ⌘⇧·
to view hidden folders and navigate to /usr/local/Cellar/
chances are this is also where node is installed. Navigate to deno
directory, then the version number folder (in my case its 1.1.2
at the time of writing this) then open the bin
directory and you should see an executable file called "deno". Open that up.
When you do, this will open up the command line utilities for deno.
You are now in a "REPL" (Read Eval Print Loop) just like if you ran node or were in the console of your browser.
You can exit out of the deno REPL using ⌃d
(control + d).
In the future, you can access this directly by just typing deno
in the terminal instead of searching through the files, but it's good to know where it's installed for future reference.
Set up your Editor
Set up your IDE for deno
I use visual studio code and recommend using it if you aren't already.
There is an official VS code extention called "Deno" you can find here: https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno
This plugin can resolve URLs in your import statements as local paths.
Create a js file in your editor and call it helloworld.js. Begin editing the file and create a simple function.
function hello(){ console.log('Hello World'); } hello();
Click on the title bar of visual studio code and select terminal > new terminal.
We are going to use the run
command in deno to "Run a program given a filename or url to the module" - the really cool part here is the "url" bit which we will see in a later article.
In the terminal run deno run helloworld.js
You should now see "Hello World" in the command line. Compared to Node, this isn't too different and you're probably thinking, this isn't very exciting.
Not impressed yet? Hold onto your butts!
Another cool feature is that TypeScript is built into deno so you can create a typescript file called helloworld2.ts
with something simple like:
const hello:string = 'Hello World'; console.log(hello);
Let's run that and see what happens: deno run helloworld2.ts
Woah now in your terminal, you should now see that it compiled that typescript file and ran it as javascript. Not to mention quickly! (I know it's a small file ha).
This is something you cannot do out of the box with node!
Next...
In my next article we will look at deno under the hood. If you found this article helpful, give me a shout on twitter @codingwithdrewk or if you find any errors, feel free to highlight them and mash that R button the right side of the screen.
Logo source: https://deno.land/logo.svg
Drew is a seasoned DevOps Engineer with a rich background that spans multiple industries and technologies. With foundational training as a Nuclear Engineer in the US Navy, Drew brings a meticulous approach to operational efficiency and reliability. His expertise lies in cloud migration strategies, CI/CD automation, and Kubernetes orchestration. Known for a keen focus on facts and correctness, Drew is proficient in a range of programming languages including Bash and JavaScript. His diverse experiences, from serving in the military to working in the corporate world, have equipped him with a comprehensive worldview and a knack for creative problem-solving. Drew advocates for streamlined, fact-based approaches in both code and business, making him a reliable authority in the tech industry.