F#, Lisp, Scheme, OCaml, Haskell, Smalltalk, C/C++, Basic, PHP, ActionScript, Prolog, Lua and others here. But there’s A New Hope... 2 JavaScript is a compile target for
representation (.wast) Compiler target Who is WEBASSEMBLY or WASM Open standard with cross-browser support W3C 20180215: WebAssembly First Public Working Drafts
than an image, because of the time spent parsing and compiling it. It's possible to parse and compile wasm as fast as it comes over the network, which makes it much more like an image than JavaScript code. Game changer! Yehuda Katz, twitter @wycats said:
a glue code) • No Parsing • Optimization and Deoptimization • Lower-level (no garbage collection) • Typed (everything is static) • A linear memory model (auto-increasing heap) Why WASM 14
produce ‘garbage’ that needs to be collected • Everything is static: Once the code is compiled, it is guaranteed to stay that way. • A linear memory model: C/C++ heap into a single Javascript TypedArray 15 Why WASM is fast
compiler and toolchain technologies. LLVM itself is written in C++. It has an IR - intermediate representation. Clang is an "LLVM native" C/C++/Objective-C compiler. LLVM and Clang 18
maintenance and can install sdk as a bundle which contains: clang, node, emscripten(emcc). emcc - emscripten compiler frontend (use in cli) Emscripten Toolchain
.wasm using wasm-loader ◦ v4+ as .wasm * async-only • Parcel v1.5.0+, as .wasm/.rs Usage 33 A lot of examples here *Sync WebAssembly compilation is not yet implemented - v4.1.1
local file system (MEMFS - default, NODEFS, IDBFS browser indexedDB). Emscripten-generated code running in the browser cannot access files in the local file system. You can use preloading and embedding(package). It is possible to allow access to local file system for code running in node.js, use the NODEFS filesystem option. 38 source
information is kept when compiling from bitcode to JavaScript. Our case it’s "-g4". This is the highest level of debuggability: • Don't minify • Preserve function names • Preserve variable names • Preserve LLVM debug information (shows line number, debug comments, source maps) 39 Debugging
consider JS a security risk. WebAssembly is about as secure as Javascript since it runs in the same sandbox. Typical WebAssembly implementations only add a fairly small parser module to the existing JS engine. Can I start a program or process from WebAssembly? Nope, same reason as DLLs, it would be unsafe. • Today Wasm runs just ~20% slower than native code execution. • Today no multithreading :/ • code-that-cannot-be-compiled source
from WebAssembly? No, WebAssembly runs inside the browser sandbox and can only access Web APIs (just like Javascript). Emscripten SDK provides wrappers for many common native APIs which simplifies porting existing C/C++ code over (for instance sockets-to-WebSockets, GL-to-WebGL, OpenAL-to-WebAudio, and some more…). Can I load and call into a DLL from WebAssembly? No, DLLs are native machine code and thus off-limits. But WebAssembly supports dynamic linking between WASM modules, this allows to reuse shared code modules (they can be cached locally). source
from-asm-js-to-webassembly • webassembly-for-beginners, ru • awesome-wasm Video • Real world WebAssembly - Sergey Rubanov, ru • WebAssembly and Node.js - Ben Smith • Compiling for the Web with WebAssembly • What WebAssembly means for React - Lin Clark • Hacker's guide to Web Assembly - Vigneshwer Dhinakaran • Practical WebAssembly - Dan Callahan • WebAssembly: What and What Next? - Ben Titzer and Andreas Rossberg Course (workshop) google codelabs web-assembly-intro URL’s 46