WebAssembly or WASM is a low-level bytecode format for in-browser client-side scripting, evolved from JavaScript. Its initial aim is to support compilation from C and C++, though other source languages such as Rust are also supported.
I In 2008, a period that people call the performance wars began. Multiple browsers added just-in-time compilers*. * As JavaScript was running, the JIT could see patterns and make the code run faster based on those patterns.
I With this improved performance. JavaScript started being used for things no one ever expected it to be used for, like server-side programming with Node.js.
I Consists of a strict subset of JavaScript, into which code written in statically-typed languages with manual memory management is translated by a source-to-source compiler such as Emscripten (based on LLVM)
I guaranteed memory safety threads without data races trait-based generics pattern matching <3 type inference minimal runtime efficient C bindings zero-cost abstractions move semantics
I fn main() { let greetings = [“Ola", "Hello", "Hola", “Bonjour”]; for (num, greeting) in greetings.iter().enumerate() { print!("{} : ", greeting); match num { 0 => println!(“Esse código é modificável e executável!"), 1 => println!("This code is editable and runnable!"), 2 => println!("¡Este código es editable y ejecutable!"), 3 => println!("Ce code est modifiable et exécutable !"), _ => {}, } } }
I $ cargo run Compiling wasm-rust v0.1.0 (file:///Users/raphael.amorim/Documents/ gcom/webassembly-and-rust/examples/wasm-rust) Finished dev [unoptimized + debuginfo] target(s) in 0.66 secs Running `target/debug/wasm-rust` South false src/main.rs
I <html> <head> <script> // This is read and used by `site.js` var Module = { wasmBinaryFile: "site.wasm" } </script> <script src="site.js"></script> </head> <body></body> </html> (brew install tree for OSX)