ITERA UKRAINE 2017
WEB
ASSEMBLY
OLEKSANDR SKACHKOV @alSkachkov
ABOUT ME
• Itera’s Software Architect
• Itera’s FrontEnd Tech Lead
• WebKit contributor from 2015 & JS hacker
• Twitter: @alSkachkov
• Email: oleksandr.skachkov@itera.no
WEB ASSEMBLY
GAME CHANGER
• What was before
• WASM – why it is needed
• WASM – what is next
HOW JS EVOLVE
• Netscape Navigator 2.0 in 1995:
• JS was born
• NPAPI – for Java plugins
• IE 3.0 - ActiveX
• Flash player initial release - 1996
• HTML5
• JiT – in modern JS engines - 2008
• Aggressive optimization algorithms and ASM.js
WHAT IS WRONG WITH JS?
• Performance
• Access to OS features
THE STRENGTH IS A WEAKNESS
• Easy to learn
• Executes in browser environment
• Dynamic typing
=
• LOW PERFORMANCE!
HOW BROWSER EXECUTE JS
HOW BROWSER EXECUTE JS
HOW BROWSER EXECUTE JS
HOW TO SOLVE BY TOOLS
• Frameworks
• Minifiers
• Optimizers – Prepack
• Rules and Hucks
TRIES TO SOLVE IN BROWSER
• WebAssembly, a bytecode standard for
web browsers
• Announced in 17 June 2015
• Will be developed by major Browsers
• Developed by WebAssembly Working
Group
WebAssembly - Game Changer
• Build target
• Binary format
• Support integration with JS
• Close IR of the JS Engines
• WASM 1.2x speed of the native code
What is WebAssembly
WEBASSEMBLY IS BUILD TARGET
• Build target – for C/C++/Rust
WEBASSEMBLY IS BUILD TARGET
• Build target – for C/C++/Rust
• Used intermediate representation – S
expression WAT/WAST
WEBASSEMBLY IS BUILD TARGET
• Build target – for C/C++/Rust
• Used intermediate representation – S
expression WAT/WAST
• Binary format - WASM
HOW BROWSER EXECUTE WASM
JS
WASM
INTERACTION WITH JAVASCRIPT
We can use JS function in WASM and WASM function in JS
INTERACTION WITH JAVASCRIPT
We can use JS function in WASM and WASM function in JS
USAGE SCENARIOS
• Write faster version of the specific application
• Using existing C libraries in browser
• Reuse algorithm from service side
• Distribute whole application as WebAsm
SECURITY
• Limit set of operation
• Controlled operation with memory
CAN WE USE WEBASSEMBLY?
Global support 57%
Yes we can
CURRENT STATUS AND FUTURE
Current
• MVP
• No finalized spec (Experimental feature)
Future:
• GC
• Threads
• Tools
EXAMLES
• Video editor https://d2jta7o2zej4pf.cloudfront.net/
• Game: http://webassembly.org/demo/Tanks/
• Garden for Mozilla: https://s3.amazonaws.com/mozilla-
games/ZenGarden/EpicZenGarden.html
• TypeScript for WA: https://github.com/AssemblyScript/assemblyscript
QUESTIONS?
WebAssembly Overview

WebAssembly Overview

  • 1.
  • 2.
    ABOUT ME • Itera’sSoftware Architect • Itera’s FrontEnd Tech Lead • WebKit contributor from 2015 & JS hacker • Twitter: @alSkachkov • Email: oleksandr.skachkov@itera.no
  • 3.
    WEB ASSEMBLY GAME CHANGER •What was before • WASM – why it is needed • WASM – what is next
  • 4.
    HOW JS EVOLVE •Netscape Navigator 2.0 in 1995: • JS was born • NPAPI – for Java plugins • IE 3.0 - ActiveX • Flash player initial release - 1996 • HTML5 • JiT – in modern JS engines - 2008 • Aggressive optimization algorithms and ASM.js
  • 5.
    WHAT IS WRONGWITH JS? • Performance • Access to OS features
  • 6.
    THE STRENGTH ISA WEAKNESS • Easy to learn • Executes in browser environment • Dynamic typing = • LOW PERFORMANCE!
  • 7.
  • 8.
  • 9.
  • 10.
    HOW TO SOLVEBY TOOLS • Frameworks • Minifiers • Optimizers – Prepack • Rules and Hucks
  • 11.
    TRIES TO SOLVEIN BROWSER
  • 12.
    • WebAssembly, abytecode standard for web browsers • Announced in 17 June 2015 • Will be developed by major Browsers • Developed by WebAssembly Working Group WebAssembly - Game Changer
  • 13.
    • Build target •Binary format • Support integration with JS • Close IR of the JS Engines • WASM 1.2x speed of the native code What is WebAssembly
  • 14.
    WEBASSEMBLY IS BUILDTARGET • Build target – for C/C++/Rust
  • 15.
    WEBASSEMBLY IS BUILDTARGET • Build target – for C/C++/Rust • Used intermediate representation – S expression WAT/WAST
  • 16.
    WEBASSEMBLY IS BUILDTARGET • Build target – for C/C++/Rust • Used intermediate representation – S expression WAT/WAST • Binary format - WASM
  • 17.
    HOW BROWSER EXECUTEWASM JS WASM
  • 18.
    INTERACTION WITH JAVASCRIPT Wecan use JS function in WASM and WASM function in JS
  • 19.
    INTERACTION WITH JAVASCRIPT Wecan use JS function in WASM and WASM function in JS
  • 20.
    USAGE SCENARIOS • Writefaster version of the specific application • Using existing C libraries in browser • Reuse algorithm from service side • Distribute whole application as WebAsm
  • 21.
    SECURITY • Limit setof operation • Controlled operation with memory
  • 22.
    CAN WE USEWEBASSEMBLY? Global support 57% Yes we can
  • 23.
    CURRENT STATUS ANDFUTURE Current • MVP • No finalized spec (Experimental feature) Future: • GC • Threads • Tools
  • 24.
    EXAMLES • Video editorhttps://d2jta7o2zej4pf.cloudfront.net/ • Game: http://webassembly.org/demo/Tanks/ • Garden for Mozilla: https://s3.amazonaws.com/mozilla- games/ZenGarden/EpicZenGarden.html • TypeScript for WA: https://github.com/AssemblyScript/assemblyscript
  • 25.