More Related Content Similar to WebAssembly for the rest of us - Jan-Erik Rediger - Codemotion Amsterdam 2017 (20) More from Codemotion (20) WebAssembly for the rest of us - Jan-Erik Rediger - Codemotion Amsterdam 20171. WebAssembly for the rest of us
Mozilla Dev Roadshow, Düsseldorf
Jan-Erik Rediger — @badboy_ | 2017-05-14
2. Amsterdam 16 - 17 May
2017
{ WebAssembly for the rest of us
Jan-Erik Rediger — @badboy_
7. What is WebAssembly?
Binary executable format for the web
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 04 84 80 80
80 00 01 70 00 00 05 83 80 80 80 00 01 00 01 06
81 80 80 80 00 00 07 91 80 80 80 00 02 06 6d 65
6d 6f 72 79 02 00 04 68 61 6c 66 00 00 0a 8d 80
80 80 00 01 87 80 80 80 00 00 20 00 41 01 6d 0b
15. What is WebAssembly not?
Replacement for JavaScript
Programming Language
A good target for every dynamic language
21. Type Annotations in JavaScript
function add(x, y) {
* x = x|0; // <- parameter type annotation
y = y|0;
* return (x + y) | 0;
} // ^- return type annotation
24. Linear memory access
function strlen(ptr) {
ptr = ptr|0;
var curr = 0;
curr = ptr;
while (HEAP8[curr]|0 != 0) {
curr = (curr + 1)|0;
}
return (curr - ptr)|0;
}
25. Linear memory access
function strlen(ptr) {
ptr = ptr|0;
var curr = 0;
curr = ptr;
* while (HEAP8[curr]|0 != 0) {
curr = (curr + 1)|0;
}
return (curr - ptr)|0;
}
46. Wasm (binary representation)
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 04 84 80 80
80 00 01 70 00 00 05 83 80 80 80 00 01 00 01 06
81 80 80 80 00 00 07 91 80 80 80 00 02 06 6d 65
6d 6f 72 79 02 00 04 68 61 6c 66 00 00 0a 8d 80
80 80 00 01 87 80 80 80 00 00 20 00 41 01 6d 0b
|.asm...........`|
|................|
|...p............|
|..............me|
|mory...half.....|
|.......... .A.m.|
47. Wasm (binary representation)
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 04 84 80 80
80 00 01 70 00 00 05 83 80 80 80 00 01 00 01 06
81 80 80 80 00 00 07 91 80 80 80 00 02 06 6d 65
6d 6f 72 79 02 00 04 68 61 6c 66 00 00 0a 8d 80
80 80 00 01 87 80 80 80 00 00 20 00 41 01 6d 0b
|.asm...........`|
|................|
|...p............|
|..............me|
|mory...half.....|
|.......... .A.m.|
48. Wasm (binary representation)
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 04 84 80 80
80 00 01 70 00 00 05 83 80 80 80 00 01 00 01 06
81 80 80 80 00 00 07 91 80 80 80 00 02 06 6d 65
6d 6f 72 79 02 00 04 68 61 6c 66 00 00 0a 8d 80
80 80 00 01 87 80 80 80 00 00 20 00 41 01 6d 0b
|.asm...........`|
|................|
|...p............|
|..............me|
|mory...half.....|
|.......... .A.m.|
49. Wasm (binary representation)
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 04 84 80 80
80 00 01 70 00 00 05 83 80 80 80 00 01 00 01 06
81 80 80 80 00 00 07 91 80 80 80 00 02 06 6d 65
6d 6f 72 79 02 00 04 68 61 6c 66 00 00 0a 8d 80
80 80 00 01 87 80 80 80 00 00 20 00 41 01 6d 0b
|.asm...........`|
|................|
|...p............|
|..............me|
|mory...half.....|
|.......... .A.m.|
50. Wasm (binary representation)
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 04 84 80 80
80 00 01 70 00 00 05 83 80 80 80 00 01 00 01 06
81 80 80 80 00 00 07 91 80 80 80 00 02 06 6d 65
6d 6f 72 79 02 00 04 68 61 6c 66 00 00 0a 8d 80
80 80 00 01 87 80 80 80 00 00 20 00 41 02 6d 0b
|.asm...........`|
|................|
|...p............|
|..............me|
|mory...half.....|
|.......... .A.m.|
51. Wast (text representation)
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "half" (func $half))
(func $half (param $0 i32) (result i32)
(i32.div_s
(get_local $0)
(i32.const 2)
)
)
)
52. Wast (text representation)
(module
* (table 0 anyfunc)
* (memory $0 1)
* (export "memory" (memory $0))
* (export "half" (func $half))
(func $half (param $0 i32) (result i32)
(i32.div_s
(get_local $0)
(i32.const 2)
)
)
)
53. Wast (text representation)
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
* (export "half" (func $half))
(func $half (param $0 i32) (result i32)
(i32.div_s
(get_local $0)
(i32.const 2)
)
)
)
54. Wast (text representation)
(module
(table 0 anyfunc)
(memory $0 1)
(export "memory" (memory $0))
(export "half" (func $half))
(func $half (param $0 i32) (result i32)
* (i32.div_s
* (get_local $0)
* (i32.const 2)
)
)
)
56. Available in Rust!
rustup target add wasm32-unknown-emscripten
cargo build --target wasm32-unknown-emscripten
Check out hellorust.com/wasm
65. { If you're a Native developer,
the Web is just a compiler
target away.
by @callahad
66. { If you're a Web developer,
you can leverage the
enormous world of native
libraries.
by @callahad
67. { Both worlds have to learn
from each other to make the
most of this.
by @callahad
70. Amsterdam 16 - 17 May
2017
{ Thank you!
Jan-Erik Rediger — @badboy_
71. Sources & Credit
Code File: Pham Thi Dieu Linh, The Noun Project, CC BY 3.0
Gears: Gregor Cresnar, The Noun Project, CC BY 3.0
Linear Memory: Introduction to WebAssembly
Last quotes: @callahad