What is it & How will it affect JavaScript
By Ziv Birer, Technical lead with HPE Software
Netscape
(1995)
Server
(2009)
Mobile
(2010)
Web
Assembly
(2015)
• Games
• Video processing
• Image processing
• Virtual reality
Subset of JS + hints
• Static typed variables
• Only “low level” operation
“asm.js” mode
• Precompile all code
• Performance optimizations
• No garbage collection
Vertical bar 0
integer
asm.js code
function _main() {
"use asm";
var $0 = 0, $vararg_buffer = 0, label = 0;
var sp = 0; sp = STACKTOP;
STACKTOP = STACKTOP + 16|0;
if ((STACKTOP|0) >= (STACK_MAX|0))
abort();
$vararg_buffer = sp; $0 = 0;
(_printf(672,$vararg_buffer)|0);
STACKTOP = sp;
return 0;
}
Simple code
Valid JS code
9
• A new browser language
• Compilation target from other language
• Typed variables
• Multi threaded
• Garbage collection
• Load fast (quick parsing)
asm.js
function () {
"use asm";
function add(x, y) {
x = x | 0;
y = y | 0;
return x + y | 0;
}
return { add: add };
}
(module
(export $add “add” $add)
(func $add
(param $x i32)
(param $y i32)
(result i32)
(i32.add
(get_local $x)
(get_local $y)
)
)
)
web assembly
Web Applications• Games
• CAD
• Video editing
• Image editing
• Scientific visualization
• Virtual reality
• Augment reality
48
photo: panoramio.com
Summary
New “low level” language of browsers
It is a “target” language (from C/C++)
Fast almost as native languages
For running “heavy” applications on the browser
Still under development
May affect future of JavaScript@bmihaylov | Voxxed Days Thessaloniki 2016
Thank you !

Web assembly lecture @AngularUP 2017

  • 1.
    What is it& How will it affect JavaScript By Ziv Birer, Technical lead with HPE Software
  • 2.
  • 3.
    • Games • Videoprocessing • Image processing • Virtual reality
  • 5.
    Subset of JS+ hints • Static typed variables • Only “low level” operation “asm.js” mode • Precompile all code • Performance optimizations • No garbage collection
  • 6.
    Vertical bar 0 integer asm.jscode function _main() { "use asm"; var $0 = 0, $vararg_buffer = 0, label = 0; var sp = 0; sp = STACKTOP; STACKTOP = STACKTOP + 16|0; if ((STACKTOP|0) >= (STACK_MAX|0)) abort(); $vararg_buffer = sp; $0 = 0; (_printf(672,$vararg_buffer)|0); STACKTOP = sp; return 0; } Simple code Valid JS code
  • 9.
    9 • A newbrowser language • Compilation target from other language • Typed variables • Multi threaded • Garbage collection • Load fast (quick parsing)
  • 10.
    asm.js function () { "useasm"; function add(x, y) { x = x | 0; y = y | 0; return x + y | 0; } return { add: add }; } (module (export $add “add” $add) (func $add (param $x i32) (param $y i32) (result i32) (i32.add (get_local $x) (get_local $y) ) ) ) web assembly
  • 12.
    Web Applications• Games •CAD • Video editing • Image editing • Scientific visualization • Virtual reality • Augment reality
  • 13.
    48 photo: panoramio.com Summary New “lowlevel” language of browsers It is a “target” language (from C/C++) Fast almost as native languages For running “heavy” applications on the browser Still under development May affect future of JavaScript@bmihaylov | Voxxed Days Thessaloniki 2016
  • 14.