# Rust language

# Web Assembly

The Rust Programming Language (opens new window)

While possible, using Rust instead of JavaScript to make UI updates is probably not how to profit from the power of WASM. No tests I found so far showed a big difference in term of speed. It's even sometimes worse with WASM. Nothing can replace the DOM API so far. That's the lowest-level API to do UI updates.

extern crate wasm_bindgen; // give acces to the DOM via WASM

use wasm_bindgen::prelude::*;

// ~1KB Allocator optimized for wasm. Slower than the Rust one but a lot lighter.
// You need to download the wasm file before executing it.
#[cfg(feature = "wee_alloc")]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

pub fn main() -> Result<(), JsValue> {
		// console.log the app panics

		// Looks like the DOM API, right?
    let window = web_sys::window().expect("no global `window` exists");
    let document = window.document().expect("should have a document on window");
    let body = document.body().expect("document should have a body");

    // Manufacture the element we're gonna append
    let val = document.create_element("div")?;
    val.set_inner_html("Hello from Rust!");


		// Everyting went well so far 👌
wasm-pack build --target web (--dev)

# Examples

# Are we [ready] yet?

# Rust on Windows (without admin rights)

While on Linux and macOS, compiling a software is straightforward with the Terminal, on Windows it's another story. Microsoft came with an tricky but easy solution: Windows Subsystem Linux.

You can also use MSYS2 and ConEmu to have something similar. Both tools don't need admin rights to be installed and launched. MSYS2 is based on MinGW and Pacman (from Arch Linux).

Install Rust from https://rustup.rs/ (opens new window)

# Useful crates

# General purpose


# Web

# Talks and Articles

# Windows 10X