Deno is 1: behind the Node.js-Alternative the Dino in the Logo

Ryan Dahl wanted to do was make Deno ten things better, like him node.js . On Wednesday, the alternative Runtime for JavaScript and TypeScript Version 1.0 has been reached. We have looked at the Node-Alternative precisely.

Deno is Node.js – a runtime environment for JavaScript. Just like Node.js Deno provides a way to write server – side JavaScript or TypeScript. It is similar to Node.js in its scope of function in many ways, uses exactly how Node, the V8 JavaScript Engine under the hood, and was even called by the same Person, which is Node. Unlike Node Deno has been implemented but not in C++ and JS, but in Rust and TypeScript. This means for you: you can directly write in Deno statically typed Code, without ever a TS-config.to have a json-file only to touch – you can to all the Features within the Runtime from the Deno-the Namespace to access.

Built-In Security

Deno comes by default with some Security precautions.

Suppose you want about console.log( Deno.cwd() ) the current Working Directory logout. Such scripts can via deno run on the command line does not run, however, to grant, without the prior permission of the implementation of such actions within the Runtime. In this particular case, we reach the –-allow-read-flag:

deno run --allow-read main.ts

Behind it there is a thing called Sandbox, which prevents programs from doing things that you don’t want to allow plugged in. This is useful if you want to run a JS program outside of the browser, but don’t want it accesses within your system to all sorts of things.

In Node.js there is nothing that a Node.js-App prevents you from, for example, your SSH Keys and you to a Server. On the other hand can protect yourself, who pays attention to only install packages from trusted authors. A bit of a security risk is there but still, these packages can also be hacked.

By means of the Sandbox Deno replicated the Permission model of the browser – the Browser that is running JS requires your explicit permission for the execution of any action on your System. More Flags, on the Deno permits can provide, for example --allow-write or --allow-net.

Bye Callback hell: Promise-Handling with top-level-await

One thing that TypeScript will delight users, is that Deno – how to implement TypeScript since V 3.8 – top-level-await.

In Deno you can about the fetch API, a Network Request is running – as you would be in the Browser:

const res = await fetch( ‘https://t3n.de’ );

And because Deno top-level-supports await, you need not even a asyncFunction.

Browser-compatible Events

Deno want to make your Code cross-browser compatible as possible. The Runtime includes windowObject Lifecycle Events,

window.onload = event => console.log( ‘t3n says hi  ’ )

the Event-Listener schedule can. This makes it possible to write Code that can be run in both the browser and on the server side.

Deno is WebAssembly-compatible

Deno can run also WebAssembly Binaries.

const wasmBinary = new Uint8Array([ 0, 23, 77]);

const wasmModule = new WebAssembly.Module(wasmBinary);

 

npm-packages ♀️

One thing that does not work in Deno, however, are npm packages. Deno Runtime and Package Manager is in a and not with the separate package Manager compatible. In Deno your packages, you can, instead, by means of IT-in modules import Syntax via the URL, for example, like this:

import { serve } from ‘ https://deno.land/std/http/server.ts’ ;

Remote Modules are referenced via URL. If you are executing a script the first Time, is stored in the Code locally and cached. There is no package.json. Code can be referenced on each URL, similar to how it works in the Browser.

Standard Library

Deno has a selection of Standard modules for common Use Cases. For example, you can, like in the above example, the http module serve import and use it to create a Server that is managed as an async Iterable:

// main.ts

import { serve } from ‘https://deno.land/std/http/server.ts’;

 

const s = serve({ port: 8000 });
for await (const req of s)
req.respond( {body: ‘Deno   is cool’} );

 

Run on you All then deno run --allow-net main.ts 

Conclusion

Deno was on Wednesday in V 1.0 released. In the short term, the Runtime node.js will not replace safe. Node creates a closed Ecosystem, which is now relatively stable. Whether the JavaScript developer Community will turn to the longer term, for the benefit of the Dinos from node.js remains to be seen. Who wants to look at the Runtime, more precisely, on the Website of the project in addition to a Blogpost to V 1.0 a detailed Manual, the Standard Library and all of the previously supported Third-Party modules.

To read More: Web Development now and later: 3 ½ predictions, you need to read

This could also interest you

Ready to see us in action:

More To Explore

IWanta.tech
Logo
Enable registration in settings - general
Have any project in mind?

Contact us:

small_c_popup.png