SlideShare a Scribd company logo
WebAssembly brings
the Web to a new era
Boyan Mihaylov
@bmihaylov
WebAssembly (WASM) is compiler
target for programs on the Web
@bmihaylov
function add(a, b) {
return a + b;
}
@bmihaylov
@bmihaylov
@bmihaylov
weak typing, implicit conversion
…not really consistent
string – string = number ?
“+” is for concatenation
“+ +” is for addition ?
@bmihaylov
JavaScript performance over the years
1995 2008 2017
Browser wars:
the introduction of JIT
?
Node.js
@bmihaylov
Reusing code on the Web
@bmihaylov
What doesWebAssembly bring?
@bmihaylov
WebAssembly runs in a memory-safe
sandboxed environment
@bmihaylov
@bmihaylov
VM
JavaScript WebAssembly
GC Compiler …
APIs
Rendering DOM + CSSOM
WebGL
WebSockets
WebAudio IndexedDB
ServiceWorkers …
Resource
<script> HTML, CSS, SVG, …
Audio
Storage
Network
Graphics
…
Sandbox, Same-origin policy, …
WebAssembly provides consistent,
predictable performance
@bmihaylov
@bmihaylov
Parse
Compile
+
optimize
Re-
optimize
Execute GC
Decode
Compile
+
optimize
Execute
WebAssembly enables code reusability
between native andWeb
@bmihaylov
Joint venture
@bmihaylov
Where is WebAssembly useful?
@bmihaylov
Gaming industry
Unreal, Unity
Multimedia
AV1, FLIF, BPG
Libraries
OpenCV, Box2D, LibSass
Platform simulation / emulation
DOSBox, MAME, QEMU
Demo: Tanks
http://webassembly.org/demo/Tanks/
@bmihaylov
Demo: Video editor
https://github.com/shamadee/web-dsp
@bmihaylov
How to produceWebAssembly?
@bmihaylov
.c
C/C++ code
.wasm .html
WASM module HTML page Browser
compilation
loading with
JavaScript execution
@bmihaylov
Open Source LLVM to JavaScript compiler
emcc index.c –s WASM=1 –o index.js
@bmihaylov
How compilers work
@bmihaylov
Source
program
Intermediate
Representation (IR)
Assembly or
machine code
Frontend Backend
Static analysis
Semantic analysis
Code generation
Code optimization
How Emscripten works
@bmihaylov
.c / .cpp LLVM IR .js
clang
Fastcomp
(LLVM Backend)
asm.js is an extraordinarily optimizable,
low-level subset of JavaScript
@bmihaylov
asm.js
@bmihaylov
function () {
“use asm”;
function add(a, b) {
a = a | 0;
b = b | 0;
return a + b | 0;
}
return { add: add };
}
asm.js performance
@bmihaylov http://kripken.github.io/mloc_emscripten_talk/#/28
WebAssembly = asm.js done right
@bmihaylov
From asm.js to WebAssembly
@bmihaylov
.c / .cpp LLVM IR asm.js
clang Fastcomp
WASM
?
Binaryen is a compiler and toolchain
infrastructure library for WebAssembly
rhymes withTargaryen (GoT)
@bmihaylov
From asm.js to WebAssembly
@bmihaylov
.c / .cpp LLVM IR asm.js
clang Fastcomp
WASM
asm2wasm
New WebAssembly Backend (unstable)
@bmihaylov
.c / .cpp LLVM IR .wasm
clang
LLVMWASM
Backend
DEMO: From C toWebAssembly
@bmihaylov
The distributable, loadable, and
executable unit of code in
WebAssembly is called a module.
@bmihaylov https://github.com/WebAssembly/design/blob/master/Modules.md
LoadingWebAssembly
@bmihaylov
.wasm
ArrayBuffer
WASM
module
WASM
instance
fetch
WebAssembly.compile
WebAssembly.instantiate
WebAssembly modules are clonable
@bmihaylov
.wasm
ArrayBuffer
WASM
module
WASM
instance
IndexedDB
store / load
(Future) integration with ES6 modules
@bmihaylov
<script type=“module”>
import * as app from ‘app.wasm’;
console.log(app.add(2, 3));
</script>
DEMO: WebAssembly  JavaScript
@bmihaylov
10 00 0F 20 01 7F 03 80 7F 01
0F 80 80 00 01 0F 80 80 80 00
01 97 46 6C 0B 00 10 00 0F 20
01 7F 03 80 7F 01 0F 80 80 80
00 01 97 46 6C 0B 10 00 0F 20
01 7F 03 80 7F 01 0F 80 80 00
46 6C 0B 10 10 00 0F 20 01 7F
03 80 7F 46 6C 0B 10 10 00 0F
@bmihaylov
Binary can be a bit overwhelming
Textual representation
@bmihaylov
int add(int a, int b) {
return a + b;
}
(module
(export “add” (func $add))
(func $add (param $0 i32) (param $1 i32) (result i32)
(i32.add
(get_local $1)
(get_local $0)
)
)
)
.c
.wast
@bmihaylov
WebAssembly Explorer
https://mbebenita.github.io/WasmExplorer/
@bmihaylov http://caniuse.com/#search=WebAssembly
What’s next?
@bmihaylov
Direct access toWebAPIs
today everything goes through JavaScript
@bmihaylov
Integration with browser’s
garbage collection
for better interop with JavaScript & WebAPIs
@bmihaylov
Multi-threading
low-level buildings blocks for shared memory
between threads, atomics and futexes
@bmihaylov
@bmihaylov
“We think Swift should be
everywhere and used by everyone.”
Craig Federighi
Apple’sWWDC 2015
https://media.wired.com/photos/593758ff5321273fc0f945e5/master/w_2666,c_limit/AppleEventTA-539935348.jpg
@bmihaylov
@bmihaylov
“WebAssembly fills in the gaps that would
be awkward to fill with JavaScript.”
Eric Elliott
https://jeremybutterfield.files.wordpress.com/2014/12/conclusion.jpg
@bmihaylov
WebAssembly makes the Web
just a compiler target away
Boyan Mihaylov / @bmihaylov / boyan.in

More Related Content

ODP
Using the Mobile Data service on IBM Bluemix with an AngularJS web app
ODP
Extending An Android App Using the IBM Push for Bluemix Cloud Service
PDF
Web Assembly (W3C TPAC presentation)
PDF
DevOps and Hybrid Applications: What You Need to Know
PPTX
Web assembly - Future of the Web
PPTX
Serverless + Machine Learning – Bringing the best of two worlds together
PPTX
ITGM#14 - How do we use Kubernetes in Zalando
PDF
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps
Using the Mobile Data service on IBM Bluemix with an AngularJS web app
Extending An Android App Using the IBM Push for Bluemix Cloud Service
Web Assembly (W3C TPAC presentation)
DevOps and Hybrid Applications: What You Need to Know
Web assembly - Future of the Web
Serverless + Machine Learning – Bringing the best of two worlds together
ITGM#14 - How do we use Kubernetes in Zalando
Optimizing and Extending Xamarin.Forms iOS, Android, and UWP Apps

What's hot (17)

PDF
Xamarin: The Future of App Development
PDF
Xamarin Froms 4.x
PDF
WebAssembly vs JavaScript: What is faster?
PDF
Get your mobile app in production in 3 months: Native and Reactive Mobile Apps
PDF
What's New in Xamarin? - Santo Domingo
PDF
Get your mobile app in production in 3 months: Native and Reactive Mobile Apps
PDF
WebAssembly Overview
PDF
Codemotion Berlin 2017 - Event-driven and serverless applications with IBM Cl...
PPTX
Cmdb
PDF
WebAssembly in Houdini CSS, is it possible?
PDF
Microprofile at IBM with Liberty
PPTX
VM Job Queues in CloudStack
PDF
Hogarama Demo on Openshift I
PPTX
Developing ASP.NET AJAX Controls with Silverlight
PDF
Helm your way with Kubernetes
PDF
CQRS and Event Sourcing in the AWS Cloud
ODP
Ensemble oscon 2011
Xamarin: The Future of App Development
Xamarin Froms 4.x
WebAssembly vs JavaScript: What is faster?
Get your mobile app in production in 3 months: Native and Reactive Mobile Apps
What's New in Xamarin? - Santo Domingo
Get your mobile app in production in 3 months: Native and Reactive Mobile Apps
WebAssembly Overview
Codemotion Berlin 2017 - Event-driven and serverless applications with IBM Cl...
Cmdb
WebAssembly in Houdini CSS, is it possible?
Microprofile at IBM with Liberty
VM Job Queues in CloudStack
Hogarama Demo on Openshift I
Developing ASP.NET AJAX Controls with Silverlight
Helm your way with Kubernetes
CQRS and Event Sourcing in the AWS Cloud
Ensemble oscon 2011
Ad

Similar to Web assembly brings the web to a new era (20)

PDF
How WebAssembly is changing the Web and what it means for Angular
PDF
Voxxed Athens 2018 - How WebAssembly is changing the Web and what it means to...
PDF
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
PDF
Spring Cloud Function
PPTX
AWS DevDay Vienna - Automating building blocks choices you will face with con...
PDF
WebAssembly - czy dzisiaj mi się to przyda do pracy?
PDF
Web Assembly (on the server)
PDF
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
PPTX
AWS DevDay Cologne - Automating building blocks choices you will face with co...
PPTX
WebAssembly WASM Introduction Presentation
PPTX
AWS DevDay Berlin - Automating building blocks choices you will face with con...
PDF
WebAssembly
PDF
2023-09-28-AWS Las Palmas UG - Dynamic Anti-Frigile Systems.pdf
PPTX
Migrating MVVM Applications to HTML5
PPTX
WinJS at NYC Code Camp 2012
PPTX
JS digest. Mid-Summer 2017
PDF
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
PPSX
Web development concepts using microsoft technologies
PPTX
Into to Webassmbly
PDF
PhoneGap Introduction
How WebAssembly is changing the Web and what it means for Angular
Voxxed Athens 2018 - How WebAssembly is changing the Web and what it means to...
Voxxed Days Thessaloniki 2016 - Web assembly : the browser vm we were waiting...
Spring Cloud Function
AWS DevDay Vienna - Automating building blocks choices you will face with con...
WebAssembly - czy dzisiaj mi się to przyda do pracy?
Web Assembly (on the server)
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
AWS DevDay Cologne - Automating building blocks choices you will face with co...
WebAssembly WASM Introduction Presentation
AWS DevDay Berlin - Automating building blocks choices you will face with con...
WebAssembly
2023-09-28-AWS Las Palmas UG - Dynamic Anti-Frigile Systems.pdf
Migrating MVVM Applications to HTML5
WinJS at NYC Code Camp 2012
JS digest. Mid-Summer 2017
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
Web development concepts using microsoft technologies
Into to Webassmbly
PhoneGap Introduction
Ad

More from Boyan Mihaylov (16)

PDF
Crafting a robust deployment pipeline in finance
PDF
Using improv techniques for better agile teams
PDF
Showdown CI/CD - TeamCity
PDF
Stop the internet, i want to go offline
PPTX
Shifting to agile
PDF
Is WebAssembly the killer of JavaScript?
PDF
Lean or agile, software architecture is fragile
PPTX
Software architecture also needs agile
PPTX
Flux architecture
PPTX
AngularJS 2.0
PPTX
To SPA or not to SPA
PPTX
The AngularJS way
PPTX
Agile software architecture
PPTX
Component-driven development with AngularJS
PPTX
Bringing the light to the client with KnockoutJS
PPTX
Identifying methods for measuring emotions
Crafting a robust deployment pipeline in finance
Using improv techniques for better agile teams
Showdown CI/CD - TeamCity
Stop the internet, i want to go offline
Shifting to agile
Is WebAssembly the killer of JavaScript?
Lean or agile, software architecture is fragile
Software architecture also needs agile
Flux architecture
AngularJS 2.0
To SPA or not to SPA
The AngularJS way
Agile software architecture
Component-driven development with AngularJS
Bringing the light to the client with KnockoutJS
Identifying methods for measuring emotions

Recently uploaded (20)

PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
presentation_pfe-universite-molay-seltan.pptx
DOC
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
artificial intelligence overview of it and more
PPTX
Mathew Digital SEO Checklist Guidlines 2025
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PPTX
Introduction to cybersecurity and digital nettiquette
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
newyork.pptxirantrafgshenepalchinachinane
PPT
Ethics in Information System - Management Information System
DOCX
Unit-3 cyber security network security of internet system
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
Introduction to Information and Communication Technology
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
Design_with_Watersergyerge45hrbgre4top (1).ppt
presentation_pfe-universite-molay-seltan.pptx
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
INTERNET------BASICS-------UPDATED PPT PRESENTATION
artificial intelligence overview of it and more
Mathew Digital SEO Checklist Guidlines 2025
Unit-1 introduction to cyber security discuss about how to secure a system
Introduction to cybersecurity and digital nettiquette
SASE Traffic Flow - ZTNA Connector-1.pdf
Slides PDF The World Game (s) Eco Economic Epochs.pdf
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
SAP Ariba Sourcing PPT for learning material
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
newyork.pptxirantrafgshenepalchinachinane
Ethics in Information System - Management Information System
Unit-3 cyber security network security of internet system
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
Introduction to Information and Communication Technology
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
The New Creative Director: How AI Tools for Social Media Content Creation Are...

Web assembly brings the web to a new era

Editor's Notes

  • #3: WebAssembly lets developers compile from C/C++ or other static-type programming languages in a format that can be loaded in the browser It lets us reuse code and build high-performance apps running in the browser
  • #8: JavaScript is a dynamic language Parsing becomes the bottleneck
  • #25: Started by Mozilla in 2013 Defines a subset of JavaScript Does only low-level, assembly-like computations
  • #28: WebAssembly lets developers compile from C/C++ or other static-type programming languages in a format that can be loaded in the browser It lets us reuse code and create high-performance apps running in the browser
  • #30: Compiler and toolchain infrastructure library for WebAssembly asm2wasm – an asm.js-to-WebAssembly compiler tool Integrated in Emscripten
  • #32: - Not stable yet
  • #33: Show basic compilation of a C program to WASM Which files are produced and what they are used for How to include it JavaScript Show basic hello world compilation with printf
  • #38: Importing JavaScript functions Exporting WASM functions