24. wasm is not a new programming language,
nor intended to replace JavaScript
1.
25. wasm is a target for other programming
languages, initially C/C++/Rust and it is
intended to complement JS
2.
26. wasm is still living in a sandbox and doesn't
expose new platform capabilities like hooks into
the native operation system
3.
27. It does however in the long run expose
things like SIMD, threads and the like
28. wasm is perfect for many of the use-cases
where the web currently doesn't shine
29. Game engines
Usually very self contained, so compiling directly to the web, introduces
unneeded layers in between.
Here wasm allows the getting very close to the metal
30. Game engines
A game engine could run mostly in wasm and paint to a DOM canvas and run
audio via WebAudio.
It is pretty much self contained, like in a applet sense
31. CAD / video + photo editors
Apps such as CAD applications can do the UI components using regular
web technologies and just delegate tough computations to wasm.
Note, wasm cannot at this point call into the DOM. You can import JS
methods that wasm can call, or call wasm from JS.
34. Existing libraries
For instance, if a browser doesn't support webp but service workers, it would
be possible to compile the webp decoder and use it to decode webp in the
service worker!
36. Actually, let's see how you can use today
Easiest way is to follow instructions on webassembly.org which mostly
revolves around using Emscripten.
It is still early days for tooling
37. Invented example
You might need to add macros to your C/C++ code for functions to avoid
being optimized away (check emscripten docs)
38. Let's look at the code
➫ Emscripten originally targeted AMS.js, eg. pure JS code
➫ Due to standard libs, SDL integration etc, it generates JS boilerplate
➫ A lot of the boilerplate is often unused and includes mapping to
WebAudio, canvas etc
➫ Emscripten has its own way of initialization from JS (Module.* etc)