revolution
play

Revolution has begun Jay Phelps | @_jayphelps WebAssembly will - PowerPoint PPT Presentation

The WebAssembly Revolution has begun Jay Phelps | @_jayphelps WebAssembly will change the way we think of "web apps" Jay Phelps | @_jayphelps Jay Phelps Senior Software Engineer | @_jayphelps So... what is WebAssembly? aka wasm Jay


  1. The WebAssembly Revolution has begun Jay Phelps | @_jayphelps

  2. WebAssembly will change the way we think of "web apps" Jay Phelps | @_jayphelps

  3. Jay Phelps Senior Software Engineer | @_jayphelps

  4. So... what is WebAssembly? aka wasm Jay Phelps | @_jayphelps

  5. Efficient, low-level bytecode for the Web Jay Phelps | @_jayphelps

  6. Efficient, low-level bytecode for the Web Jay Phelps | @_jayphelps

  7. Fast to load and execute Jay Phelps | @_jayphelps

  8. Efficient, low-level bytecode for the Web Jay Phelps | @_jayphelps

  9. 0x6a 01101010 Jay Phelps | @_jayphelps

  10. Intended as a compilation target Jay Phelps | @_jayphelps

  11. int factorial(int n) { if (n == 0) { return 1; } else { return n * factorial(n - 1); } }

  12. 00 61 73 6D 01 00 00 00 01 int factorial(int n) { 86 80 80 80 00 01 60 01 7F if (n == 0) { 01 7F 03 82 80 80 80 00 01 return 1; 00 06 81 80 80 80 00 00 0A } else { 9D 80 80 80 00 01 97 80 80 return n * factorial(n - 1); 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01 } 6B 10 00 20 00 6C 0B }

  13. Safe and portable just like JavaScript is Jay Phelps | @_jayphelps

  14. Is it going to kill JavaScript ? Jay Phelps | @_jayphelps

  15. Nope! * says browser vendors Jay Phelps | @_jayphelps

  16. *well... maybe ...some day...a long time from now (my own opinion) Jay Phelps | @_jayphelps

  17. Will we compile JavaScript to WebAssembly ? Jay Phelps | @_jayphelps

  18. JavaScript is an extremely dynamic language Jay Phelps | @_jayphelps

  19. Jay Phelps | @_jayphelps

  20. Compiling JavaScript to WebAssembly would run slower What about a something JavaScript-like? Jay Phelps | @_jayphelps

  21. AssemblyScript , TurboScript , ThinScript , etc Jay Phelps | @_jayphelps

  22. class Coordinates { x: i64; y: i64; z: i64; constructor(x: i64, y: i64, z: i64) { this.x = x; this.y = y; this.z = z; } } export function example() { let position = new Coordinates(10, 20, 30); // later delete position; } Jay Phelps | @_jayphelps

  23. WebAssembly is still missing things for broad adoption Jay Phelps | @_jayphelps

  24. v1 MVP is best suited for languages like C/C++ and Rust Jay Phelps | @_jayphelps

  25. But other languages soon! Things like Java , OCaml , and even brand new ones Jay Phelps | @_jayphelps

  26. type schoolPerson = Teacher | Director | Student(string); let greeting = (stranger) => switch stranger { | Teacher => "Hey professor!" | Director => "Hello director." | Student("Richard") => "Still here Ricky?" | Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "." }; Jay Phelps | @_jayphelps

  27. When should I target WebAssembly right now ? Jay Phelps | @_jayphelps

  28. Heavily CPU-bound number computations Jay Phelps | @_jayphelps

  29. Games Physics Simulation Encryption Compression Video Decoding Audio Mixing Language Detection Jay Phelps | @_jayphelps

  30. Games Physics Simulation Encryption Compression Video Decoding Audio Mixing Language Detection Jay Phelps | @_jayphelps

  31. Jay Phelps | @_jayphelps

  32. https://goo.gl/yvV92X Jay Phelps | @_jayphelps

  33. https://goo.gl/YWMpdp

  34. asm-dom https://goo.gl/XWBeme

  35. Other use cases just around the corner Jay Phelps | @_jayphelps

  36. You'll likely consume compiled WebAssembly libraries even sooner Jay Phelps | @_jayphelps

  37. What was that binary stuff? Jay Phelps | @_jayphelps

  38. 00 61 73 6D 01 00 00 00 01 int factorial(int n) { 86 80 80 80 00 01 60 01 7F if (n == 0) { 01 7F 03 82 80 80 80 00 01 return 1; 00 06 81 80 80 80 00 00 0A } else { 9D 80 80 80 00 01 97 80 80 return n * factorial(n - 1); 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01 } 6B 10 00 20 00 6C 0B }

  39. 00 61 73 6D 01 00 00 00 01 86 80 80 80 00 01 60 01 7F 01 7F 03 82 80 80 80 00 01 00 06 81 80 80 80 00 00 0A 9D 80 80 80 00 01 97 80 80 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01 6B 10 00 20 00 6C 0B

  40. 00 61 73 6D 01 00 00 00 01 86 80 80 80 00 01 60 01 7F 01 7F 03 82 80 80 80 00 01 00 06 81 80 80 80 00 00 0A 9D 80 80 80 00 01 97 80 80 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01 6B 10 00 20 00 6C 0B

  41. 00 61 73 6D 01 00 00 00 01 86 80 80 80 00 01 60 01 7F 01 7F 03 82 80 80 80 00 01 00 06 81 80 80 80 00 00 0A 9D 80 80 80 00 01 97 80 80 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01 6B 10 00 20 00 6C 0B

  42. 86 80 80 80 00 01 60 01 7F 01 7F 03 82 80 80 80 00 01 00 06 81 80 80 80 00 00 0A 9D 80 80 80 00 01 97 80 80 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01

  43. 86 80 80 80 00 01 60 01 7F 01 7F 03 82 80 80 80 00 01 00 06 81 80 80 80 00 00 0A 9D 80 80 80 00 01 97 80 80 80 00 00 20 00 41 00 46 04 40 41 01 0F 0B 20 00 41 01

  44. Binary can be a little intimidating Jay Phelps | @_jayphelps

  45. Protip: don't worry about it (unless of course, you want to) Jay Phelps | @_jayphelps

  46. Textual representation to the rescue! Jay Phelps | @_jayphelps

  47. (func $factorial (param $n i32) (result i32) get_local $n i32.const 0 i32.eq if $if0 i32.const 1 return end $if0 get_local $n i32.const 1 i32.sub call $factorial get_local $n i32.mul ) Jay Phelps | @_jayphelps

  48. (func $factorial (param $n i32) (result i32) get_local $n i32.const 0 i32.eq if $if0 i32.const 1 return end $if0 get_local $n i32.const 1 i32.sub call $factorial get_local $n i32.mul ) Jay Phelps | @_jayphelps

  49. WebAssembly is a stack machine language Jay Phelps | @_jayphelps

  50. stack machine: instructions on a stack Jay Phelps | @_jayphelps

  51. 1 + 2

  52. mnemonic opcode i32.add 0x6a 01101010

  53. i32.const 1 i32.const 2 i32.add stack

  54. i32.const 1 i32.const 1 1 i32.const 2 i32.add stack

  55. i32.const 1 i32.const 2 i32.const 2 2 i32.add 1 stack

  56. i32.const 1 i32.const 2 i32.add i32.add 2 1 stack

  57. 3 i32.const 1 i32.const 2 i32.add i32.add stack

  58. i32.const 1 i32.const 2 i32.add call $log Jay Phelps | @_jayphelps

  59. Compilers usually apply optimizations real-world output is often less understandable to humans Jay Phelps | @_jayphelps

  60. i32.const 1 i32.const 2 i32.add call $log Jay Phelps | @_jayphelps

  61. i32.const 3 call $log Jay Phelps | @_jayphelps

  62. Most tooling supports an Abstract Syntax Tree (AST) still compiled and evaluated as a stack machine Jay Phelps | @_jayphelps

  63. i32.const 1 i32.const 2 i32.add call $log Jay Phelps | @_jayphelps

  64. (call $log (i32.add (i32.const 1) (i32.const 2) ) ) Jay Phelps | @_jayphelps

  65. s-expressions Yep, looks like Lisp (call $log (i32.add (i32.const 1) (i32.const 2) ) ) Jay Phelps | @_jayphelps

  66. Source map support is coming Jay Phelps | @_jayphelps

  67. What about memory on the heap? Jay Phelps | @_jayphelps

  68. A linear memory is a contiguous, byte- addressable range of memory Jay Phelps | @_jayphelps

  69. Accessed with instructions like i32.load and i32.store Jay Phelps | @_jayphelps

  70. 0 1 2 3 4 5 6 7 8 9 10 Jay Phelps | @_jayphelps

  71. 1 byte 0 1 2 3 4 5 6 7 8 9 10 Jay Phelps | @_jayphelps

  72. 0 1 2 3 4 5 6 7 8 9 10 Jay Phelps | @_jayphelps

  73. w a s m 0 1 2 3 4 5 6 7 8 9 10 Jay Phelps | @_jayphelps

  74. w a s m 0 1 2 3 4 5 6 7 8 9 10 Jay Phelps | @_jayphelps

  75. 119 97 115 109 0 1 2 3 4 5 6 7 8 9 10 Jay Phelps | @_jayphelps

  76. How do I get started ? Jay Phelps | @_jayphelps

  77. https://mbebenita.github.io/WasmExplorer/

  78. https://github.com/WebAssembly/wabt Jay Phelps | @_jayphelps

  79. https://github.com/WebAssembly/binaryen Jay Phelps | @_jayphelps

  80. Jay Phelps | @_jayphelps

  81. $ emcc main.c -s WASM=1 -o app.html Jay Phelps | @_jayphelps

  82. webassembly.org Jay Phelps | @_jayphelps

  83. Webpack is adding support (!!!) They received a $125,000 grant from MOSS Jay Phelps | @_jayphelps

  84. Imagine a cpp-loader / rust-loader Jay Phelps | @_jayphelps

  85. What's missing? Jay Phelps | @_jayphelps

  86. Direct access to Web APIs You have call into JavaScript, right now Jay Phelps | @_jayphelps

  87. Garbage collection also necessary for better interop with JavaScript and WebIDL Jay Phelps | @_jayphelps

  88. Multi-threading Jay Phelps | @_jayphelps

  89. Browser support? Jay Phelps | @_jayphelps

  90. The revolution is just beginning Jay Phelps | @_jayphelps

  91. Jay Phelps | @_jayphelps

  92. Efficient, low-level bytecode for the Web Jay Phelps | @_jayphelps

  93. Efficient, low-level bytecode for the Web Jay Phelps | @_jayphelps

  94. Jay Phelps | @_jayphelps

  95. Questions? @_jayphelps Jay Phelps | @_jayphelps

  96. Thanks! @_jayphelps Jay Phelps | @_jayphelps

  97. Jay Phelps | @_jayphelps

  98. Jay Phelps | @_jayphelps

  99. void log(char *); void example() { log("wasm"); } Jay Phelps | @_jayphelps

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend