Thanks for visiting my blog!
Not John BoltonThe notorious quip by Mark Twain came to mind today as I was reviewing comments to my recent blog post about Blazor, a lot of the comments talked about WebAssembly being the death of JavaScript.
The fact is that we’ve all been here before. In fact, we’ve been here many times. And I, for one, don’t want to simply see WebAssembly as something to replace JavaScript. Here are my thoughts.
We’ve Been Here Before
So I’ve been in software development for over thirty years (I know, i’m old). And my experience with web development started about twenty years ago. So I’ve seen a lot of solutions to avoiding client-side development with Scripting Languages come and go. Here’s a short list:
- Java Applets
- ActiveX
- Flash
- Silverlight
- XAML Browser Applications (XBAP)
- Google Native Client
Sure, none of these worked, but maybe WebAssembly will. It’s goals seem to get a lot of people worked up. But the idea of handling modules in a smarter, component based solution seems laudable and better than our current, server-side bundling required of JavaScript (e.g. WebPack, Browserify).
What Does WebAssembly Bring to the Table?
Specifically, I want to point out some basics of WebAssembly (maybe duplicating my last post), but to understand why it’s an interesting beast:
WebAssembly is a binary format of browser code, not compiled to JavaScript
WebAssembly is made up of modules which are distributable, loadable and executable unit of code.
WebAssembly is an underlying set of types, values and instructions that aren’t meant to be written by developers directly, but compiled into by any language that wants to use WebAssembly as a target.
WebAssembly 1.0 is focused on delivering a standard with roughly the same features as asm.js as well as focusing on threads, zero-cost exceptions, and SIMD.
WebAssembly does define a text-format to support debugging and ‘view-source’ of an WASM package.
WebAssembly (today) can be build via a large number of languages/platforms including C/C++, C#, Rust, AssemblyScript (e.g. subset of TypeScript), et al.
So on the face of it WebAssembly looks to be the future of web development, but what does that mean for JavaScript?
Does JavaScript Need Replacing?
WebAssembly doesn’t think so. Here’s a quote from their FAQ:
“WebAssembly is designed to be a complement to, not replacement of, JavaScript. While WebAssembly will, over time, allow many languages to be compiled to the Web, JavaScript has an incredible amount of momentum and will remain the single, privileged (as described above) dynamic language of the Web.”
JavaScript as it’s evolving (e.g. ES6, ES2015, etc.) is looking much more like the language we all deserved back in 1998. But there are still problems to overcome. I would like the web, in general, to solve some real problems:
Package Loading: I don’t want to have to pre-package everything in WebPack. I want a component based loading system like most mature systems have (e.g. .NET, Java, etc.).
Components in the DOM: Vue, React, and Angular style composition models are fine, but they still require I either just use HTML semantics or take over drawing with Canvas.
Tie CSS to Components: I like CSS as a styling language, but it’s too global. Using component based CSS (which I know is possible, just not as easy as it is).
These are the solutions that I think WebAssembly can tackle without us having to throw the baby out with the bathwater. Most people that I know that hate JavaScript are tied up in the funny slidedecks on it’s inconsistencies instead of where it excels.
Prediction?
So do I know what will happen? Nope. No Idea. I’ve tied myself to other tech before that failed, so you probably shouldn’t believe my prediction even if I had one. I’m no oracle.
But if you take time to look at WebAssembly and like what it’s doing? Start using it. The arbiters of whether it succeeds aren’t Microsoft, Google and Facebook. It’s you, the working developer. It’s open source: File bugs, put your opinion out there. Show off cool uses of it and comment about better ways to use it. Don’t assume that there is some council that will make the decision for you. Play with it and see what you think yourself. It’ll be fun, I promise ; )