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
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)
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
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'
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*
Sounds good? Notice how it doesn't mention it's a language?
Jay Phelps
And not really for what you think of as traditional "web"
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
Great improvements but there’s still a visible performance gap
LLVM compiler, Emscripten
Draft Specifications lets browser vendors to start playing around with different solutions
Fast adaptation
Linear memory – untyped array of bytes. Sandboxed
Fast execution – 10% slower than native code, 20× faster parsing
Compact – binary around 20% smaller
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
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
There are many tutorials using older build methods, they can be very confusing be aware
Prelude – loads everything from wasm_bindgen prelude module
#[wasm_bindgen] adds some JavaScript glue code
await import engine is meant to compile while downloading