WASM FAQ

Abhishek Yadav

4 Jan 2020

What languages can be compiled to WASM ?

C, C++, Rust, Javascript

What about Python/Ruby/Java ?

Not yet

Its planned, but needs a GC implementation, which is in progress

Will WASM replace (kill) Javascript ?

Can WASM programs access the DOM ?

No

No access to any web apis directly

Is it faster than Javascript ? How fast ?

It is faster

  • The compilation step takes much lesser (compared to JIT in JS)
  • Uses better optimisations (like Emscripten) 

 

Its all going to run on the same browser engine, both JS and WASM. Well optimised JS can perform at par with WASM

Can I use it today ?

Yes

 

WASM support has been implemented by most major browsers including Edge (but not IE)

Works even on IOS Safari, Android Browser

 

WASM-MVP has been stable for a while

Who is using it ?

Some examples:

  • AutoCaD (ported)
  • Doom3 (ported
  • Gutenberg (Wordpress) (Rust)
  • squoosh.app (multiple)

Can it run outside the browser ?

Yes, since recently

What are some other use cases ?

  • Image editing
  • Games (ported)
  • Music application
  • Data processing

 

Anything CPU intensive -

https://webassembly.org/docs/use-cases/

 

Is it safe to run native code in the browser ?

Yes

Secure sandboxing has been one of the design principles for WASM

Memory management layer is designed from grounds up to support pointer based operations

More details in next session

Can we use multi-threading in WASM ?

Not yet

Pthread support work is in progress

What are the main constraints  ?

(What's the catch)

  • Web APIs are not directly available - a JS glue is always needed
  • Communication along this glue is only using ints and floats. JS objects cant be passed
  • Learning curve

Can we run a Python interpreter on web - as its written in C ?

Yes

It has been attempted using ASM.js

But its not very useful - because of the binary size. 

Will be a great when Python program compiles directly to WASM

Does it make sense to compile JS to WASM ?

Yes, for very large JS projects - where the parse time is a problem, especially on weaker devices

 

Otherwise, once loaded (and JITed), JS is fast enough 

Is it the same as asm.js ?

Very similar but not the same.
EmScripten is being reused

 

(More details in next session)

Will WASM replace (kill) Javascript ?

No

Not soon at least

 

  • The design is to keep it at par and interoperable with JS. Not as a replacement
  • Glue code will always be needed
  • JS -> WASM is an encouraged use case

Wasm FAQ

By Abhishek Yadav

Wasm FAQ

  • 853