Deno (software)

from Wikipedia, the free encyclopedia
Deno

Deno.svg
Basic data

Maintainer Ryan Dahl
developer Ryan Dahl
Publishing year 05/13/2018
Current  version 1.0.5
(June 3rd, 2020 )
Current preliminary version 1.0.0-rc3
(05/12/2020)
operating system Linux , MacOS , Windows
programming language TypeScript , JavaScript , Rust , C ++
category Runtime environment
License MIT license
deno.land

Deno is a runtime environment for JavaScript and TypeScript based on the V8 JavaScript engine and written in Rust . It was developed by Ryan Dahl created, the original creator of Node.js . It was announced by Dahl in 2018 in his lecture "10 Things I Regret About Node.js" (German: "10 things that I regret about Node.js"). Deno combines both runtime environment and package management in one program.

history

Deno was announced by Ryan Dahl at JSConf EU 2018 in his lecture "10 Things I Regret About Node.js" (German: "10 things that I regret about Node.js"). In the lecture Ryan describes that he regrets some design decisions with Node.js , that he does not use any promises in the API design, using the legacy GYP building system, the node_modules folder and the package.json, omitting filename extensions , the automatic one Module resolution with the index.js and the resolution of the sandbox from V8 . Finally, he presented the Deno prototype.

Deno was originally written in Go , but was soon replaced by Rust . This was due to concerns about the double runtime environment (that of Go and Deno themselves) and garbage collection .

In November 2018, a standard library was created based on the Go standard library, which provided extensive tools to solve problems with the Node.js dependency trees.

Deno version 1.0 was released on May 13, 2020.

Comparison with Node.js

Deno and Node.js are both runtime environments based on Google's V8 JavaScript engine, which is also used in Google Chrome . Both have internal event loops and can be called from the command line to execute scripts and auxiliary commands.

They differ mainly in the following points:

  1. Deno uses ES Modules as a standard module system instead of CommonJS .
  2. Deno uses URLs for dependencies , similar to web browsers .
  3. Deno has an integrated package manager, so npm is not required.
  4. Deno naturally supports TypeScript
  5. Deno is more compatible with browsers and supports a wide range of web APIs.
  6. Access to the file system and network can be controlled through the sandbox in Deno.
  7. Deno supports Promises, ECMAScript ES6 and TypeScript.
  8. Despite the large standard library, Deno has a smaller core size.
  9. Deno uses special message channels for system access.

use

The following command executes the TypeScript file main.ts without read, write or network access ( sandbox mode):

deno run main.ts

Access to the file system or network can be granted via certain attributes:

deno run --allow-read --allow-net main.ts

To display the dependency tree of the script, the infosubcommand can be used:

deno info main.ts

A simple hello world program looks like this in Deno (as well as in Node.js) (this could e.g. be in main.ts):

console.log("Hello world");

In order to use Deno's own API, a special, global namespace is used that does not exist in browsers. The Unix cat program could be programmed as follows:

/* cat.ts */

/* Deno APIs werden über den Namensraum `Deno` bereitgestellt. */
const { stdout, open, copy, args } = Deno;

// await wird auf oberster Ebene unterstützt
for (let i = 0; i < args.length; i++) {
    const filename = args[i]; // Enthält das Kommandozeilenargument
    const file = await open(filename); // Öffnet die entsprechende Datei zum Auslesen
    await copy(file, stdout); // Führt ein asynchrones kopieren von `file` nach `stdout` durch.
}

The Deno.copyfunction above works like Gos io.Copy, while stdout(standard output) is the destination and filethe source. In order to run the program, read rights are required on the file system:

deno run --allow-read cat.ts myfile

The following Deno script implements a simple HTTP server :

// Importiert `serve` von der Deno Standardbibliothek über eine URL.
import { serve } from "https://deno.land/std@v0.21.0/http/server.ts";

// `serve` Funktion gibt einen asynchronen Iterator zurück, der nach und Nach die Anfragen zurück gibt
for await (const req of serve({ port: 8000 })) {
    req.respond({ body: "Hello World\n" });
}

When the program runs, Deno automatically loads the standard library down and cachet them and compiles the code.

Web links

Individual evidence

  1. Contributors, denoland / deno, Github. Retrieved July 5, 2019 .
  2. Releases · denoland / deno. Retrieved June 3, 2020 .
  3. Deno 1.0.0-rc3. In: GitHub . Retrieved May 12, 2020 (English).
  4. deno / LICENSE at master. In: GitHub. Retrieved July 5, 2019 .
  5. ^ The MIT License. In: Open Source Initiative. September 17, 2018, accessed on September 17, 2018 .
  6. Deno: Secure V8 TypeScript Runtime from Original Node.js Creator. In: InfoQ. Accessed May 17, 2019 .
  7. a b c Silke Hahn: Web development: Deno 1.0 is supposed to replace Node.js as a framework for scripting languages. May 14, 2020, accessed June 6, 2020 .
  8. a b 10 Things I Regret About Node.js - Ryan Dahl - JSConf EU 2018. June 6, 2018, accessed on May 17, 2019 (English).
  9. a b Deno Manual. In: deno.land. Accessed May 17, 2019 .
  10. ^ Paul Krill: Ryan Dahl's Node.js regrets lead to Deno. InfoWorld , June 21, 2018, accessed June 6, 2020 .
  11. Ryan Dahl: Design mistakes in Node. In: Github. June 6, 2018, accessed June 6, 2020 .
  12. denoland / deno, branch "golang". In: Github. Retrieved June 6, 2020 .
  13. suggestion: Look into porting to Rust and using Tokyo. In: GitHub. Retrieved June 6, 2020 .
  14. Deno Standard Modules. In: Github. Retrieved June 6, 2020 .
  15. Deno 1.0. In: deno.land. Retrieved May 14, 2020 .