If someone has only good things to say about the language, they probably haven't used it enough yet. I mean, there are definitely good parts, but if your language needs a book like that, it means there are a lot of bad parts.
Unfortunately, it is often the only tool for the job.
So, what can we do if we want to use a different programming language instead?
Before you start learning up any new skill or concept, I suggest you take a look at my course “10 Steps to Learn Anything Quickly”.
Transpilation vs. Compilation
A programming language is really just a human-friendly syntax. We already have programs that interpret or compile that syntax into something a computer can run. Instead of compiling our program into machine code, we could compile it into another programming language.
It is a garbage collected language with very loose semantics that, while more friendly for beginning developers to learn, is really bad as a transpilation target.
By predicting how much space is needed and laying out objects in memory efficiently, the interpreter or compiler can optimize the code execution. This works well in programming languages like C, or Java, because you can't change what fields a class has, or their types after you define it.
Number to a
String halfway through.
For instance, in the below code, you can see that we can modify fields on class instances and even completely change the methods even after the objects are created!
This language is known as asm.js.
Here's an example of what asm.js code looks like if it was written by hand (it looks much crazier when machine generated).
WebAssembly is a Compile Target for the Web
And the best part—it's not being designed in 10 days!
Here's an example of some WebAssembly code in textual format. The main format is binary, but it can be freely converted to a text format more suitable for reading by humans. This is just one potential text syntax, as the official format hasn't yet been decided.
It will also support hardware-accelerated features of modern processors like Single Instruction, Multiple Data (SIMD). This would let you write code that could potentially do a calculation on multiple variables at the same time, really speeding up certain applications like live video processing or games.
Since it is built for the web, it will be safe to run in browsers from day one. What does “safe to run in browsers” mean?
For one, it's memory safe, which means you can't crash your computer just by going to some website with an allocation bug.
Secondly, code will have to abide by the existing browser-based security restrictions like the same-origin policy to prevent malicious sites from stealing user's data without their permission.
Lastly, WebAssembly will be portable, so there are no platform specific aspects of the format. This means it can run on many different devices including regular web browsers, mobile, or even Internet of Things (IoT) devices. Technically it doesn't even have to run in the context of a webpage!
And just because WebAssembly won't have platform specific aspects, a given host may decide to provide additional APIs on top of what's available normally. For instance, if Android had a native host for WebAssembly, it could provide an API to access native Android features that aren't normally available to websites.
This is Great for Other Programming Languages
What does all this mean for you?
It means we'll have a solid platform for optimizing lower level code, and a great vector for implementing programming languages that run in a cross-platform way. Among other things, it makes other programming languages first-class citizens of the web.
There are already communities forming around languages like ClojureScript, but I can see higher-performance languages really starting to become mainstream.
Despite how much people like to bash it (myself included), there have been many improvements in the last couple years, thanks to EcmaScript 6. It will always be a great language when you want high flexibility and fast prototyping, or the most choices for frontend work.
However, if you want to build something like a video encoder, security encryption software, or need to carefully manage memory, now you can use a low-level language suited to the task.
Or if you really care about catching bugs at compile time, you could use something that is statically typed with a fancy type system like Haskell. You could even theoretically mix them in a single app.
It's Still Early Days
So where is WebAssembly now?
It was first announced in June 2015, and as of writing this post (May 2016), it's still being designed. However, they have been hard at work, and already there's a spec and reference interpreter, a draft of the binary format, and even a playable 3D game by Unity called “angry bots” compiled from C++. Everything is open source, so you can check out their implementations and designs in the github repos.
We should all feel excited to be living in a time with this kind of innovation and potential. The web has already proven to be the most useful and accessible platform ever, and WebAssembly will take everything to the next level.
I'm extremely excited for what the future brings. Long live the web!