SlideShare a Scribd company logo
1 of 37
Deno
Ryan Dahl
2019.04.04
Kiev, Ukraine
Disclaimer
This talk is aimed at experienced enthusiasts
If this isn't you: Don't Panic
Ignore this talk - use Node. Node isn't going anywhere!
Deno is a new command-line runtime
for executing JavaScript and TypeScript
Primarily it is built on top of:
● V8
● Rust
● Tokio (event loop)
● TypeScript
But why!? Isn't this exactly what Node does?
JavaScript (both the language itself and the ecosystem around it) has changed
significantly since Node was designed in 2009. Notably:
● Promises / Async / Await
● ES Modules
● Typed Arrays
Node has problems:
● A poorly designed module system, with centralized distribution.
● Lots of legacy APIs that must be supported.
● Security.
(These problems aren't unique to Node. Python and Ruby suffer similarly)
I want a fun and productive system for scripting.
A good scripting platform is too useful of a tool to
shrug and accept the status quo.
I find neither Node nor
Python nor Ruby nor any
other dynamic language
platform satisfactory.
Deno attempts to correct design mistakes in Node by
radically breaking compatibility
● ES modules are the one and only module system
○ HTTP URLs are used to link to third party code
○ Deno has the ability to fetch resources itself, so it is its own package manager.
● Deno is secure by default
○ Users must give extra permission to access the disk, network, or otherwise do privileged
operations.
● Deno maintains browser compatibility
○ The subset of Deno programs which are written completely in JavaScript and do not use the
global Deno object should also run in a modern web browser without change.
Example 1
deno -h
REPL
deno --types
cat program
Example 2
location.href
import.meta
Example 3
echo_server
http server
file_server
Example 4
testing
Deno is (kind of) like an OS
Linux
Processes
Syscalls
File descriptors (fd)
Scheduler
Userland: libc++ / glib / boost
/proc/$$/stat
man pages
Deno
Web Workers
Ops
Resource ids (rid)
Tokio
deno_std
deno.metrics()
deno --types
V8 (C++)
Deno (Rust)
deno::Isolate (Rust)
Uint8Array
Internal Design (VERY VERY simplified)
Deno.core.send()
Deno.core.recv()
JS
V8 (C++)
libdeno (C++)
deno process (Rust)
deno_recv_cb
deno_send
deno::Isolate (Rust)
Tokio thread pool (Rust)
deno_buf
"ops"
Resources (Rust)
stdio
TCP socket
child process
... etc
Internal Design (Very Simplified)
thread1 thread2 thread3 thread4
Deno.core.send()
Deno.core.recv()
//js (JS)
Embedding Deno
https://crates.io/crates/deno
Deno is released as a standalone executable, but it's also embeddable.
There are many situations where one might want to execute a bit of JavaScript,
but shelling out to Node (or Deno) is too insecure, complex, or generally
inappropriate:
○ Databases often use a JavaScript for Map Reduce functions
○ Serverless products like Lambda@Edge or Cloudflare Workers
Using raw V8 is difficult
Embedding Deno
https://crates.io/crates/deno
Essentially all you need to implement is this callback:
fn dispatch(
&mut self,
control: &[u8],
zero_copy_buf: deno_buf
) -> (bool, Box<Op>)
(rust)
deno_std (Standard Modules)
Deno core is kept as minimal as possible.
However it's useful to have high quality standard modules.
https://github.com/denoland/deno_std
● This partially addresses the "dependency hell" problem by not having external
deps.
● All code is reviewed by me (at least superficially)
● Is tagged with each Deno release: https://deno.land/std@v0.3.2/
Deno Performance
We continuously run benchmarks, to ensure our performance goes in the right
direction over time. Startup time is shown below (3x faster than Node)
Deno I/O Performance: improving but not fast yet
Deno I/O Performance: improving but not fast yet
Deno CLI TCP
Deno Core TCP
Node TCP
Deno I/O Performance: improving but not fast yet
Perf gap between
deno_core and CLI
Will be closed soon.
Roadmap: Aiming for 1.0 by end of summer
Soon:
● I/O performance issues must be fixed (mentioned earlier)
● Parallelize code loading pipeline (initialization progress bar)
● TLS / SSL
● Lock file for external modules
● Expose snapshotting to deno_core
● Debugger
Eventually:
● WebCrypto
● File system events
● WebGL
And others!
Deno is an open collaboration of many people.
Contributions welcome!
Thanks!
Comments? Questions? Concerns?
ry@tinyclouds.org
ES Modules map bijectively onto JavaScript files
This is a wonderful simplification over languages where "modules" and "source
code files" are not the same. It is one less concept for users to grok.
Files map bijectively onto URLs. Therefore modules map to URLs.
ES Module <=> JS File <=> JS URL
This is a very simple and file-centric programming model.
URL <=> source code <=> Module
For this reason, we've chosen to deviate from the convention of importing
TypeScript files without file extensions.
We require that module specifies that are paths to actual files:
import { red } from "https://deno.land/std/colors/mod.ts";
This maintains the bijection, and if it sticks, it will provide a simpler conceptual
basis for new users.
Please consider adopting this convention for TS code outside of Deno.
UNIX is also a very file-centric programming model
but over data rather than source files.
Inspired by this, Deno has the following design constraint:
1. Users should be able to allocate a Typed Array in JS, and tell the kernel to
read(2) into it.
2. Users should be able to pass a locally allocated Typed Array to the kernel for
a write(2) syscall without an internal memcpy happening.
Colloquially this is known as "zero-copy"
UNIX inspired I/O
Traditional UNIX programs use blocking reads and writes to process data:
char buf[64];
size_t n;
for (;;) {
n = read(STDIN_FILENO, buf, 64);
if (n <= 0) break;
n = write(STDOUT_FILENO, buf, n);
if (n <= 0) break;
}
UNIX inspired I/O
Traditional UNIX programs use blocking reads and writes to process data:
char buf[64];
size_t n;
for (;;) {
n = read(STDIN_FILENO, buf, 64);
if (n <= 0) break;
n = write(STDOUT_FILENO, buf, n);
if (n <= 0) break;
}
Zero-copy.
Fixed buf allocation.
Thus: efficient
UNIX inspired I/O
Traditional UNIX programs use blocking reads and writes to process data:
char buf[64];
size_t n;
for (;;) {
n = read(STDIN_FILENO, buf, 64);
if (n <= 0) break;
n = write(STDOUT_FILENO, buf, n);
if (n <= 0) break;
}
Different data streams
abstracted as a FD
Thus: composable
Zero-copy.
Fixed buf allocation.
Thus: efficient
UNIX inspired I/O
Traditional UNIX programs use blocking reads and writes to process data:
char buf[64];
size_t n;
for (;;) {
n = read(STDIN_FILENO, buf, 64);
if (n <= 0) break;
n = write(STDOUT_FILENO, buf, n);
if (n <= 0) break;
}
Different data streams
abstracted as a FD
Thus: composable
Does not read more
than it can handle.
Thus: back-pressure
Zero-copy.
Fixed buf allocation.
Thus: efficient
Go's Reader/Writer is the modern ideal of UNIX
type Reader interface {
Read(p []byte) (n int, err error)
}
type Writer interface {
Write(p []byte) (n int, err error)
}
The interfaces model the
read(2) write(2)
syscalls without relying on
FDs (which imply
expensive syscalls).
Not every type of data
stream needs a FD
E.G. gzip.
Expressing Reader/Writer in TypeScript
interface Reader {
read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>;
}
interface Writer {
write(p: Uint8Array): Promise<number>;
}
Expressing Reader/Writer in TypeScript
interface Reader {
read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>;
}
interface Writer {
write(p: Uint8Array): Promise<number>;
}
ArrayBuffers allow raw
memory access
Thus: efficient
Expressing Reader/Writer in TypeScript
interface Reader {
read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>;
}
interface Writer {
write(p: Uint8Array): Promise<number>;
}
TS interfaces allow
abstracting different
data streams
Thus: composable
ArrayBuffers allow raw
memory access
Thus: efficient
Expressing Reader/Writer in TypeScript
interface Reader {
read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>;
}
interface Writer {
write(p: Uint8Array): Promise<number>;
}
TS interfaces allow
abstracting different
data streams
Thus: composable
Async/Await allows
ergonomic sequencing
Thus: back-pressure
ArrayBuffers allow raw
memory access
Thus: efficient
Building a runtime around Reader/Writer allows us
to port other concepts, tests, and documentation
from Go.
Good ideas should be reused - and there are many of them in Go.
Examples:
Buffer ported from bytes.Buffer
copy() ported from io.Copy()
BufReader() ported from bufio.Reader

More Related Content

What's hot

Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...Edureka!
 
Full Stack Web Development
Full Stack Web DevelopmentFull Stack Web Development
Full Stack Web DevelopmentSWAGATHCHOWDARY1
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
GitLab for CI/CD process
GitLab for CI/CD processGitLab for CI/CD process
GitLab for CI/CD processHYS Enterprise
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)iFour Technolab Pvt. Ltd.
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Prashanth Kumar
 
Introducing type script
Introducing type scriptIntroducing type script
Introducing type scriptRemo Jansen
 
dot net technology
dot net technologydot net technology
dot net technologyImran Khan
 
Building mobile app with Ionic Framework
Building mobile app with Ionic FrameworkBuilding mobile app with Ionic Framework
Building mobile app with Ionic FrameworkHuy Trần
 

What's hot (20)

Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
 
Full Stack Web Development
Full Stack Web DevelopmentFull Stack Web Development
Full Stack Web Development
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
Nextjs13.pptx
Nextjs13.pptxNextjs13.pptx
Nextjs13.pptx
 
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
 
GitLab for CI/CD process
GitLab for CI/CD processGitLab for CI/CD process
GitLab for CI/CD process
 
Express js
Express jsExpress js
Express js
 
Basics of VueJS
Basics of VueJSBasics of VueJS
Basics of VueJS
 
React native
React nativeReact native
React native
 
Core java
Core javaCore java
Core java
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
 
MongoDB and Node.js
MongoDB and Node.jsMongoDB and Node.js
MongoDB and Node.js
 
Introducing type script
Introducing type scriptIntroducing type script
Introducing type script
 
dot net technology
dot net technologydot net technology
dot net technology
 
Type script mcq
Type script mcqType script mcq
Type script mcq
 
Building mobile app with Ionic Framework
Building mobile app with Ionic FrameworkBuilding mobile app with Ionic Framework
Building mobile app with Ionic Framework
 
Server side rendering review
Server side rendering reviewServer side rendering review
Server side rendering review
 

Similar to JS Fest 2019. Ryan Dahl. Deno, a new way to JavaScript

Introduction of deno 1
Introduction of deno 1Introduction of deno 1
Introduction of deno 1Vishal Sharma
 
Some wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily useSome wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily usearun.arwachin
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascriptAndrei Sebastian Cîmpean
 
Copmuter Languages
Copmuter LanguagesCopmuter Languages
Copmuter Languagesactanimation
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008guestd9065
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...IndicThreads
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftTalentica Software
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdfcifoxo
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java ProgrammingKaty Allen
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_netNico Ludwig
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...Maarten Balliauw
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfAnassElHousni
 

Similar to JS Fest 2019. Ryan Dahl. Deno, a new way to JavaScript (20)

Introduction of deno 1
Introduction of deno 1Introduction of deno 1
Introduction of deno 1
 
Some wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily useSome wonderful Linux softwares for daily use
Some wonderful Linux softwares for daily use
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
 
Book
BookBook
Book
 
C++0x
C++0xC++0x
C++0x
 
Copmuter Languages
Copmuter LanguagesCopmuter Languages
Copmuter Languages
 
Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008Purdue CS354 Operating Systems 2008
Purdue CS354 Operating Systems 2008
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
 
Dotnet basics
Dotnet basicsDotnet basics
Dotnet basics
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf2023-02-22_Tiberti_CyberX.pdf
2023-02-22_Tiberti_CyberX.pdf
 
Designing A Project Using Java Programming
Designing A Project Using Java ProgrammingDesigning A Project Using Java Programming
Designing A Project Using Java Programming
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
World of Node.JS
World of Node.JSWorld of Node.JS
World of Node.JS
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Deno Fundamentals
Deno FundamentalsDeno Fundamentals
Deno Fundamentals
 
Introduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdfIntroduction-to-C-Part-1.pdf
Introduction-to-C-Part-1.pdf
 

More from JSFestUA

JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in productionJS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in productionJSFestUA
 
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript PerformanceJS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript PerformanceJSFestUA
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JSFestUA
 
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...JSFestUA
 
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...JSFestUA
 
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...JSFestUA
 
JS Fest 2019/Autumn. Александр Товмач. JAMstack
JS Fest 2019/Autumn. Александр Товмач. JAMstackJS Fest 2019/Autumn. Александр Товмач. JAMstack
JS Fest 2019/Autumn. Александр Товмач. JAMstackJSFestUA
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JSFestUA
 
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...JSFestUA
 
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developersJS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developersJSFestUA
 
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...JSFestUA
 
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?JSFestUA
 
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the ScaleJS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the ScaleJSFestUA
 
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratchJS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratchJSFestUA
 
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотятJS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотятJSFestUA
 
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for RustJS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for RustJSFestUA
 
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...JSFestUA
 
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проектіJS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проектіJSFestUA
 
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядроJS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядроJSFestUA
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JSFestUA
 

More from JSFestUA (20)

JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in productionJS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
JS Fest 2019/Autumn. Роман Савіцький. Webcomponents & lit-element in production
 
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript PerformanceJS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
JS Fest 2019/Autumn. Erick Wendel. 10 secrets to improve Javascript Performance
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
 
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
JS Fest 2019/Autumn. Anton Cherednikov. Choreographic or orchestral architect...
 
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
JS Fest 2019/Autumn. Adam Leos. So why do you need to know Algorithms and Dat...
 
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
JS Fest 2019/Autumn. Marko Letic. Saving the world with JavaScript: A Data Vi...
 
JS Fest 2019/Autumn. Александр Товмач. JAMstack
JS Fest 2019/Autumn. Александр Товмач. JAMstackJS Fest 2019/Autumn. Александр Товмач. JAMstack
JS Fest 2019/Autumn. Александр Товмач. JAMstack
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
JS Fest 2019/Autumn. Дмитрий Жарков. Blockchainize your SPA or Integrate Java...
 
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developersJS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
JS Fest 2019/Autumn. Maciej Treder. Angular Schematics - Develop for developers
 
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
JS Fest 2019/Autumn. Kyle Boss. A Tinder Love Story: Create a Wordpress Blog ...
 
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
JS Fest 2019/Autumn. Андрей Старовойт. Зачем нужен тип "true" в TypeScript?
 
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the ScaleJS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
JS Fest 2019/Autumn. Eyal Eizenberg. Tipping the Scale
 
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratchJS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
JS Fest 2019/Autumn. Sota Ohara. Сreate own server less CMS from scratch
 
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотятJS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
JS Fest 2019/Autumn. Джордж Евтушенко. Как стать программистом, которого хотят
 
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for RustJS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
JS Fest 2019/Autumn. Алексей Орленко. Node.js N-API for Rust
 
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
JS Fest 2019/Autumn. Daniel Ostrovsky. Falling in love with decorators ES6/Ty...
 
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проектіJS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
JS Fest 2019/Autumn. Андрей Андрийко. Гексагональна архітектура в Nodejs проекті
 
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядроJS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
JS Fest 2019/Autumn. Борис Могила. Svelte. Почему нам не нужно run-time ядро
 
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
JS Fest 2019/Autumn. Виталий Кухар. Сравнение кластеризации HTTP, TCP и UDP н...
 

Recently uploaded

ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxRosabel UA
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 

Recently uploaded (20)

Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Presentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptxPresentation Activity 2. Unit 3 transv.pptx
Presentation Activity 2. Unit 3 transv.pptx
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 

JS Fest 2019. Ryan Dahl. Deno, a new way to JavaScript

  • 2. Disclaimer This talk is aimed at experienced enthusiasts If this isn't you: Don't Panic Ignore this talk - use Node. Node isn't going anywhere!
  • 3. Deno is a new command-line runtime for executing JavaScript and TypeScript Primarily it is built on top of: ● V8 ● Rust ● Tokio (event loop) ● TypeScript
  • 4. But why!? Isn't this exactly what Node does? JavaScript (both the language itself and the ecosystem around it) has changed significantly since Node was designed in 2009. Notably: ● Promises / Async / Await ● ES Modules ● Typed Arrays Node has problems: ● A poorly designed module system, with centralized distribution. ● Lots of legacy APIs that must be supported. ● Security. (These problems aren't unique to Node. Python and Ruby suffer similarly)
  • 5. I want a fun and productive system for scripting. A good scripting platform is too useful of a tool to shrug and accept the status quo. I find neither Node nor Python nor Ruby nor any other dynamic language platform satisfactory.
  • 6. Deno attempts to correct design mistakes in Node by radically breaking compatibility ● ES modules are the one and only module system ○ HTTP URLs are used to link to third party code ○ Deno has the ability to fetch resources itself, so it is its own package manager. ● Deno is secure by default ○ Users must give extra permission to access the disk, network, or otherwise do privileged operations. ● Deno maintains browser compatibility ○ The subset of Deno programs which are written completely in JavaScript and do not use the global Deno object should also run in a modern web browser without change.
  • 7. Example 1 deno -h REPL deno --types cat program
  • 11. Deno is (kind of) like an OS Linux Processes Syscalls File descriptors (fd) Scheduler Userland: libc++ / glib / boost /proc/$$/stat man pages Deno Web Workers Ops Resource ids (rid) Tokio deno_std deno.metrics() deno --types
  • 12. V8 (C++) Deno (Rust) deno::Isolate (Rust) Uint8Array Internal Design (VERY VERY simplified) Deno.core.send() Deno.core.recv() JS
  • 13. V8 (C++) libdeno (C++) deno process (Rust) deno_recv_cb deno_send deno::Isolate (Rust) Tokio thread pool (Rust) deno_buf "ops" Resources (Rust) stdio TCP socket child process ... etc Internal Design (Very Simplified) thread1 thread2 thread3 thread4 Deno.core.send() Deno.core.recv() //js (JS)
  • 14. Embedding Deno https://crates.io/crates/deno Deno is released as a standalone executable, but it's also embeddable. There are many situations where one might want to execute a bit of JavaScript, but shelling out to Node (or Deno) is too insecure, complex, or generally inappropriate: ○ Databases often use a JavaScript for Map Reduce functions ○ Serverless products like Lambda@Edge or Cloudflare Workers Using raw V8 is difficult
  • 15. Embedding Deno https://crates.io/crates/deno Essentially all you need to implement is this callback: fn dispatch( &mut self, control: &[u8], zero_copy_buf: deno_buf ) -> (bool, Box<Op>) (rust)
  • 16. deno_std (Standard Modules) Deno core is kept as minimal as possible. However it's useful to have high quality standard modules. https://github.com/denoland/deno_std ● This partially addresses the "dependency hell" problem by not having external deps. ● All code is reviewed by me (at least superficially) ● Is tagged with each Deno release: https://deno.land/std@v0.3.2/
  • 17. Deno Performance We continuously run benchmarks, to ensure our performance goes in the right direction over time. Startup time is shown below (3x faster than Node)
  • 18. Deno I/O Performance: improving but not fast yet
  • 19. Deno I/O Performance: improving but not fast yet Deno CLI TCP Deno Core TCP Node TCP
  • 20. Deno I/O Performance: improving but not fast yet Perf gap between deno_core and CLI Will be closed soon.
  • 21. Roadmap: Aiming for 1.0 by end of summer Soon: ● I/O performance issues must be fixed (mentioned earlier) ● Parallelize code loading pipeline (initialization progress bar) ● TLS / SSL ● Lock file for external modules ● Expose snapshotting to deno_core ● Debugger Eventually: ● WebCrypto ● File system events ● WebGL
  • 22. And others! Deno is an open collaboration of many people. Contributions welcome!
  • 24.
  • 25. ES Modules map bijectively onto JavaScript files This is a wonderful simplification over languages where "modules" and "source code files" are not the same. It is one less concept for users to grok. Files map bijectively onto URLs. Therefore modules map to URLs. ES Module <=> JS File <=> JS URL This is a very simple and file-centric programming model.
  • 26. URL <=> source code <=> Module For this reason, we've chosen to deviate from the convention of importing TypeScript files without file extensions. We require that module specifies that are paths to actual files: import { red } from "https://deno.land/std/colors/mod.ts"; This maintains the bijection, and if it sticks, it will provide a simpler conceptual basis for new users. Please consider adopting this convention for TS code outside of Deno.
  • 27. UNIX is also a very file-centric programming model but over data rather than source files. Inspired by this, Deno has the following design constraint: 1. Users should be able to allocate a Typed Array in JS, and tell the kernel to read(2) into it. 2. Users should be able to pass a locally allocated Typed Array to the kernel for a write(2) syscall without an internal memcpy happening. Colloquially this is known as "zero-copy"
  • 28. UNIX inspired I/O Traditional UNIX programs use blocking reads and writes to process data: char buf[64]; size_t n; for (;;) { n = read(STDIN_FILENO, buf, 64); if (n <= 0) break; n = write(STDOUT_FILENO, buf, n); if (n <= 0) break; }
  • 29. UNIX inspired I/O Traditional UNIX programs use blocking reads and writes to process data: char buf[64]; size_t n; for (;;) { n = read(STDIN_FILENO, buf, 64); if (n <= 0) break; n = write(STDOUT_FILENO, buf, n); if (n <= 0) break; } Zero-copy. Fixed buf allocation. Thus: efficient
  • 30. UNIX inspired I/O Traditional UNIX programs use blocking reads and writes to process data: char buf[64]; size_t n; for (;;) { n = read(STDIN_FILENO, buf, 64); if (n <= 0) break; n = write(STDOUT_FILENO, buf, n); if (n <= 0) break; } Different data streams abstracted as a FD Thus: composable Zero-copy. Fixed buf allocation. Thus: efficient
  • 31. UNIX inspired I/O Traditional UNIX programs use blocking reads and writes to process data: char buf[64]; size_t n; for (;;) { n = read(STDIN_FILENO, buf, 64); if (n <= 0) break; n = write(STDOUT_FILENO, buf, n); if (n <= 0) break; } Different data streams abstracted as a FD Thus: composable Does not read more than it can handle. Thus: back-pressure Zero-copy. Fixed buf allocation. Thus: efficient
  • 32. Go's Reader/Writer is the modern ideal of UNIX type Reader interface { Read(p []byte) (n int, err error) } type Writer interface { Write(p []byte) (n int, err error) } The interfaces model the read(2) write(2) syscalls without relying on FDs (which imply expensive syscalls). Not every type of data stream needs a FD E.G. gzip.
  • 33. Expressing Reader/Writer in TypeScript interface Reader { read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>; } interface Writer { write(p: Uint8Array): Promise<number>; }
  • 34. Expressing Reader/Writer in TypeScript interface Reader { read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>; } interface Writer { write(p: Uint8Array): Promise<number>; } ArrayBuffers allow raw memory access Thus: efficient
  • 35. Expressing Reader/Writer in TypeScript interface Reader { read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>; } interface Writer { write(p: Uint8Array): Promise<number>; } TS interfaces allow abstracting different data streams Thus: composable ArrayBuffers allow raw memory access Thus: efficient
  • 36. Expressing Reader/Writer in TypeScript interface Reader { read(p: Uint8Array): Promise<{ nread: number, eof: boolean }>; } interface Writer { write(p: Uint8Array): Promise<number>; } TS interfaces allow abstracting different data streams Thus: composable Async/Await allows ergonomic sequencing Thus: back-pressure ArrayBuffers allow raw memory access Thus: efficient
  • 37. Building a runtime around Reader/Writer allows us to port other concepts, tests, and documentation from Go. Good ideas should be reused - and there are many of them in Go. Examples: Buffer ported from bytes.Buffer copy() ported from io.Copy() BufReader() ported from bufio.Reader