SlideShare a Scribd company logo
TURBOCHARGING CLIENT-SIDE PROCESSING

LEVERAGING ASM.JS
Vladimir Vukićević / @vvuk
OVERVIEW
What is asm.js?
Writing asm.js by hand
Using Emscripten
Integrating libraries
What can you do with this
WHAT IS ASM.JS?
vrg=Fot2ra(26)
a
la3Ary378;
fnto mi( {
ucin an)
vra=0 b=0
a
,
;
d {
o
a=8+( < 2 |0
b < )
;
ga> 2 =+[ > 2 +10
[ > ]
ga > ]
.;
b=b+1|0
;
}wie(b|0 <50)
hl (
)
00;
}

This is asm.js. It's JavaScript, with some rigid rules.
asm.js operates on an ArrayBuffer heap
asm.js operates only on numeric values
asm.js can call regular JavaScript
asm.js can be called by regular JavaScript
asm.js provides predictable performance
TWO WAYS TO USE ASM.JS
To bring existing C/C++ apps to the web
Many of the current flashy demos do this
Great for games
Not the focus here
To accelerate processing of JS apps
Leverage existing libraries
Offload and speed up data processing and analysis
WRITING ASM.JS BY HAND
vrha =nwAryufr49)
a ep e raBfe(06;
vram=fnto(tlb frin ha){
a s
ucinsdi, oeg, ep
"s am;
ue s"
vrHAF2=nwsdi.la3Aryha)
a EP3
e tlbFot2ra(ep;
fnto aeaeausfrt ls){
ucin vrgVle(is, at
frt=frt0 ls =ls|;
is
is|; at at0
vrcut=0 vrag=00
a on
; a v
.;
cut=(at-frt > 2
on
ls
is) > ;
wie(frt0 <(at0){
hl (is|) ls|)
ag=ag++EP3[is > 2;
v
v
HAF2frt > ]
frt=frt+40
is
is
|;
}
rtr +ag/+cut0)
eun (v
(on|);
}
rtr {
eun
aeaeaus aeaeaus
vrgVle: vrgVle,
}
;
}wno,{,ha)
(idw } ep;
/ ptsm vle it teha *
* u oe aus no h ep /
vrHAF2=nwFot2ra(ep;
a EP3
e la3Aryha)
fr(a i=0 i<2;+i {
o vr
;
0 +)
HAF2i =i
EP3[] ;
}
/ mk tecl *
* ae h al /
vrag=amaeaeaus0<,2<2;
a v
s.vrgVle(<2 0<)
cnoelgag;
osl.o(v)
WRITING ASM.JS BY HAND
... DOABLE, BUT PAINFUL.
Doable by hand for simple things
e.g., a matrix math library
It's intended to be a compile target
Not just from C/C++!
LLJS can target asm.js
TypeScript is interested
Emscripten for C/C++ source
USING EXISTING LIBRARIES
THROUGH EMSCRIPTEN
LOTS OF EXISTING CODE OUT THERE
For example, open source libraries for...
Computer Vision — OpenCV
Physics — Box2D, Bullet
Compression — zlib, lz4, etc.
Text-to-Speech — eSpeak
Convex Hull Computation — qhull
...
LOTS OF EXISTING CODE OUT THERE
Many already have Emscripten ports
Some have nice JS layers on top
INTEGRATING WITH ASM.JS CODE
1. Get data into asm.js heap
vrcnaDt =cxgtmgDt(,0 w h;
a avsaa
t.eIaeaa0 , , )
/ alct saei amj ha *
* loae pc n s.s ep /
vrhaPr=Mdl.mlo( *h*4;
a ept
oue_alcw
)
vrhaDt =nwUn8ra(EP haPr w*h*4;
a epaa
e itAryHA, ept,
)
/ cp cnaDt.aait ha *
* oy avsaadt no ep /
haDt.e(avsaadt)
epaastcnaDt.aa;

2. Call function(s)
amouedPoesn(ept,w h;
sMdl.orcsighaPr , )

3. Get data out of heap
/ cp dt bc t Iaeaa*
* oy aa ak o mgDt /
cnaDt.aasthaDt)
avsaadt.e(epaa;
/ fe saei amj ha *
* re pc n s.s ep /
Mdl.fe(ept)
oue_rehaPr;
/ da iaedt bc *
* rw mg aa ak /
cxptmgDt(avsaa 0 0;
t.uIaeaacnaDt, , )
INTEGRATING WITH ASM.JS CODE
You have to deal with manual
memory management and allocation
Likely already thinking about it
if you're heavily optimizing your JS
Make some nice wrappers and avoid
having to think about this again
NICE WRAPPERS?
fnto poesmgDt(mgDt){
ucin rcsIaeaaiaeaa
vrw=iaeaawdh h=iaeaahih;
a
mgDt.it,
mgDt.egt
vrhaPr=Mdl.mlo( *h*4;
a ept
oue_alcw
)
vrhaDt =nwUn8ra(EP haPr w*h*4;
a epaa
e itAryHA, ept,
)
haDt.e(avsaadt)
epaastcnaDt.aa;
amouedPoesn(ept,w h;
sMdl.orcsighaPr , )
iaeaadt.e(epaa;
mgDt.aasthaDt)
Mdl.fe(ept)
oue_rehaPr;
}
JUST ANOTHER MODULE
JavaScript App
App Code
EmberJS
jQuery
...

asm.js
code
SOME ODDS AND ENDS
Use Worker Threads
Use async Script Loading
USING WORKER THREADS
Place your asm.js module on a worker
Asynchronous execution, no jank!
Main App code

postMessage ⇒
request
⇐ postMessage
reply

Worker
asm.js
module
(ASIDE) WORKERS ARE AWESOME
And will get even more awesome
We've got lots of APIs coming to workers, including...
WebRTC
WebGL & Canvas 2D
Web Sockets
Web Audio
Synchronous message passing
USING ASYNCHRONOUS SCRIPT LOADING
asm.js code can be large, and parsing and compiling takes time.
<citaycsc"i/ysLbj"<srp>
srp sn r=lbmAmi.s>/cit

Add async. Magic.
In the (very near) future, such compilation will also be cached.
WHAT DO I DO WITH THIS?
Processing/resizing of photos client-side
(color correction, face identification)
Data analysis
(download raw data to client)
WHAT DO I DO WITH THIS?
Face login/confirmation
(WebRTC + UserMedia + canvas)
Add text-to-speech
(read notices in the background)
WHAT DO I DO WITH THIS?
Implement new image (and video?) codecs
(specialized or experimental)
Recognize barcodes
(handy on mobile!)
PERFORMANCE?
"Within 2x of native."
... pretty consistently.
Even on mobile! Take advantage to make mobile apps feel more
like native.
IT'S DANGEROUS TO GO ALONE
You'll need...
Some familiarity with C/C++
(or someone nearby familiar with C/C++)
Emscripten and Emscripten SDK
NOT JUST FOR C/C++

Focus has been on C/C++ due to large body of existing code
Lua, Python, etc. all exist
For example, give users ability to write scripts in Lua
WRAP-UP
asmjs.org
emscripten.org
QUESTIONS?
Vladimir Vukićević / @vvuk

More Related Content

What's hot

Nodejs in Production
Nodejs in ProductionNodejs in Production
Nodejs in Production
William Bruno Moraes
 
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverageTesting NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoveragemlilley
 
(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" web(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" webWeb::Strategija
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
Algorithm cup 2010
Algorithm cup 2010Algorithm cup 2010
Algorithm cup 2010Wizche
 
appborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-systemappborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-systemendian7000
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
Christian Joudrey
 
JS knowing-nuances
JS knowing-nuancesJS knowing-nuances
JS knowing-nuances
Ramesh Ramalingam
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
Oleg Podsechin
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
amix3k
 
Kraken Front-Trends
Kraken Front-TrendsKraken Front-Trends
Kraken Front-Trends
PayPal
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
Tapan B.K.
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitter
Simen Li
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Node.js - Best practices
Node.js  - Best practicesNode.js  - Best practices
Node.js - Best practices
Felix Geisendörfer
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
Chris Cowan
 

What's hot (20)

Node ppt
Node pptNode ppt
Node ppt
 
Nodejs in Production
Nodejs in ProductionNodejs in Production
Nodejs in Production
 
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverageTesting NodeJS with Mocha, Should, Sinon, and JSCoverage
Testing NodeJS with Mocha, Should, Sinon, and JSCoverage
 
(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" web(WS14) Sasa Matijasic - Node.js i "novi" web
(WS14) Sasa Matijasic - Node.js i "novi" web
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
 
Algorithm cup 2010
Algorithm cup 2010Algorithm cup 2010
Algorithm cup 2010
 
appborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-systemappborg, coffeesurgeon, moof, logging-system
appborg, coffeesurgeon, moof, logging-system
 
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect ToolboxWebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
WebCamp 2016: PHP.Алексей Петров.PHP at Scale: System Architect Toolbox
 
Building your first Node app with Connect & Express
Building your first Node app with Connect & ExpressBuilding your first Node app with Connect & Express
Building your first Node app with Connect & Express
 
JS knowing-nuances
JS knowing-nuancesJS knowing-nuances
JS knowing-nuances
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Kraken Front-Trends
Kraken Front-TrendsKraken Front-Trends
Kraken Front-Trends
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
 
Node.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitterNode.js Event Loop & EventEmitter
Node.js Event Loop & EventEmitter
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Node.js - Best practices
Node.js  - Best practicesNode.js  - Best practices
Node.js - Best practices
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 

Viewers also liked

Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...
Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...
Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...
FITC
 
My Type of Life
My Type of LifeMy Type of Life
My Type of Life
FITC
 
From Box to Bots in Minutes
From Box to Bots in MinutesFrom Box to Bots in Minutes
From Box to Bots in Minutes
FITC
 
21st Century Crystal Ball
21st Century Crystal Ball21st Century Crystal Ball
21st Century Crystal Ball
FITC
 
Showing Your Brand Story Online
Showing Your Brand Story OnlineShowing Your Brand Story Online
Showing Your Brand Story Online
FITC
 
The Browser Is Dead, Long Live The Web!
The Browser Is Dead, Long Live The Web!The Browser Is Dead, Long Live The Web!
The Browser Is Dead, Long Live The Web!
FITC
 
Making Work For Humans, Not Consumers
Making Work For Humans, Not ConsumersMaking Work For Humans, Not Consumers
Making Work For Humans, Not Consumers
FITC
 
Managing The Process
Managing The ProcessManaging The Process
Managing The Process
FITC
 
Neuroscience Brightens Up the Grey Area of User Feedback
Neuroscience Brightens Up the Grey Area of User FeedbackNeuroscience Brightens Up the Grey Area of User Feedback
Neuroscience Brightens Up the Grey Area of User Feedback
FITC
 
Managing Responsive Design Projects
Managing Responsive Design ProjectsManaging Responsive Design Projects
Managing Responsive Design Projects
FITC
 
Empowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsEmpowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris Mills
FITC
 
Building Apps with Ember
Building Apps with EmberBuilding Apps with Ember
Building Apps with Ember
FITC
 
Badass Motion Design for Front-end Developers
Badass Motion Design for Front-end DevelopersBadass Motion Design for Front-end Developers
Badass Motion Design for Front-end Developers
FITC
 
Creating a Smile Worthy World
Creating a Smile Worthy WorldCreating a Smile Worthy World
Creating a Smile Worthy World
FITC
 
Prolific Minded
Prolific MindedProlific Minded
Prolific Minded
FITC
 
Goofy, Goodfellas and a Gardener: The Masters of Experience Design.
Goofy, Goodfellas and a Gardener: The Masters of Experience Design.Goofy, Goodfellas and a Gardener: The Masters of Experience Design.
Goofy, Goodfellas and a Gardener: The Masters of Experience Design.
FITC
 
UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg
 UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg
UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg
FITC
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
FITC
 
Getting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James HalpernGetting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James Halpern
FITC
 
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig FitzpatrickPageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
FITC
 

Viewers also liked (20)

Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...
Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...
Should I Build a Separate Mobile Site or a Responsive Site? Neither! with Der...
 
My Type of Life
My Type of LifeMy Type of Life
My Type of Life
 
From Box to Bots in Minutes
From Box to Bots in MinutesFrom Box to Bots in Minutes
From Box to Bots in Minutes
 
21st Century Crystal Ball
21st Century Crystal Ball21st Century Crystal Ball
21st Century Crystal Ball
 
Showing Your Brand Story Online
Showing Your Brand Story OnlineShowing Your Brand Story Online
Showing Your Brand Story Online
 
The Browser Is Dead, Long Live The Web!
The Browser Is Dead, Long Live The Web!The Browser Is Dead, Long Live The Web!
The Browser Is Dead, Long Live The Web!
 
Making Work For Humans, Not Consumers
Making Work For Humans, Not ConsumersMaking Work For Humans, Not Consumers
Making Work For Humans, Not Consumers
 
Managing The Process
Managing The ProcessManaging The Process
Managing The Process
 
Neuroscience Brightens Up the Grey Area of User Feedback
Neuroscience Brightens Up the Grey Area of User FeedbackNeuroscience Brightens Up the Grey Area of User Feedback
Neuroscience Brightens Up the Grey Area of User Feedback
 
Managing Responsive Design Projects
Managing Responsive Design ProjectsManaging Responsive Design Projects
Managing Responsive Design Projects
 
Empowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris MillsEmpowering the “Mobile Web” with Chris Mills
Empowering the “Mobile Web” with Chris Mills
 
Building Apps with Ember
Building Apps with EmberBuilding Apps with Ember
Building Apps with Ember
 
Badass Motion Design for Front-end Developers
Badass Motion Design for Front-end DevelopersBadass Motion Design for Front-end Developers
Badass Motion Design for Front-end Developers
 
Creating a Smile Worthy World
Creating a Smile Worthy WorldCreating a Smile Worthy World
Creating a Smile Worthy World
 
Prolific Minded
Prolific MindedProlific Minded
Prolific Minded
 
Goofy, Goodfellas and a Gardener: The Masters of Experience Design.
Goofy, Goodfellas and a Gardener: The Masters of Experience Design.Goofy, Goodfellas and a Gardener: The Masters of Experience Design.
Goofy, Goodfellas and a Gardener: The Masters of Experience Design.
 
UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg
 UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg
UX Lessons from the USSR: The Trouble with Manifestos with Erik von Stackelberg
 
Here Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript DebuggingHere Be Dragons – Advanced JavaScript Debugging
Here Be Dragons – Advanced JavaScript Debugging
 
Getting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James HalpernGetting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James Halpern
 
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig FitzpatrickPageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
 

Similar to Turbocharging Client-Side Processing: Leveraging asm.js

Jassa la GeekMeet Bucuresti
Jassa la GeekMeet BucurestiJassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucurestialexnovac
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math ops
Luka Zakrajšek
 
Asm.js introduction
Asm.js introductionAsm.js introduction
Asm.js introduction
Oleksii Prohonnyi
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
Robert Cooper
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsMichael Lehmann
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Codemotion
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
Sebastian Springer
 
Everyone loves PHP
Everyone loves PHPEveryone loves PHP
Everyone loves PHP
Abhijit Das
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
Juho Vepsäläinen
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLsintelliyole
 
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...Tom Croucher
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
Sasha Goldshtein
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXL
Linaro
 
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Emery Berger
 
Web (dis)assembly
Web (dis)assemblyWeb (dis)assembly
Web (dis)assembly
Shakacon
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
Doug Jones
 

Similar to Turbocharging Client-Side Processing: Leveraging asm.js (20)

Jassa la GeekMeet Bucuresti
Jassa la GeekMeet BucurestiJassa la GeekMeet Bucuresti
Jassa la GeekMeet Bucuresti
 
Emscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math opsEmscripten, asm.js, and billions of math ops
Emscripten, asm.js, and billions of math ops
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 
Asm.js introduction
Asm.js introductionAsm.js introduction
Asm.js introduction
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Divide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.jsDivide and Conquer – Microservices with Node.js
Divide and Conquer – Microservices with Node.js
 
Everyone loves PHP
Everyone loves PHPEveryone loves PHP
Everyone loves PHP
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
JavaScript is the new black - Why Node.js is going to rock your world - Web 2...
 
Node.js on Azure
Node.js on AzureNode.js on Azure
Node.js on Azure
 
SFO15-500: VIXL
SFO15-500: VIXLSFO15-500: VIXL
SFO15-500: VIXL
 
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
Exploiting Multicore CPUs Now: Scalability and Reliability for Off-the-shelf ...
 
Web (dis)assembly
Web (dis)assemblyWeb (dis)assembly
Web (dis)assembly
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
 

More from FITC

Cut it up
Cut it upCut it up
Cut it up
FITC
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
FITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
FITC
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
FITC
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
FITC
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
FITC
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
FITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
FITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
FITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
FITC
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
FITC
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
FITC
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
FITC
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
FITC
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
FITC
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
FITC
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
FITC
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
FITC
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
FITC
 

More from FITC (20)

Cut it up
Cut it upCut it up
Cut it up
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
 

Recently uploaded

一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
keoku
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
VivekSinghShekhawat2
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Brad Spiegel Macon GA
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 

Recently uploaded (20)

一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
一比一原版(SLU毕业证)圣路易斯大学毕业证成绩单专业办理
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptxInternet-Security-Safeguarding-Your-Digital-World (1).pptx
Internet-Security-Safeguarding-Your-Digital-World (1).pptx
 
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptxBridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
Bridging the Digital Gap Brad Spiegel Macon, GA Initiative.pptx
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 

Turbocharging Client-Side Processing: Leveraging asm.js

  • 1. TURBOCHARGING CLIENT-SIDE PROCESSING LEVERAGING ASM.JS Vladimir Vukićević / @vvuk
  • 2. OVERVIEW What is asm.js? Writing asm.js by hand Using Emscripten Integrating libraries What can you do with this
  • 4. vrg=Fot2ra(26) a la3Ary378; fnto mi( { ucin an) vra=0 b=0 a , ; d { o a=8+( < 2 |0 b < ) ; ga> 2 =+[ > 2 +10 [ > ] ga > ] .; b=b+1|0 ; }wie(b|0 <50) hl ( ) 00; } This is asm.js. It's JavaScript, with some rigid rules.
  • 5. asm.js operates on an ArrayBuffer heap asm.js operates only on numeric values asm.js can call regular JavaScript asm.js can be called by regular JavaScript asm.js provides predictable performance
  • 6. TWO WAYS TO USE ASM.JS To bring existing C/C++ apps to the web Many of the current flashy demos do this Great for games Not the focus here To accelerate processing of JS apps Leverage existing libraries Offload and speed up data processing and analysis
  • 7. WRITING ASM.JS BY HAND vrha =nwAryufr49) a ep e raBfe(06; vram=fnto(tlb frin ha){ a s ucinsdi, oeg, ep "s am; ue s" vrHAF2=nwsdi.la3Aryha) a EP3 e tlbFot2ra(ep; fnto aeaeausfrt ls){ ucin vrgVle(is, at frt=frt0 ls =ls|; is is|; at at0 vrcut=0 vrag=00 a on ; a v .; cut=(at-frt > 2 on ls is) > ; wie(frt0 <(at0){ hl (is|) ls|) ag=ag++EP3[is > 2; v v HAF2frt > ] frt=frt+40 is is |; } rtr +ag/+cut0) eun (v (on|); } rtr { eun aeaeaus aeaeaus vrgVle: vrgVle, } ; }wno,{,ha) (idw } ep; / ptsm vle it teha * * u oe aus no h ep / vrHAF2=nwFot2ra(ep; a EP3 e la3Aryha) fr(a i=0 i<2;+i { o vr ; 0 +) HAF2i =i EP3[] ; } / mk tecl * * ae h al / vrag=amaeaeaus0<,2<2; a v s.vrgVle(<2 0<) cnoelgag; osl.o(v)
  • 8. WRITING ASM.JS BY HAND ... DOABLE, BUT PAINFUL. Doable by hand for simple things e.g., a matrix math library It's intended to be a compile target Not just from C/C++! LLJS can target asm.js TypeScript is interested Emscripten for C/C++ source
  • 10. LOTS OF EXISTING CODE OUT THERE For example, open source libraries for... Computer Vision — OpenCV Physics — Box2D, Bullet Compression — zlib, lz4, etc. Text-to-Speech — eSpeak Convex Hull Computation — qhull ...
  • 11. LOTS OF EXISTING CODE OUT THERE Many already have Emscripten ports Some have nice JS layers on top
  • 12. INTEGRATING WITH ASM.JS CODE 1. Get data into asm.js heap vrcnaDt =cxgtmgDt(,0 w h; a avsaa t.eIaeaa0 , , ) / alct saei amj ha * * loae pc n s.s ep / vrhaPr=Mdl.mlo( *h*4; a ept oue_alcw ) vrhaDt =nwUn8ra(EP haPr w*h*4; a epaa e itAryHA, ept, ) / cp cnaDt.aait ha * * oy avsaadt no ep / haDt.e(avsaadt) epaastcnaDt.aa; 2. Call function(s) amouedPoesn(ept,w h; sMdl.orcsighaPr , ) 3. Get data out of heap / cp dt bc t Iaeaa* * oy aa ak o mgDt / cnaDt.aasthaDt) avsaadt.e(epaa; / fe saei amj ha * * re pc n s.s ep / Mdl.fe(ept) oue_rehaPr; / da iaedt bc * * rw mg aa ak / cxptmgDt(avsaa 0 0; t.uIaeaacnaDt, , )
  • 13. INTEGRATING WITH ASM.JS CODE You have to deal with manual memory management and allocation Likely already thinking about it if you're heavily optimizing your JS Make some nice wrappers and avoid having to think about this again
  • 14. NICE WRAPPERS? fnto poesmgDt(mgDt){ ucin rcsIaeaaiaeaa vrw=iaeaawdh h=iaeaahih; a mgDt.it, mgDt.egt vrhaPr=Mdl.mlo( *h*4; a ept oue_alcw ) vrhaDt =nwUn8ra(EP haPr w*h*4; a epaa e itAryHA, ept, ) haDt.e(avsaadt) epaastcnaDt.aa; amouedPoesn(ept,w h; sMdl.orcsighaPr , ) iaeaadt.e(epaa; mgDt.aasthaDt) Mdl.fe(ept) oue_rehaPr; }
  • 15. JUST ANOTHER MODULE JavaScript App App Code EmberJS jQuery ... asm.js code
  • 16. SOME ODDS AND ENDS Use Worker Threads Use async Script Loading
  • 17. USING WORKER THREADS Place your asm.js module on a worker Asynchronous execution, no jank! Main App code postMessage ⇒ request ⇐ postMessage reply Worker asm.js module
  • 18. (ASIDE) WORKERS ARE AWESOME And will get even more awesome We've got lots of APIs coming to workers, including... WebRTC WebGL & Canvas 2D Web Sockets Web Audio Synchronous message passing
  • 19. USING ASYNCHRONOUS SCRIPT LOADING asm.js code can be large, and parsing and compiling takes time. <citaycsc"i/ysLbj"<srp> srp sn r=lbmAmi.s>/cit Add async. Magic. In the (very near) future, such compilation will also be cached.
  • 20. WHAT DO I DO WITH THIS? Processing/resizing of photos client-side (color correction, face identification) Data analysis (download raw data to client)
  • 21. WHAT DO I DO WITH THIS? Face login/confirmation (WebRTC + UserMedia + canvas) Add text-to-speech (read notices in the background)
  • 22. WHAT DO I DO WITH THIS? Implement new image (and video?) codecs (specialized or experimental) Recognize barcodes (handy on mobile!)
  • 23. PERFORMANCE? "Within 2x of native." ... pretty consistently. Even on mobile! Take advantage to make mobile apps feel more like native.
  • 24. IT'S DANGEROUS TO GO ALONE You'll need... Some familiarity with C/C++ (or someone nearby familiar with C/C++) Emscripten and Emscripten SDK
  • 25. NOT JUST FOR C/C++ Focus has been on C/C++ due to large body of existing code Lua, Python, etc. all exist For example, give users ability to write scripts in Lua