Rust and WebAssembly for the masses

Rust and WebAssembly for the masses

32e6a76c61f41da3beca909251498c60?s=128

Sendil Kumar N

February 05, 2020
Tweet

Transcript

  1. @sendilkumarn Hej! Stockholm

  2. @sendilkumarn Every progra!"ing language has trade-offs. Choose one that solves

    your problem, not creates one.
  3. Rust and WebAssembly Sendil Kumar N

  4. @sendilkumarn Sendil Kumar

  5. @sendilkumarn

  6. @sendilkumarn Netherlands

  7. @sendilkumarn Senior Software Engineer @uber

  8. @sendilkumarn Passionate about Open Source Senior Software Engineer @uber

  9. @sendilkumarn Passionate about Open Source Senior Software Engineer @uber Team

    member @JHipster
  10. @sendilkumarn Passionate about Open Source Senior Software Engineer @uber Team

    member @JHipster Hacking on WebAssembly
  11. What is WASM? How WASM helps? DEMO Why Rust? Rust

    and WASM DEMO WASM Roadmap Agenda @sendilkumarn
  12. WebAssembly @sendilkumarn

  13. Yet Another Frontend framework?

  14. @sendilkumarn 00 61 73 6D 01 00 00 00 Native

    Code WebAssembly Binary JavaScript Javascript Engine
  15. @sendilkumarn func add is called Stack get_local $lhs LHS RHS

    get_local $rhs i32.add SUM Structured stack machine
  16. @sendilkumarn 00 61 73 6D 01 00 00 00 Size

    & Load time efficient
  17. @sendilkumarn Native Speed 00 61 73 6D 01 00 00

    00
  18. @sendilkumarn madewithwebassembly.com

  19. Why not JavaScript? @sendilkumarn

  20. JavaScript is awesome @sendilkumarn

  21. JavaScript is easy @sendilkumarn

  22. JavaScript is weird* * - sometimes @sendilkumarn

  23. [] + {} @sendilkumarn

  24. [] + {} “[object Object]” @sendilkumarn

  25. {} + [] @sendilkumarn

  26. 0 {} + [] @sendilkumarn

  27. [] + {} === {} + [] @sendilkumarn

  28. [] + {} === {} + [] True @sendilkumarn

  29. @sendilkumarn JavaScript Tuning

  30. @sendilkumarn Types

  31. @sendilkumarn Polymorphism

  32. @sendilkumarn Unpredictable Performance

  33. @sendilkumarn Runtime exceptions

  34. @sendilkumarn A B

  35. @sendilkumarn A B [empty x 5] []

  36. @sendilkumarn A B [1, empty x 4] [1, 2, empty

    x 3] [1, 2, 3, empty x 2] [1, 2, 3, 4, empty x 1] [1, 2, 3, 4, 5] [1] [1, 2] [1, 2, 3] [1, 2, 3, 4] [1, 2, 3, 4, 5]
  37. @sendilkumarn A B Holey Array Packed Array

  38. @sendilkumarn How WebAssembly address the problems?

  39. @sendilkumarn Speed

  40. @sendilkumarn Near Native perf.

  41. @sendilkumarn ˜30% faster than JS

  42. @sendilkumarn Boundary Crossing

  43. @sendilkumarn Not always faster

  44. @sendilkumarn WebAssembly is secure

  45. @sendilkumarn Linear Memory Model

  46. @sendilkumarn Shared Array Buffer

  47. @sendilkumarn How it works… Why it is faster?

  48. @sendilkumarn JavaScript Execution

  49. @sendilkumarn Load JavaScript

  50. @sendilkumarn a.js AST 1001010010101101010 Execute Profiler Parse Interpret Compile 100101001010

    Optimise 1010 GC
  51. @sendilkumarn WebAssembly Execution

  52. @sendilkumarn Load WebAssembly

  53. @sendilkumarn Decode Compile Execute 00 61 73 6D 00 61

    73 6D 00 61 73 6D
  54. @sendilkumarn PARSE COMPILE OPTIMISE EXECUTE GC JavaScript execution DECODE COMPILE

    EXECUTE WebAssembly execution
  55. @sendilkumarn PARSE COMPILE OPTIMISE EXECUTE GC JavaScript execution DECODE COMPILE

    EXECUTE WebAssembly execution I am faster
  56. @sendilkumarn PARSE COMPILE OPTIMISE EXECUTE GC JavaScript execution DECODE COMPILE

    EXECUTE WebAssembly execution Optimised already
  57. @sendilkumarn Streaming compilation

  58. @sendilkumarn Typed

  59. @sendilkumarn (module )

  60. @sendilkumarn (module (func $add (param $lhs i32) (param $rhs i32)

    (result i32) (get_local $lhs) (get_local $rhs) (i32.add) ) )
  61. @sendilkumarn (module (func $add (param $lhs i32) (param $rhs i32)

    (result i32) (get_local $lhs) (get_local $rhs) (i32.add) ) (export “add” (func $add)) )
  62. @sendilkumarn i32 i64 f32 f64 00 61 73 6D 01

    00 00 00 WebAssembly Binary JavaScript Javascript Engine
  63. Demo bit.ly/wasm2020-001 @sendilkumarn

  64. Why Rust? @sendilkumarn

  65. @sendilkumarn Blazingly fast @sendilkumarn

  66. @sendilkumarn Memory Safety

  67. @sendilkumarn Productivity

  68. @sendilkumarn Friendly compiler

  69. @sendilkumarn Better tooling support

  70. @sendilkumarn Awesome co!"unity

  71. @sendilkumarn Modern language

  72. @sendilkumarn Crates

  73. @sendilkumarn wasm_bindgen https://github.com/rustwasm/wasm-bindgen

  74. @sendilkumarn i32 i64 f32 f64 00 61 73 6D 01

    00 00 00 WebAssembly Binary JavaScript Javascript Engine
  75. @sendilkumarn 00 61 73 6D 01 00 00 00 WebAssembly

    Binary JavaScript Javascript Engine Binding JS file JS API WEB API JS SYS WEB SYS
  76. @sendilkumarn wasm_pack https://github.com/rustwasm/wasm-pack

  77. @sendilkumarn PACK PUBLISH TEST BUILD

  78. @sendilkumarn wasm_snip https://github.com/rustwasm/wasm-snip

  79. @sendilkumarn twiggy https://github.com/rustwasm/twiggy

  80. @sendilkumarn Rust demo First demo wasm-game-of-life

  81. @sendilkumarn Future

  82. @sendilkumarn Threads

  83. @sendilkumarn ⚠ Exception Handling

  84. @sendilkumarn ♻ Garbage Collection

  85. @sendilkumarn WebAssembly provides a platform to plug and play best

    parts from different languages and use them together.
  86. @sendilkumarn Questions…

  87. @sendilkumarn Thanks… @sendilkumarn dev.to/sendilkumarn sendilkumarn.com/blog