WebAssembly

Safe binary format with Web in mind

What is it?

Efficient and portable bytecode

Possible compilation target

Stack machine language

Why?

  • Almost native performance
  • Secure execution model
  • More languages!

How does it look like? v1

00 61 73 6d 01 00 00 00 01 00 01
60 01 7c 01 7c 06 03 00 01 00 02
07 00 01 03 66 61 63 00 00 07 0a
00 01 00 00 20 00 44 00 00 00 00
00 00 f0 3f 63 04 7c 44 00 00 00
00 00 00 f0 3f 05 20 00 20 00 44
00 00 00 00 00 00 f0 3f a1 10 00
a2 0b 0b 2c 2e 00 00 04 6e 61 6d
65 01 00 01 00 03 66 61 63 06 02
00 01 00 01 00 00 05 14

How does it look like? v1

(module
  (func $fac (param f64) (result f64)
    get_local 0
    f64.const 1
    f64.lt
    if (result f64)
      f64.const 1
    else
      get_local 0
      get_local 0
      f64.const 1
      f64.sub
      call $fac
      f64.mul
    end)
  (export "fac" (func $fac)))

How does it look like? v1

const instance = new WebAssembly.Instance(wasm, {});

for (let i = 1; i <= 15; i++) {
  console.log(instance.exports.fac(i));
}

How does it look like? v2

#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern {
   fn alert(s: &str);
}

#[wasm_bindgen]
pub fn greet(name: &str) {
  alert(&format!("Hello, {}!", name));
}

How does it look like? v2

import {greet} from './greet.rs';

greet('World');

How does it look like? v3

Give me numbers!

7 full integrations

15 almost there

11 started

Cool websites

Clearly defined standards

Future!