Javascript slow, compared to wasm
categories: hacking
tags: wasm
Description/Summary
WASM vs JavascriptContent
Javascript has dynamic types, which checks each step of types – a lot of conditions. Javascript GC needs time to run. Heap allocated everything. Integers in Rust never touch the heap.
Wasm is approaching as fast as native code. Wasm is basically machine code. 20% instructions to do checks.
Both C++ and Rust do their type checking in compile time but not runtime. C is fast too. But C has weak types and is extremely unsafe.