Deno is a program that allows you to run JavaScript and TypeScript programs. Deno is a direct successor to Node.js and in fact Deno was written by the guy who wrote Node.js.
I started working on a small project that uses Deno so my first step was to install Deno and get a Hello World program up and running.
Installing Deno using the Choclately program.
Installing Deno was quick and easy. I use Windows and so I decided to use the Chocolatey installer system to install Deno. First I installed Chocolately. I opened a PowerShell shell with Administrator privileges and issued the command “Set-ExecutionPolicy AllSigned”. Then I installed Chocolatey with the hideous command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))
Next, I opened a regular CMD shell with Administrator privileges. I installed Deno using the beautifully simple command:
choco install deno
Now I was ready to try a Hello World program for Deno. First I used JavaScript. I opened Notepad and created a file hello.js based on the Deno documentation example:
// hello.js // Deno can run JavaScript function capitalize(word) { return word.charAt(0).toUpperCase() + word.slice(1); } function hello(name) { return "Hello " + capitalize(name); } function main() { console.log(hello("adam")); console.log(hello("Barb")); console.log(hello("CARL")); } main()
I ran the program by typing the command
deno run hello.js
Nice. Simple.
Then I created a hello.ts TypeScript equivalent version of the program and ran it to prove that Deno can run TypeScript without having to manually transpile it to JavaScript. Very Nice!
// hello.ts // Deno can run TypeScript directly function capitalize(word: string): string { return word.charAt(0).toUpperCase() + word.slice(1); } function hello(name: string): string { return "Hello " + capitalize(name); } function main() { console.log(hello("doug")); console.log(hello("Evan")); console.log(hello("freD")); } main()
In my opinion, Deno is a big improvement over Node.js in many ways. I especially like Deno’s no-need-to-transpile TypeScript, integrated package manager (no need for NPM), direct use of ES6 modules, integrated security, and module handling. I hope Deno overcomes the massive head start that Node.js has. Computer science is continuously evolving and maybe Deno will be part of that evolution (or maybe not).
Art is continuously evolving. Four illustrations by artist Mads Berg. His style is sort of an evolved form of 1920s art deco.
You must be logged in to post a comment.