Wonderful WebAssembly

Wonderful WebAssembly

WebAssembly is neither "web" nor "assembly" - but 100% amazing. It is our one chance to build a fast, safe, and universal compilation target for all languages and all platforms.

Let me show you why this is cool and how to get started with WebAssembly in Go, C, and Rust.

We will also learn about up and coming features of WebAssembly (like WASI) that will make it even faster and more versatile. Let's change the way we write software forever!

Ed9e9992fe069a0d3de05b69d8d187c3?s=128

Matthias Endler

November 07, 2019
Tweet

Transcript

  1. ...and the future of computing Webassembly Wonderful !

  2. Matthias Endler ...works at trivago ...mostly Backend ...afraid of Frontend

    ...Python/Golang/Rust ...Runs "Hello Rust" https://endler.dev
  3. hello-rust.show

  4. None
  5. None
  6. None
  7. None
  8. ? ? ?

  9. Ritchie Thompson Kernighan

  10. None
  11. None
  12. " UNIX is very simple.
 It just takes a genius


    to understand its simplicity. " -- Dennis Ritchie
  13. None
  14. " C is what made
 Unix portable " -- Dennis

    Ritchie
  15. None
  16. None
  17. <HTML> <HEAD> <TITLE>WWW</TITLE> </HEAD> <BODY> <BLINK>Hello, World!</BLINK> </BODY> </HTML>

  18. None
  19. None
  20. None
  21. None
  22. None
  23. None
  24. function Vb(d) { d = d | 0; var e

    = 0, f = 0, h = 0, j = 0, k = 0, l = 0, m = 0, n = 0, o = 0, p = 0, q = 0, r = 0, s = 0; e = i; i = i + 12 | 0; f = e | 0; [l + 4 >> 2] = 0; l = (c[1384465] | 0) + 3 | 0; do { if (l >>> 0 < 26) { if ((c[1356579] | 0) > 0) { m = d + 4 | 0; n = 0; while (1) { o = c[(c[1356577] | 0) + (n << 2) >> 2] | 0; do { if (a[o + 22 | 0] << 24 >> 24 == 24) { if (!(Vp(d, o | 0) | 0)) { break } p = (c[m >> 2] | 0) + (((c[h >> 2] | 0) - 1 | 0) * 40 & -1) + 12 | 0; q = o + 28 | 0; c[p >> 2] = c[q >> 2] | 0; c[p + 4 >> 2] = c[q + 4 >> 2] | 0; c[p + 8 >> 2] = c[q + 8 >> 2] | 0; c[p + 12 >> 2] = c[q + 12 >> 2] | 0; c[p + 16 >> 2] = c[q + 16 >> 2] | 0; asm.js
  25. [Source]

  26. •Performance differences between browsers •Still requires 
 parsing, compiling, optimising

    •No specification Disadvantages of asm.js
  27. Enter WASM (Webassembly)

  28. None
  29. None
  30. None
  31. None
  32. None
  33. None
  34. •Fast •Safe •Well defined •Language-independent •Streamable •Parallelizable Wasm is .

    . .
  35. Wasm is . . . 
 neither web nor assembly

  36. Decoding Validation Execution

  37. https://blog.logrocket.com/webassembly-how-and-why-559b7f96cd71/

  38. i32, i64, f32, f64 that's it. Datatypes!

  39. 1 5 3

  40. 1 5 3 0

  41. 5 3

  42. None
  43. None
  44. (module)

  45. 0000000: 0061 736d ; WASM_BINARY_MAGIC 0000004: 0100 0000 ; WASM_BINARY_VERSION

  46. ( func <signature> <locals> <body> )

  47. // JavaScript
 function add(a, b) { return a + b;

    }
  48. (func (param i32) (param i32) (result f64) <body> )

  49. (func (param i32) (param f32) (local f64) get_local 0 get_local

    1 get_local 2 )
  50. (func (param $foo i32) (param $bar f32) (local $baz f64)

    get_local $foo get_local $bar get_local $baz )
  51. (module ( func (param $a i32) (param $b i32) (result

    i32) get_local $a get_local $b i32.add ) )
  52. (module (func $add (param $a i32) (param $b i32) (result

    i32) get_local $a get_local $b i32.add) (export "add" (func $add)) )
  53. (module (type $type0 (func (result i32))) (table 0 anyfunc) (memory

    1) (export "memory" memory) (export "hello" $func0) (func $func0 (result i32) i32.const 16 ) (data (i32.const 16) "Hello World\00" ) )
  54. None
  55. wasm2wat wat2wasm

  56. None
  57. None
  58. None
  59. None
  60. None
  61. None
  62. 0 750 1500 2250 3000 Go C Rust How big

    is " Hello World " (in KB)? 40k 1k
  63. None
  64. 0 750 1500 2250 3000 Go C Rust "Hello World"

    unoptimized (KB) 40k 1k
  65. 0 750 1500 2250 3000 Go C Rust "Hello World"

    unoptimized (KB) 20k 400 bytes
  66. Examples!

  67. Wasm!

  68. https://endler.dev/2019/tinysearch

  69. https://squoosh.app/editor

  70. None
  71. " Serverless "

  72. None
  73. None
  74. None
  75. None
  76. None
  77. None
  78. None
  79. https://wapm.io/

  80. https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/

  81. None
  82. https://www.youtube.com/watch?v=QKTh5Xj60pI

  83. Thanks! endler.dev/talks