Good front-end programmers to share what is Deno, the difference between it and the Node.js

  Good front-end programmers to share what is Deno, it Node.js difference , Node.js creator Ryan Dahl spent a year and a half study Deno , this is a new JavaScript running, you can solve all the inherent Node problem.

  Do not get me wrong, the Node JS which itself is a great server-side JavaScript runtime, mainly because it has a very large ecosystem and JavaScript. However, Node.js creator Ryan Dahl admitted that he should consider more - safety, modules and dependencies, to name a few.

  In his defense, the platform does not mean that he can imagine in such a short period of time will increase the number. In addition, early in 2009, JavaScript is still this strange little language, everyone made fun of, but many of its features yet.

  So what is Deno, the main characteristics of what is it?

1.  Deno is a V8-based security built in TypeScript of Google runtime engine.

  It establishes:

Rust (Deno's core is written in Rust, node written in C ++)

Tokio (Rust written to the event loop)

the typescript (Deno support JavaScript and typeScript out of the box)

(when used in Google Chrome and node in JavaScript be) V8

  2. It supports T the y- pe2.8 out of the box, no Package Penalty for. J Son, no npm not compatible with the pursuit of Node, by URL introducing dependent manner instead, and loaded and cached on the first run through the local module , and is used only to run the code, will depend update.  

can control the file system and network access to run the sandboxed code access to the default read-only file system access, no network access. Access between the V8 and Golang message can only be done by a sequence of protobuf defined;

finally create a single executable file;

supports the  top-level  of  the await ;

ultimate goal is compatible browser;

can be introduced as a library, used to build their own  JavaScript Runtime .

  These features, there are many more were present for  the Node Js pain point comes, including non  package.json introduction and update mode, dependent for is widely Tucao too large. 

  At the same time, no longer pursue compatible  node , it can be considered  ry  want to completely abandon the  node  burden, to create a better  JS  run time.

Its security is very reassuring, one of its most important functions is highly secure, and NodeJs contrary, Deno default sandbox code execution, which means running is not authorized to access.

Let's look at how it works:

  (async () => {

   const encoder = new TextEncoder();

   const data = encoder.encode('Hello world');

   await Deno.writeFile('HelloWorld.txt', data);

   await Deno.writeFile(' HelloWorld2.txt', data);

  })();

  The script creates two text file containing a message. The code is being executed in the sandbox, so it can not access the file system. HelloWorld.txt HelloWorld2.txt Hello world

  Please also note that we are using Deno namespace rather than fs module, as in Node as in. Deno namespace provides many basic helper functions. By using namespaces, we are losing browser compatibility .

  当然我们用到Deno的时候,会想到浏览器的兼容性,Deno旨在浏览器兼容。从技术上讲,在使用ES模块时,我们不必使用任何构建工具(如webpack)来使我们的应用程序啊可以在浏览器中使用。

  但是像Babel这样的工具会将代码转换成ES5版本的JavaScript,因此 即使在不支持该语言所用最新功能的旧版浏览器中,代码也可以运行。但这也是最终文件中包含大量不必要的代码并使输出文件膨胀为代价的。

  由我们决定我们的主要目标是什么,并相应地做出选择。

TypeScript支持开箱即用

  Deno使得无需任何配置文件即可轻松使用TypeScript。仍然可以用纯JavaScript编写程序并使用Deno执行它们而不会有任何麻烦。

  DenoTypeScriptJavaScript的新运行时,是一个有趣的项目,现在已经稳定增长了很长一段时间。但是在它被认为是生产就绪之前还有很长的路要走。

借助它的分散式方法,它需要从集中式软件包注册表(即npm)中释放JavaScript生态系统。



Guess you like

Origin blog.51cto.com/14256902/2424576