JMF Labs LogoJMF Labs
HomeArticles

Deno JS the Future of Javascript Development

deno logo Can Deno change javascript runtimes for the better or it something that the nodejs community just doesn’t need at this time?

Nodejs is about a decade old and some of the first design choices are now showing their age. Like the module system, typing, and guard rails.

A big feature is a native typescript compiling. Most backend code that is written by our team is in typescript. Anyone that has setup typescript, knows it is a process or has some boilerplate for setting up. But to have native compiling for typescript get developers writing code faster.

Another awesome feature is the guard rails. No more wild west, Deno requires you to explicitly allow each run to read/write files or make internet calls. This is great for javascript build systems and cloud systems. Where you want to limit the abilities of bad actors coming in as a good actor.

Our current assumption is it is great to test with, maybe build a build system with it. The future looks bright for it and for sure to keep it on the watch list.

Here is some an example code to get started...

First we need to install deno

Using the shell installer

1
curl -fsSL https://deno.land/x/install/install.sh | sh

or

using brew

1
brew install deno

Now you should be able to do

1
deno --version

to make sure you have it working.

As pointed out we can now import external code snippets safely like we would in javacript in the browser.

1
deno run https://deno.land/std/examples/welcome.ts

which is really just

welcome.ts

1
console.log("Hello Deno 🦕");

now lets implement an easy to use file reader program in deno.

output.ts

1
2
3
4
5
6
for (let i = 0; i < Deno.args.length; i++) {
  let filename = Deno.args[i];
  let file = await Deno.open(filename);
  await Deno.copy(file, Deno.stdout);
  file.close();
}

As you can see we don't need another library to read in the arguments or to open the file. Once we save it we can run it like so...

1
deno run --allow-read output.ts test.txt

Remember we need to explicitly give permission to deno to allow it to read the filesystem. And you have now written your first deno program.explicitly

If you need typescript or deno help please contact us

Still need help?

Thank you, you will hear back from us shortly!

Your Name (Required):

Your Email (Required):

Submit!