Many decades ago, you programmed computers by flipping switches. It was a slow, error-prone and tedious process. Then came assembly language, which was machine code that humans could actually read. The great age of assembly came in the early 80s, when it was used to power commercial games for 8-bit boxes such as the CBM-64; since basic interpreters were slow and there were no C compilers, only assembly language code ran fast enough.
Still in use today, assembly remains slow and tedious. In the time it would take you to write ten lines of assembly, you could write ten lines of Python or C# that would accomplish far, far more from a software perspective. (That hasn’t stopped the people who still like to write 8-bit assembly; there’s even a C compiler that outputs 6502 machine code for CBM-64/Vic-20, and so on.)
The other issue with assembly is the lack of portability. Converting 6502 to Z80 (or some other assembly language) is a non-trivial piece of work, despite some advances in automation. Thirty years ago, it might have taken you a month to convert, test, and release a working program based on 5,000 lines of assembly code. Things are still pretty slow, but assembly does have its uses in legacy systems and software that must deal directly with hardware (i.e., the Internet of Things).
However, even asm.js has its problems. Downloading and compiling large asm.js apps can be quite slow, especially in mobile environments. Instead of source code that is bulky and needs compiling, why not download machine code or something close to it? That’s the thought process that led to the birth of WebAssembly.
WebAssembly is a low-level binary format, not unlike assembly language. But WebAssembly code isn’t the most readable. Can you figure out what this example does?
get_local 0 i64.const 0 i64.eq if i64 i64.const 1 else get_local 0 get_local 0 i64.const 1 i64.sub call 0 i64.mul end
It’s a recursive factorial function, and i64 is a 64-bit integer variable. You can see the original C/C++ source code, plus this and the binary on the text format page. Only masochists would write programs in wasm (the short name for WebAssembly).
Current State of WebAssembly
WebAssembly is still a work in progress. Earlier this year, W3c WebAssembly Community Group announced that the Minimum Viable Product (MVP) was complete, with approximately the same functionality as asm.js (supported platforms include Chrome and Android 57, Opera 44, Edge 15 (experimental) and Firefox 52.)