Skip to content

Instantly share code, notes, and snippets.

@nphsu
Last active June 8, 2019 08:18
Show Gist options
  • Save nphsu/7b3e93f2cd30faceff75f4764c80b3ab to your computer and use it in GitHub Desktop.
Save nphsu/7b3e93f2cd30faceff75f4764c80b3ab to your computer and use it in GitHub Desktop.

WebAssembly is at best when considered as a supplement to JavaScript - filling in when JavaScript isn't quite performant enough.

WebAssembly can be used to write entire web applications or to replace small bits of existing applications that might not be performant enough with something that runs at near native speed.

These languages(C#,Go) have large runtimes that must be included in the WebAssembly binary, they're only really practical for greenfield projects.

※the smallest achievable binary size uncompressed is around 2MB; this mirrors what I've seen. For Rust, which ships with an extremely minimal runtime (basically just an allocator), the "hello, world" example compiles to 1.6KB

C and C++ ship with very small runtimes, just like Rust, and thus can be practical for embedding inside existing apps and libraries.

However, Rust is also a much more memory safe language meaning that a whole class of bugs that are common in C and C++ are impossible to have in safe Rust.

JIT makes JavaScript run faster by monitoring the code as it’s running it and sending hot code paths to be optimized.

There’s room for improvement here: that overhead could be removed, making performance more predictable. And that’s one of the things that WebAssembly does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment