SlideShare a Scribd company logo
React,
Powered by
WebAssembly
Jay Phelps | @_jayphelps
Jay Phelps | @_jayphelps
WebAssembly will change the way
we think of "web apps"
Jay Phelps
Chief Software Architect |
Support, Training, Mentorship, and More
https://www.thisdot.co/
So...what is WebAssembly? aka wasm
Jay Phelps | @_jayphelps
Jay Phelps | @_jayphelps
Efficient, low-level bytecode for the Web
Jay Phelps | @_jayphelps
Efficient, low-level bytecode for the Web
Jay Phelps | @_jayphelps
Fast to load and execute
Jay Phelps | @_jayphelps
Efficient, low-level bytecode for the Web
Jay Phelps | @_jayphelps
0x6a01101010
Jay Phelps | @_jayphelps
Intended (mostly) as a compilation target
int factorial(int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}
int factorial(int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}
00 61 73 6D 01 00 00 00 01
86 80 80 80 00 01 60 01 7F
01 7F 03 82 80 80 80 00 01
00 06 81 80 80 80 00 00 0A
9D 80 80 80 00 01 97 80 80
80 00 00 20 00 41 00 46 04
40 41 01 0F 0B 20 00 41 01
6B 10 00 20 00 6C 0B
Jay Phelps | @_jayphelps
Safe and portable
just like JavaScript
Jay Phelps | @_jayphelps
“shortcut to your JavaScript engine's optimizer”
Ben Smith, Chrome team
Jay Phelps | @_jayphelps
Is it going to kill JavaScript?
Jay Phelps | @_jayphelps
Nope!says browser vendors
*
Jay Phelps | @_jayphelps
*well...maybe...some day...a really long time from now
(my own opinion)
Jay Phelps | @_jayphelps
Will we compile JavaScript to WebAssembly?
Jay Phelps | @_jayphelps
JavaScript is an extremely dynamic language
Jay Phelps | @_jayphelps
Compiling JavaScript to WebAssembly
would be all around slower
Jay Phelps | @_jayphelps
v1 MVP is best suited for languages like
C/C++ and Rust
Jay Phelps | @_jayphelps
But other languages soon!
Things like Java, OCaml, and even new ones
Jay Phelps | @_jayphelps
TurboScript
Jay Phelps | @_jayphelps
class Coordinates {
x: float32;
y: float32;
z: float32;
constructor(x: float32, y: float32, z: float32): Vect3 {
this.x = x;
this.y = y;
this.z = z;
}
}
export function example() {
let position = new Coordinates(x, y, z);
// later
delete position;
}
Jay Phelps | @_jayphelps
When should I target WebAssembly?
Jay Phelps | @_jayphelps
Heavily CPU-bound number computations
Jay Phelps | @_jayphelps
Games
Jay Phelps | @_jayphelps
You'll likely consume compiled
WebAssembly binaries even sooner
Jay Phelps | @_jayphelps
Oxidizing Source Maps with Rust and WebAssembly
https://hacks.mozilla.org/2018/01/oxidizing-source-maps-with-rust-and-webassembly/
5.89 times faster!
Jay Phelps | @_jayphelps
d3-wasm-force
https://github.com/ColinEberhardt/d3-wasm-force
const simulation = d3wasm.forceSimulation(graph.nodes, true)
.force('charge', d3wasm.forceManyBody())
.force('center', d3wasm.forceCenter(width / 2, height / 2))
.force('link', d3wasm.forceLink().links(graph.links).id(d => d.id))
.stop();
Jay Phelps | @_jayphelps
Other use cases are imminent
Jay Phelps | @_jayphelps
What was that binary stuff?
int factorial(int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}
00 61 73 6D 01 00 00 00 01
86 80 80 80 00 01 60 01 7F
01 7F 03 82 80 80 80 00 01
00 06 81 80 80 80 00 00 0A
9D 80 80 80 00 01 97 80 80
80 00 00 20 00 41 00 46 04
40 41 01 0F 0B 20 00 41 01
6B 10 00 20 00 6C 0B
00 61 73 6D 01 00 00 00 01
86 80 80 80 00 01 60 01 7F
01 7F 03 82 80 80 80 00 01
00 06 81 80 80 80 00 00 0A
9D 80 80 80 00 01 97 80 80
80 00 00 20 00 41 00 46 04
40 41 01 0F 0B 20 00 41 01
6B 10 00 20 00 6C 0B
00 61 73 6D 01 00 00 00 01
86 80 80 80 00 01 60 01 7F
01 7F 03 82 80 80 80 00 01
00 06 81 80 80 80 00 00 0A
9D 80 80 80 00 01 97 80 80
80 00 00 20 00 41 00 46 04
40 41 01 0F 0B 20 00 41 01
6B 10 00 20 00 6C 0B
00 61 73 6D 01 00 00 00 01
86 80 80 80 00 01 60 01 7F
01 7F 03 82 80 80 80 00 01
00 06 81 80 80 80 00 00 0A
9D 80 80 80 00 01 97 80 80
80 00 00 20 00 41 00 46 04
40 41 01 0F 0B 20 00 41 01
6B 10 00 20 00 6C 0B
03 82 80 80 80 0
81 80 80 80 00 0
80 80 00 01 97 8
00 20 00 41 00 4
03 82 80 80 80 0
81 80 80 80 00 0
80 80 00 01 97 8
00 20 00 41 00 4
Jay Phelps | @_jayphelps
Binary can be a little intimidating
Jay Phelps | @_jayphelps
Protip: don't worry about it
(unless of course, you want to)
Jay Phelps | @_jayphelps
Tooling will eventually make it a non-issue
Jay Phelps | @_jayphelps
Textual representation to the rescue!
Jay Phelps | @_jayphelps
(func $factorial (param $n i32) (result i32)
get_local $n
i32.const 0
i32.eq
if $if0
i32.const 1
return
end $if0
get_local $n
i32.const 1
i32.sub
call $factorial
get_local $n
i32.mul
)
Jay Phelps | @_jayphelps
(func $factorial (param $n i32) (result i32)
get_local $n
i32.const 0
i32.eq
if $if0
i32.const 1
return
end $if0
get_local $n
i32.const 1
i32.sub
call $factorial
get_local $n
i32.mul
)
Jay Phelps | @_jayphelps
Let's learn the fundamentals
Jay Phelps | @_jayphelps
WebAssembly is a stack machine language
Jay Phelps | @_jayphelps
...what's a stack machine?
Jay Phelps | @_jayphelps
a data structure with two operations:
push and pop
Stack
stack
item
stack
item
stack
push
item
stack
item
stack
item
item
stack
item
item
stack
item
item
stack
item
item
item
stack
item
item
item
stack
item
item
item
stack
item
item
item
stack
pop
item
item
item
stack
item
item
stack
item
stack
item
item
stack
item
item
stack
stack
item
stack
item
stack
Jay Phelps | @_jayphelps
last in, first out order (LIFO)
Jay Phelps | @_jayphelps
stack machine: instructions on a stack
1 + 2
i32.add 0x6a
opcode mnemonics
01101010
i32.const 1
i32.const 2
i32.add
i32.const 1
i32.const 2
i32.add
i32.const 1
i32.const 1
i32.const 2
i32.add
i32.const 2
i32.const 1
i32.const 2
i32.addi32.add
i32.const 1
i32.const 2
i32.add
stack
i32.const 1
i32.const 2
i32.add
i32.const 1
i32.const 2
i32.add
i32.const 1
stack
1
i32.const 1
i32.const 2
i32.add
i32.const 1
stack
1
i32.const 1
i32.const 2
i32.add
i32.const 2
stack
2
1
i32.const 1
i32.const 2
i32.add
i32.const 2
stack
2
1
i32.const 1
i32.const 2
i32.addi32.add
stack
1
2
i32.const 1
i32.const 2
i32.addi32.add
stack
1
2
i32.const 1
i32.const 2
i32.addi32.add
stack
3
i32.const 1
i32.const 2
i32.addi32.add
stack
3
i32.const 1
i32.const 2
i32.add
Jay Phelps | @_jayphelps
i32.const 1
i32.const 2
i32.add
call $log
Jay Phelps | @_jayphelps
Jay Phelps | @_jayphelps
Compilers usually apply optimizations
real-world output is often less understandable to humans
i32.const 1
i32.const 2
i32.add
call $log
Jay Phelps | @_jayphelps
i32.const 3
call $log
Jay Phelps | @_jayphelps
Jay Phelps | @_jayphelps
Most tooling supports an Abstract Syntax Tree (AST)
still compiled and evaluated as a stack machine
i32.const 1
i32.const 2
i32.add
call $log
Jay Phelps | @_jayphelps
(call $log
(i32.add
(i32.const 1)
(i32.const 2)
)
)
Jay Phelps | @_jayphelps
(call $log
(i32.add
(i32.const 1)
(i32.const 2)
)
)
Jay Phelps | @_jayphelps
s-expressions
(call $log
(i32.add
(i32.const 1)
(i32.const 2)
)
)
Jay Phelps | @_jayphelps
s-expressions
Yep, looks like Lisp
Jay Phelps | @_jayphelps
What's missing?
Jay Phelps | @_jayphelps
Direct access to Web APIs
Jay Phelps | @_jayphelps
Direct access to Web APIs
You have call into JavaScript, right now
Jay Phelps | @_jayphelps
Garbage collection
Jay Phelps | @_jayphelps
Garbage collection
necessary for better interop with JavaScript and WebIDL
Jay Phelps | @_jayphelps
Multi-threading
Jay Phelps | @_jayphelps
Multi-threading
Sounds likely we'll get very close to "real" threads
Jay Phelps | @_jayphelps
There's more, but advancing very quickly!
Jay Phelps | @_jayphelps
How is this going to impact React?
Jay Phelps | @_jayphelps
React could create a WebAssembly reconciler for Fiber
Jay Phelps | @_jayphelps
Fiber
Jay Phelps | @_jayphelps
• pause work and come back to it later
Fiber
Jay Phelps | @_jayphelps
• pause work and come back to it later
• assign priority to different types of work
Fiber
Jay Phelps | @_jayphelps
• pause work and come back to it later
• assign priority to different types of work
• reuse previously completed work
Fiber
Jay Phelps | @_jayphelps
• pause work and come back to it later
• assign priority to different types of work
• reuse previously completed work
• abort work if it's no longer needed
Fiber
Jay Phelps | @_jayphelps
Lin Clark - A Cartoon Intro to Fiber
https://goo.gl/bXsYhY
Jay Phelps | @_jayphelps
Ember’s “Glimmer” VM is being written in Rust
compiled to WebAssembly
Jay Phelps | @_jayphelps
React components could run in WebAssembly
e.g. writing them in Reason
Jay Phelps | @_jayphelps
let component = ReasonReact.statelessComponent("Page");
let handleClick = (_event, _self) => Js.log("clicked!");
let make = (~message, _children) => {
...component,
render: self =>
<div onClick={self.handle(handleClick)}>
{ReasonReact.stringToElement(message)}
</div>
};
Jay Phelps | @_jayphelps
This is possible right now, but not yet ideal
missing direct access to the DOM
Jay Phelps | @_jayphelps
React.js?
Jay Phelps | @_jayphelps
React.js?
Jay Phelps | @_jayphelps
How do I get started now?
Jay Phelps | @_jayphelps
webassembly.org
Jay Phelps | @_jayphelps
https://mbebenita.github.io/WasmExplorer/
Jay Phelps | @_jayphelps
emcc main.c -s WASM=1 -o app.html
Jay Phelps | @_jayphelps
Webpack is adding support (!!!)
Jay Phelps | @_jayphelps
Webpack is adding support (!!!)
They received a $125,000 grant from MOSS
Jay Phelps | @_jayphelps
import('./add.wasm').then(module => {
const result = module.add(1, 2);
console.log(result);
});
Jay Phelps | @_jayphelps
Imagine an rust-loader / reason-loader
Jay Phelps | @_jayphelps
Supported in all modern browsers
Jay Phelps | @_jayphelps
The revolution is just beginning
Jay Phelps | @_jayphelps
Efficient, low-level bytecode for the Web
Jay Phelps | @_jayphelps
Efficient, low-level bytecode for the Web
Jay Phelps | @_jayphelps
Thanks!
@_jayphelps

More Related Content

Similar to React, Powered by WebAssembly (20)

PPTX
A Brief introduction to Webassembly
Manuel Eusebio de Paz Carmona
 
PPT
Web assembly overview by Mikhail Sorokovsky
Valeriia Maliarenko
 
PPTX
WebAssembly: In a Nutshell
RangHo Lee
 
PDF
Web (dis)assembly
Shakacon
 
PDF
Start writing in WebAssembly
The Software House
 
PPTX
WebAssembly overview. KievJS meetup
Alexandr Skachkov
 
PPTX
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JSFestUA
 
PDF
WebAssembly - czy dzisiaj mi się to przyda do pracy?
Brainhub
 
PDF
Boyan Mihaylov - Is web assembly the killer of javascript
Codemotion
 
PDF
Is WebAssembly the killer of JavaScript?
Boyan Mihaylov
 
PDF
Web assembly brings the web to a new era
Boyan Mihaylov
 
PDF
Web assembly for the masses
Sendil Kumar
 
PDF
WebAssemlby vs JavaScript
Alexandr Skachkov
 
PDF
Supercharging tutorials with WebAssembly
All Things Open
 
ODP
An Introduction to WebAssembly
Daniel Budden
 
PPTX
Web Assembly Big Picture
Yousif Shalaby
 
PPTX
WebAssembly WASM Introduction Presentation
Brad Beiermann
 
PPTX
Blazor v1.1
Juan Luis Guerrero Minero
 
PDF
Assembly thy Web
Martin Ockajak
 
PDF
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
Voxxed Days Thessaloniki
 
A Brief introduction to Webassembly
Manuel Eusebio de Paz Carmona
 
Web assembly overview by Mikhail Sorokovsky
Valeriia Maliarenko
 
WebAssembly: In a Nutshell
RangHo Lee
 
Web (dis)assembly
Shakacon
 
Start writing in WebAssembly
The Software House
 
WebAssembly overview. KievJS meetup
Alexandr Skachkov
 
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JSFestUA
 
WebAssembly - czy dzisiaj mi się to przyda do pracy?
Brainhub
 
Boyan Mihaylov - Is web assembly the killer of javascript
Codemotion
 
Is WebAssembly the killer of JavaScript?
Boyan Mihaylov
 
Web assembly brings the web to a new era
Boyan Mihaylov
 
Web assembly for the masses
Sendil Kumar
 
WebAssemlby vs JavaScript
Alexandr Skachkov
 
Supercharging tutorials with WebAssembly
All Things Open
 
An Introduction to WebAssembly
Daniel Budden
 
Web Assembly Big Picture
Yousif Shalaby
 
WebAssembly WASM Introduction Presentation
Brad Beiermann
 
Assembly thy Web
Martin Ockajak
 
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
Voxxed Days Thessaloniki
 

More from Jay Phelps (7)

PDF
Backpressure? Resistance is not futile. RxJS Live 2019
Jay Phelps
 
PDF
Why I Love JSX!
Jay Phelps
 
PDF
ES2015 and Beyond
Jay Phelps
 
PDF
Intro to Ember CLI
Jay Phelps
 
PDF
Ember Overview in 5 Minutes
Jay Phelps
 
PDF
Profit From Your Media Library Using Multi-Platform Distribution
Jay Phelps
 
PDF
Intro to Ember.js
Jay Phelps
 
Backpressure? Resistance is not futile. RxJS Live 2019
Jay Phelps
 
Why I Love JSX!
Jay Phelps
 
ES2015 and Beyond
Jay Phelps
 
Intro to Ember CLI
Jay Phelps
 
Ember Overview in 5 Minutes
Jay Phelps
 
Profit From Your Media Library Using Multi-Platform Distribution
Jay Phelps
 
Intro to Ember.js
Jay Phelps
 
Ad

Recently uploaded (20)

PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Ad

React, Powered by WebAssembly