3 ms·
Two reasons: Portability - you would need to know what you're compiling for, in the same way you need to compile a different version of your program for your P
by rkangel 8y ago
Two reasons:
Portability - you would need to know what you're compiling for, in the same way you need to compile a different version of your program for your PC and your phone. You could imagine a system where some pre-compiled versions exist for certain browser/host combinations to make life faster for the majority case thought except:
Security - the primitives that WASM has available are limited and only affect stuff in the sandbox. The browser then compiles that to machine code and can know that the machine code will only affect stuff in the sandbox. This is exactly how JS works - unless there's a browser bug, JS can't write to an arbitrary place on your harddisk (for instance). If machine code was provided directly, then the browser couldn't easily verify that the machine code only did safe things (because machine code can do anything, unlike WASM).