deno crate organization
anthonyCampolo
@ajcwebdev
Craig Morten
@CraigMorten
• How to publish Deno modules

• How To Bundle Code For Deno Web Applications

• Guide To Porting Node Modules To Deno

• Countdown Of The Top Package Registries For Deno

• What Is The Best Deno Web Framework?

• Opine Tutorial Part 2: Creating A Website In Deno

• Running Code From READMEs In 10 Lines Of Deno

• Proxy Middleware For Deno

• Testing Your Deno Apps With Mocha

• GitHub Actions With Deno
an·a·gram
/ˈanəˌɡram/
Noun

• a word, phrase, or name formed by rearranging the
letters of another, such as cinema, formed from iceman.
secure
runtime
for
javascript
and
typescript
“JavaScript has changed quite a bit in the
last 10 years since I originally sat down to do
Node.”
-Ryan Dhal
10 (8) Things Ryan Regrets about Node
• Not sticking with Promises

• Security

• The Build System: GYP

• package.json
• require("somemodule") is not specific

• node_modules

• require("module") without the
extension “.js"

• index.js
Node is fundamentally divergent
from the standardization of
JavaScript since ES2015
Node has too much access to
the computer it's running on
The module/package system is a
bit of a nightmare
"I imagine him standing in the rain at night - 

stoically facing the dark battle that is software engineering.”

-hashrock
Deno Principles
Secure by default
• No file, network, or environment access, unless explicitly enabled

Supports TypeScript out of the box
Ships only a single executable file
Built-in utilities
• Dependency inspector (deno info) and code formatter (deno fmt)

Standard modules
• Audited and guaranteed to work with Deno: deno.land/std
Origins
• In 2015 it was a project called V8 worker which was
a binding to V8 and Go.

• The idea was to disallow Go programmers from
using V8's APIs to create random JS objects.

• Instead they would be forced into a message
passing system that would pass messages
between Go and V8.
why avoid
monolithic
design?
Better separation of concerns inside the CLI
• Sub-systems can be tested independently

• Provides principled binding layer for CLI
Many use cases for embedding a JS VM
• Web servers customizable with JS (serverless)

• Databases using JS for map-reduce

• GUI applications like Electron
Rust Crates
Unlike Node, a monolithic project, Deno is organized into a collection of Rust crates
deno

• Deno executable

deno_typescript

• Type-checking and type-stripping at compile-time

deno_core

• Ops and resources

rusty_v8

• Rust interface to V8
rusty_v8
rusty_v8
V8 is a C++ library with 800,000 lines of code
rusty_v8 is a framework for adding bindings to V8
• Zero cost Rust interface to V8

• Safe bindings to V8

• Ability to recompile V8 with different compilation settings
Zero cost Rust interface to V8
• Objects manipulated in rusty_v8 are exactly the objects in C++
Safe bindings to V8
• The type system forces Local handles to be created in a HandleScope

• Isolates are pegged to a thread for optimal usage
Ability to recompile V8 with different compilation settings
• Prebuilt binaries created through github actions are provided for most users

• V8 source code is distributed inside a crate file. It does not depend on depot_tools
deno_core
deno_core
Node Problems
• No centralized binding interface in Node means no way to monitor metrics or
perform security checks.

• Many callbacks are issued from C++ without being requested from the JS
side giving users the opportunity to create code without back pressure.
Deno Solutions
• Native bindings are done through “Ops”, native functions called from JS.

• Everything in the executable is built on ops, which provides superior
performance to Node.
Binary data
• Parameters and return value are ArrayBuffers

• ArrayBuffer object is used to represent a generic, fixed-length raw binary data
buffer
Zero-copy
• ArrayBuffers pass pointers back and forth between JS and Rust
Integrated with event loop
• An op either completes synchronously with a result or returns a promise
corresponding to a Rust Future
Resources
• Similar to a file
descriptor in POSIX.

• It is an integer identifier
given to JS to reference
some object allocated in
Rust such as an open
socket or file.

• Resources are stored in
the resource table and
are removed from the
table by Deno.close()
deno
Goals
Only ship a single executable (deno)
Provide Secure Defaults
• Unless specifically allowed, scripts can't access files, the environment, or the network

Browser compatible
• Subset of Deno programs which are written in JS and don’t use the global Deno
namespace should run in a modern web browser without change

Provide built-in tooling
• Unit testing, code formatting, and linting to improve developer experience

Does not leak V8 concepts into user land
Be able to serve HTTP efficiently
deno_typescript
deno_typescript
deno_core is JS-only
• deno_typescript is where the TypeScript compiler is incorporated.

• This is currently a work in progress and should not be used in production.

Deno Crate Organization

  • 1.
  • 2.
    Craig Morten @CraigMorten • Howto publish Deno modules • How To Bundle Code For Deno Web Applications • Guide To Porting Node Modules To Deno • Countdown Of The Top Package Registries For Deno • What Is The Best Deno Web Framework? • Opine Tutorial Part 2: Creating A Website In Deno • Running Code From READMEs In 10 Lines Of Deno • Proxy Middleware For Deno • Testing Your Deno Apps With Mocha • GitHub Actions With Deno
  • 3.
    an·a·gram /ˈanəˌɡram/ Noun • a word,phrase, or name formed by rearranging the letters of another, such as cinema, formed from iceman.
  • 4.
  • 5.
    “JavaScript has changedquite a bit in the last 10 years since I originally sat down to do Node.” -Ryan Dhal
  • 6.
    10 (8) ThingsRyan Regrets about Node • Not sticking with Promises • Security • The Build System: GYP • package.json • require("somemodule") is not specific • node_modules • require("module") without the extension “.js" • index.js
  • 7.
    Node is fundamentallydivergent from the standardization of JavaScript since ES2015
  • 8.
    Node has toomuch access to the computer it's running on
  • 9.
    The module/package systemis a bit of a nightmare
  • 10.
    "I imagine himstanding in the rain at night - stoically facing the dark battle that is software engineering.” -hashrock
  • 11.
    Deno Principles Secure bydefault • No file, network, or environment access, unless explicitly enabled Supports TypeScript out of the box Ships only a single executable file Built-in utilities • Dependency inspector (deno info) and code formatter (deno fmt) Standard modules • Audited and guaranteed to work with Deno: deno.land/std
  • 12.
    Origins • In 2015it was a project called V8 worker which was a binding to V8 and Go. • The idea was to disallow Go programmers from using V8's APIs to create random JS objects. • Instead they would be forced into a message passing system that would pass messages between Go and V8.
  • 13.
  • 14.
    Better separation ofconcerns inside the CLI • Sub-systems can be tested independently • Provides principled binding layer for CLI Many use cases for embedding a JS VM • Web servers customizable with JS (serverless) • Databases using JS for map-reduce • GUI applications like Electron
  • 15.
    Rust Crates Unlike Node,a monolithic project, Deno is organized into a collection of Rust crates deno • Deno executable deno_typescript • Type-checking and type-stripping at compile-time deno_core • Ops and resources rusty_v8 • Rust interface to V8
  • 16.
  • 17.
    rusty_v8 V8 is aC++ library with 800,000 lines of code rusty_v8 is a framework for adding bindings to V8 • Zero cost Rust interface to V8 • Safe bindings to V8 • Ability to recompile V8 with different compilation settings
  • 18.
    Zero cost Rustinterface to V8 • Objects manipulated in rusty_v8 are exactly the objects in C++ Safe bindings to V8 • The type system forces Local handles to be created in a HandleScope • Isolates are pegged to a thread for optimal usage Ability to recompile V8 with different compilation settings • Prebuilt binaries created through github actions are provided for most users • V8 source code is distributed inside a crate file. It does not depend on depot_tools
  • 19.
  • 20.
    deno_core Node Problems • Nocentralized binding interface in Node means no way to monitor metrics or perform security checks. • Many callbacks are issued from C++ without being requested from the JS side giving users the opportunity to create code without back pressure. Deno Solutions • Native bindings are done through “Ops”, native functions called from JS. • Everything in the executable is built on ops, which provides superior performance to Node.
  • 21.
    Binary data • Parametersand return value are ArrayBuffers • ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer Zero-copy • ArrayBuffers pass pointers back and forth between JS and Rust Integrated with event loop • An op either completes synchronously with a result or returns a promise corresponding to a Rust Future
  • 22.
    Resources • Similar toa file descriptor in POSIX. • It is an integer identifier given to JS to reference some object allocated in Rust such as an open socket or file. • Resources are stored in the resource table and are removed from the table by Deno.close()
  • 23.
  • 25.
    Goals Only ship asingle executable (deno) Provide Secure Defaults • Unless specifically allowed, scripts can't access files, the environment, or the network Browser compatible • Subset of Deno programs which are written in JS and don’t use the global Deno namespace should run in a modern web browser without change Provide built-in tooling • Unit testing, code formatting, and linting to improve developer experience Does not leak V8 concepts into user land Be able to serve HTTP efficiently
  • 26.
  • 27.
    deno_typescript deno_core is JS-only •deno_typescript is where the TypeScript compiler is incorporated. • This is currently a work in progress and should not be used in production.