SlideShare ist ein Scribd-Unternehmen logo
1 von 31
WebAssembly – Future of the web
Guy Nesher
Web Architect @ CodeValue
Mozilla Tech Speaker
Hodash Dev Meetup
@GuyNesher
Introduction To WebAssembly
WebAssembly )WASM(
a binary instruction format for a stack-based
virtual machine.
Wasm is designed as a portable target for
compilation of high-level languages like
C/C++/Rust/Blazor, enabling deployment on
the web for client and server applications.
WebAssembly Simplified
C
C++
wasm html
Compiler
+
JavaScript
Glue Fast Applications
Rust
Blazor
Etc.
Will WebAssembly Replace JavaScript
 The short answer is no
 WebAssembly complements JavaScript
 Useful for heavier processes
 But most applications do not need the extra performance
WebAssembly: Neither Web, Nor Assembly,
but Revolutionary
Jay Phelps
Let's Start At the Beginning
https://xkcd.com/1367/
Web Applications
 No Installation Process
 Cross Platform
 Safe
 But What About Performance?
JavaScript Performance – Prime Numbers
JavaScript Performance – Prime Numbers
2013 The Birth of asm.js
 Subset of JavaScript
 Compile Target for C/C++
 C/C++ -> LLVM -> Emscripten -> JavaScript
 Faster JavaScript (static typing, no garbage collection) etc.
 Still runs on old browsers (just loses some optimization)
Micosoft Demo asm.js vs js
https://bit.ly/2D72ubb
A Brief History
2013 - asm.js compiles C/C++ code to a subset of JavaScript
2015 – W3c forms the WebAssembly committee
2017 – MVP Implementation of WebAssembly in all browsers
2018 – W3C releases draft specification for WebAssembly
Web Assembly MVP
* By Lin Clark, Till Schneidereit, Luke Wagner - https://mzl.la/2TEUrej
WebAssembly MVP Games
Unreal Engine
Unity Engine
Quake
WebAssembly MVP Applications
Adobe Lightroom
Autodesk AutoCAD
WebAssembly MVP Web Applications
eBay barcode scanner – 50FPS
vs 1FPS (scans per seconds),
95% vs 20% success rate
Wordpress Gutenberg post
parser – 96% - 317% parsing
speed increase
But This Is Just The Beginning
WebAssembly Heavyweight Apps
* By Lin Clark, Till Schneidereit, Luke Wagner - https://mzl.la/2TEUrej
WebAssembly JavaScript Integration
* By Lin Clark, Till Schneidereit, Luke Wagner - https://mzl.la/2TEUrej
A Quick Intro to
WebAseembly And Rust
Wait, What’s Rust
 Developed in 2010
 Syntax similar to C++
 Memory Safe
 Used in Production by Dropbox, Yelp, NPM and many others
 The most loved programing 2016 – 2019 (according to Stack Overflow
survey)
 Use rustup - https://rustup.rs/
 Cargo – rust package manager (similar to package.json), packages are
called 'Crates'
C++ FizzBuzz Rust
int main(void)
{
int num;
for(num=1; num<101; ++num)
{
if( num%3 == 0 && num%5 == 0 ) {
printf("fizzbuzzn");
} else if( num%3 == 0) {
printf("fizzn");
} else if( num%5 == 0) {
printf("buzzn");
} else {
printf("%dn",num);
}
}
return 0;
}
FizzBuzz in Rust
fn main() {
for num in 1..101 { // Range notation!
match (num%3, num%5) { // Pattern Matching FTW!
(0, 0) => println!("fizzbuzz"),
(0, _) => println!("fizz"),
(_, 0) => println!("buzz"),
_ => println!("{}", num)
}
}
}
* By Szmozsánszky István https://mzl.la/2JIrfyA
Rust And WebAssembly
 wasm-pack – crate, simplest way to build WebAssembly
 cargo install wasm-pack
 wasm-pack build
 wasm-bindgen – crate which manages JavaScript -> WebAssembly
interaction
 Starting a new project:
 cargo new --lib <project name>
 wasm-pack build
Cargo File
[package]
name = "hello_world"
version = "0.1.0"
authors = ["Guy Nesher <nesher.guy@gmail.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2.42"
Wasm Webpack
const path = require("path");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = {
// ...
plugins: [
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, "crate"),
}),
]
// ...
};
Rust / JavaScript Interaction
Rust Code JavaScript Code
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub extern fn add(x: u32, y: u32) -> u32 {
x + y
}
async function handleAdd(event) {
event.preventDefault();
const { add } = await import(‘../add/pkg’);
console.log(add(2, 3));
console.log(add(100, 500));
}
JavaScript Bindings
import * as wasm from './hello_world_bg';
function _assertNum(n) {
if (typeof(n) !== 'number') throw new Error('expected a number argument');
}
export function add(x, y) {
_assertNum(x);
_assertNum(y);
return wasm.add(x, y) >>> 0;
}
WebAssembly Post MVC Summary
 Fast browser applications
 Using a language of your choice
 Adopted by many large corporations
 .NET Core support using Blazor - http://tiny.cc/bvnh7y
 Or use Rust - http://tiny.cc/6znh7y
 Missing features are coming*
Guy Nesher
Web Architect @ CodeValue
Mozilla Tech Speaker
Photographer
@GuyNesher

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Rust
RustRust
Rust
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
 
Automating security test using Selenium and OWASP ZAP - Practical DevSecOps
Automating security test using Selenium and OWASP ZAP - Practical DevSecOpsAutomating security test using Selenium and OWASP ZAP - Practical DevSecOps
Automating security test using Selenium and OWASP ZAP - Practical DevSecOps
 
Automating with Ansible
Automating with AnsibleAutomating with Ansible
Automating with Ansible
 
Introduction to CloudStack
Introduction to CloudStack Introduction to CloudStack
Introduction to CloudStack
 
JAMstack
JAMstackJAMstack
JAMstack
 
Docker + WASM.pdf
Docker + WASM.pdfDocker + WASM.pdf
Docker + WASM.pdf
 
Web assembly with go
Web assembly with goWeb assembly with go
Web assembly with go
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at Square
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVM
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Building High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol BuffersBuilding High Performance APIs In Go Using gRPC And Protocol Buffers
Building High Performance APIs In Go Using gRPC And Protocol Buffers
 
Introduction à web assembly
Introduction à web assemblyIntroduction à web assembly
Introduction à web assembly
 
Buffer overflow explained
Buffer overflow explainedBuffer overflow explained
Buffer overflow explained
 
Docker and WASM
Docker and WASMDocker and WASM
Docker and WASM
 
wamp.ppt
wamp.pptwamp.ppt
wamp.ppt
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
JAMStack
JAMStackJAMStack
JAMStack
 

Ähnlich wie Web assembly - Future of the Web

Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
OdessaJS Conf
 

Ähnlich wie Web assembly - Future of the Web (20)

WebAssembly
WebAssemblyWebAssembly
WebAssembly
 
WebAssembly - czy dzisiaj mi się to przyda do pracy?
WebAssembly - czy dzisiaj mi się to przyda do pracy?WebAssembly - czy dzisiaj mi się to przyda do pracy?
WebAssembly - czy dzisiaj mi się to przyda do pracy?
 
Web Assembly (on the server)
Web Assembly (on the server)Web Assembly (on the server)
Web Assembly (on the server)
 
Word press workflows and gulp
Word press workflows and gulpWord press workflows and gulp
Word press workflows and gulp
 
Expanding WebAssembly.pdf
Expanding WebAssembly.pdfExpanding WebAssembly.pdf
Expanding WebAssembly.pdf
 
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
Oleksandr Skachkov - WebAssembly vs JavaScript: What is faster?
 
WebAssembly vs JavaScript: What is faster?
WebAssembly vs JavaScript: What is faster?WebAssembly vs JavaScript: What is faster?
WebAssembly vs JavaScript: What is faster?
 
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
(ARC402) Deployment Automation: From Developers' Keyboards to End Users' Scre...
 
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScriptJS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
JS Fest 2018. Александр Скачков. WebAssembly vs JavaScript
 
Modern Static Site with GatsbyJS
Modern Static Site with GatsbyJSModern Static Site with GatsbyJS
Modern Static Site with GatsbyJS
 
WebAssemlby vs JavaScript
WebAssemlby vs JavaScriptWebAssemlby vs JavaScript
WebAssemlby vs JavaScript
 
A glance at the Rust SWC
A glance at the Rust SWCA glance at the Rust SWC
A glance at the Rust SWC
 
Into to Webassmbly
Into to WebassmblyInto to Webassmbly
Into to Webassmbly
 
Introduction of webpack 4
Introduction of webpack 4Introduction of webpack 4
Introduction of webpack 4
 
Rock Solid WordPress
Rock Solid WordPressRock Solid WordPress
Rock Solid WordPress
 
Always on! Or not?
Always on! Or not?Always on! Or not?
Always on! Or not?
 
Web assembly with PWA
Web assembly with PWA Web assembly with PWA
Web assembly with PWA
 
Web Assembly Big Picture
Web Assembly Big PictureWeb Assembly Big Picture
Web Assembly Big Picture
 
Quick overview of WebAssembly
Quick overview of WebAssemblyQuick overview of WebAssembly
Quick overview of WebAssembly
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019
 

Mehr von CodeValue

Mehr von CodeValue (20)

Digital transformation buzzword or reality - Alon Fliess
Digital transformation buzzword or reality - Alon FliessDigital transformation buzzword or reality - Alon Fliess
Digital transformation buzzword or reality - Alon Fliess
 
The IDF's journey to the cloud - Merav
The IDF's journey to the cloud - MeravThe IDF's journey to the cloud - Merav
The IDF's journey to the cloud - Merav
 
When your release plan is concluded at the HR office - Hanan Zakai
When your release plan is concluded at the HR office - Hanan  ZakaiWhen your release plan is concluded at the HR office - Hanan  Zakai
When your release plan is concluded at the HR office - Hanan Zakai
 
We come in peace hybrid development with web assembly - Maayan Hanin
We come in peace hybrid development with web assembly - Maayan HaninWe come in peace hybrid development with web assembly - Maayan Hanin
We come in peace hybrid development with web assembly - Maayan Hanin
 
The IoT Transformation and What it Means to You - Nir Dobovizky
The IoT Transformation and What it Means to You - Nir DobovizkyThe IoT Transformation and What it Means to You - Nir Dobovizky
The IoT Transformation and What it Means to You - Nir Dobovizky
 
State in stateless serverless functions - Alex Pshul
State in stateless serverless functions - Alex PshulState in stateless serverless functions - Alex Pshul
State in stateless serverless functions - Alex Pshul
 
Will the Real Public API Please Stand Up? Amir Zuker
Will the Real Public API Please Stand Up? Amir ZukerWill the Real Public API Please Stand Up? Amir Zuker
Will the Real Public API Please Stand Up? Amir Zuker
 
How I built a ml human hybrid workflow using computer vision - Amir Shitrit
How I built a ml human hybrid workflow using computer vision - Amir ShitritHow I built a ml human hybrid workflow using computer vision - Amir Shitrit
How I built a ml human hybrid workflow using computer vision - Amir Shitrit
 
Application evolution strategy - Eran Stiller
Application evolution strategy - Eran StillerApplication evolution strategy - Eran Stiller
Application evolution strategy - Eran Stiller
 
Designing products in the digital transformation era - Eyal Livne
Designing products in the digital transformation era - Eyal LivneDesigning products in the digital transformation era - Eyal Livne
Designing products in the digital transformation era - Eyal Livne
 
Eerez Pedro: Product thinking 101 - Architecture Next
Eerez Pedro: Product thinking 101 - Architecture NextEerez Pedro: Product thinking 101 - Architecture Next
Eerez Pedro: Product thinking 101 - Architecture Next
 
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
 
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
Amir Zuker: Building web apps with web assembly and blazor - Architecture Nex...
 
Magnus Mårtensson: The Cloud challenge is more than just technical – people a...
Magnus Mårtensson: The Cloud challenge is more than just technical – people a...Magnus Mårtensson: The Cloud challenge is more than just technical – people a...
Magnus Mårtensson: The Cloud challenge is more than just technical – people a...
 
Nir Doboviski: In Space No One Can Hear Microservices Scream – a Microservice...
Nir Doboviski: In Space No One Can Hear Microservices Scream – a Microservice...Nir Doboviski: In Space No One Can Hear Microservices Scream – a Microservice...
Nir Doboviski: In Space No One Can Hear Microservices Scream – a Microservice...
 
Vered Flis: Because performance matters! Architecture Next 20
Vered Flis: Because performance matters! Architecture Next 20Vered Flis: Because performance matters! Architecture Next 20
Vered Flis: Because performance matters! Architecture Next 20
 
Vitali zaidman Do You Need Server Side Rendering? What Are The Alternatives?
Vitali zaidman Do You Need Server Side Rendering? What Are The Alternatives?Vitali zaidman Do You Need Server Side Rendering? What Are The Alternatives?
Vitali zaidman Do You Need Server Side Rendering? What Are The Alternatives?
 
Ronen Levinson: Unified policy enforcement with opa - Architecture Next 20
Ronen Levinson: Unified policy enforcement with opa - Architecture Next 20Ronen Levinson: Unified policy enforcement with opa - Architecture Next 20
Ronen Levinson: Unified policy enforcement with opa - Architecture Next 20
 
Moaid Hathot: Dapr the glue to your microservices - Architecture Next 20
Moaid Hathot: Dapr  the glue to your microservices - Architecture Next 20Moaid Hathot: Dapr  the glue to your microservices - Architecture Next 20
Moaid Hathot: Dapr the glue to your microservices - Architecture Next 20
 
Eyal Ellenbogen: Building a UI Foundation for Scalability - Architecture Next 20
Eyal Ellenbogen: Building a UI Foundation for Scalability - Architecture Next 20Eyal Ellenbogen: Building a UI Foundation for Scalability - Architecture Next 20
Eyal Ellenbogen: Building a UI Foundation for Scalability - Architecture Next 20
 

Kürzlich hochgeladen

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Kürzlich hochgeladen (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Web assembly - Future of the Web

  • 1. WebAssembly – Future of the web Guy Nesher Web Architect @ CodeValue Mozilla Tech Speaker Hodash Dev Meetup @GuyNesher
  • 3. WebAssembly )WASM( a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust/Blazor, enabling deployment on the web for client and server applications.
  • 5. Will WebAssembly Replace JavaScript  The short answer is no  WebAssembly complements JavaScript  Useful for heavier processes  But most applications do not need the extra performance
  • 6. WebAssembly: Neither Web, Nor Assembly, but Revolutionary Jay Phelps
  • 7. Let's Start At the Beginning https://xkcd.com/1367/
  • 8. Web Applications  No Installation Process  Cross Platform  Safe  But What About Performance?
  • 10. JavaScript Performance – Prime Numbers
  • 11. 2013 The Birth of asm.js  Subset of JavaScript  Compile Target for C/C++  C/C++ -> LLVM -> Emscripten -> JavaScript  Faster JavaScript (static typing, no garbage collection) etc.  Still runs on old browsers (just loses some optimization)
  • 12. Micosoft Demo asm.js vs js https://bit.ly/2D72ubb
  • 13. A Brief History 2013 - asm.js compiles C/C++ code to a subset of JavaScript 2015 – W3c forms the WebAssembly committee 2017 – MVP Implementation of WebAssembly in all browsers 2018 – W3C releases draft specification for WebAssembly
  • 14. Web Assembly MVP * By Lin Clark, Till Schneidereit, Luke Wagner - https://mzl.la/2TEUrej
  • 15. WebAssembly MVP Games Unreal Engine Unity Engine Quake
  • 16. WebAssembly MVP Applications Adobe Lightroom Autodesk AutoCAD
  • 17. WebAssembly MVP Web Applications eBay barcode scanner – 50FPS vs 1FPS (scans per seconds), 95% vs 20% success rate Wordpress Gutenberg post parser – 96% - 317% parsing speed increase
  • 18. But This Is Just The Beginning
  • 19. WebAssembly Heavyweight Apps * By Lin Clark, Till Schneidereit, Luke Wagner - https://mzl.la/2TEUrej
  • 20. WebAssembly JavaScript Integration * By Lin Clark, Till Schneidereit, Luke Wagner - https://mzl.la/2TEUrej
  • 21. A Quick Intro to WebAseembly And Rust
  • 22. Wait, What’s Rust  Developed in 2010  Syntax similar to C++  Memory Safe  Used in Production by Dropbox, Yelp, NPM and many others  The most loved programing 2016 – 2019 (according to Stack Overflow survey)  Use rustup - https://rustup.rs/  Cargo – rust package manager (similar to package.json), packages are called 'Crates'
  • 23. C++ FizzBuzz Rust int main(void) { int num; for(num=1; num<101; ++num) { if( num%3 == 0 && num%5 == 0 ) { printf("fizzbuzzn"); } else if( num%3 == 0) { printf("fizzn"); } else if( num%5 == 0) { printf("buzzn"); } else { printf("%dn",num); } } return 0; }
  • 24. FizzBuzz in Rust fn main() { for num in 1..101 { // Range notation! match (num%3, num%5) { // Pattern Matching FTW! (0, 0) => println!("fizzbuzz"), (0, _) => println!("fizz"), (_, 0) => println!("buzz"), _ => println!("{}", num) } } } * By Szmozsánszky István https://mzl.la/2JIrfyA
  • 25. Rust And WebAssembly  wasm-pack – crate, simplest way to build WebAssembly  cargo install wasm-pack  wasm-pack build  wasm-bindgen – crate which manages JavaScript -> WebAssembly interaction  Starting a new project:  cargo new --lib <project name>  wasm-pack build
  • 26. Cargo File [package] name = "hello_world" version = "0.1.0" authors = ["Guy Nesher <nesher.guy@gmail.com>"] edition = "2018" [lib] crate-type = ["cdylib"] [dependencies] wasm-bindgen = "0.2.42"
  • 27. Wasm Webpack const path = require("path"); const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); module.exports = { // ... plugins: [ new WasmPackPlugin({ crateDirectory: path.resolve(__dirname, "crate"), }), ] // ... };
  • 28. Rust / JavaScript Interaction Rust Code JavaScript Code use wasm_bindgen::prelude::*; #[wasm_bindgen] pub extern fn add(x: u32, y: u32) -> u32 { x + y } async function handleAdd(event) { event.preventDefault(); const { add } = await import(‘../add/pkg’); console.log(add(2, 3)); console.log(add(100, 500)); }
  • 29. JavaScript Bindings import * as wasm from './hello_world_bg'; function _assertNum(n) { if (typeof(n) !== 'number') throw new Error('expected a number argument'); } export function add(x, y) { _assertNum(x); _assertNum(y); return wasm.add(x, y) >>> 0; }
  • 30. WebAssembly Post MVC Summary  Fast browser applications  Using a language of your choice  Adopted by many large corporations  .NET Core support using Blazor - http://tiny.cc/bvnh7y  Or use Rust - http://tiny.cc/6znh7y  Missing features are coming*
  • 31. Guy Nesher Web Architect @ CodeValue Mozilla Tech Speaker Photographer @GuyNesher

Hinweis der Redaktion

  1. Sounds good? Notice how it doesn't mention it's a language? 
  2. Jay Phelps
  3. And not really for what you think of as traditional "web"
  4. No installation – reduce drop in sales, easier for corporations Cross Platform – Windows Phone, KaiOS & feature phones Safe – sandboxed, we aren’t afraid to browse sites
  5. Great improvements but there’s still a visible performance gap
  6. LLVM compiler, Emscripten
  7. Draft Specifications lets browser vendors to start playing around with different solutions Fast adaptation
  8. Linear memory – untyped array of bytes. Sandboxed Fast execution – 10% slower than native code, 20× faster parsing Compact – binary around 20% smaller
  9. Threading – delay due to Spectre security SIMD – Single instruction, multiple data – under active development 64-bit – general idea how to implement Loat Time improvements – Streaming Compilation, Tired Compilation, Implicit HTTP Caching
  10. Fast calls – 2017, minimal support. Already implemented in most browsers Data Exchange – WebAssembly supports only numbers, interaction via serialization to linear memory Proposal Module Integration – Module integration with JS Proposal Toolchain Integration - webpack Plugin wasm-pack Backward compatibility - wasm2js
  11. There are many tutorials using older build methods, they can be very confusing be aware
  12. Prelude – loads everything from wasm_bindgen prelude module #[wasm_bindgen] adds some JavaScript glue code await import engine is meant to compile while downloading