The web site of Vas — 2018-10-11

WebAssembly isn’t the Messiah

I’ll keep this as short as I can so subhuman vermin redditors can comprehend it. WebAssembly doesn’t solve the problems you think it solves. WebAssembly won’t magically improve the web. WebAssembly won’t eliminate the pathologies of modern web design, and in fact it’s likely to exacerbate them.

Here’s what WebAssembly does:

Here’s some realities to keep in mind before you post your next retarded comment on /r/programming to farm karma from your echo chamber with a collective IQ just shy of room temperature:

JavaScript isn’t slow

You can see some microbenchmarks comparing JavaScript with WebAssembly. You will notice the difference isn’t that high. In fact, in some cases the difference is statistical noise. Of course, microbenchmarks aren’t the best way to predict how an application will perform overall. We could very well expect improvements by a factor of 2 on average, maybe 10 in extreme cases.

If you haven’t been living under a rock the past 30 years, you might notice this is the same trade-off Perl, Python, Ruby, and other dynamic language darlings have offered you, and while there’s many people who think the performance loss is unacceptable, to say you don’t understand why people prefer them to C is arguing in bad faith. Of course people are going to prefer a language such as Python, which when well written can read like English prose, to systems programming languages.

You can read more microbenchmarks between languages if you’d like, but the bottom line is modern JavaScript engines are closer to gcc C++ in performance than Python. This is because of the amount of resources that have been sunk into optimising JavaScript engines. Considering you get dynamic typing and garbage collection out of the box, it’s actually surprising JavaScript is as fast as it is.

You don’t have to write JavaScript

We’ve had CoffeeScript forever, and in the current year, you can write as much Clojure, TypeScript, Python, Lua, Dart, and Elixir as you want and it can be compiled to JavaScript. You don’t have to write a single line of JavaScript if that’s your biggest concern, and they’ll give you all the type safety your heart desires, assuming flow isn’t good enough for you. WebAssembly doesn’t magically allow you to write in a different programming language in the browser, because you’ve already had that ability.

WebAssembly will increase bloat

JavaScript is a very high level language, so it can be more compact in expressing things that are far more verbose in lower level languages. That’s just mathematics I’m afraid. All major browsers come equipped with a JavaScript JIT compiler and APIs already baked in, no downloading required. Perhaps this wasn’t the cleanest solution, but WebAssembly doesn’t solve that problem in any way.

Every single WebAssembly program will have to ship its own libraries for things as basic as memory allocation, never mind all the other things that JavaScript already does, and most likely compatibility layers for interacting with the DOM. This is orders of magnitude larger than this entire website, and if you’re shipping a garbage collector (perhaps because you’re writing C#) then congratulations, you’ve just shipped several megabytes of functionality the browser already implements.

This is acceptable when porting Skyrim so that it can run in NSA Botnet Google Chrome, not so much when you’re trying to load your blog comments asynchronously.

JavaScript isn’t the devil

Yes, JavaScript has a fuckton of gotchas and incredibly poor decisions. However, since the Internet Explorer 6 era, it has received significant quality of life updates that bring it closer to modern programming languages. These updates are ongoing, like for example we’ll soon have real integer arithmetic, and even type annotations are on the horizon. These gotchas aren’t even unique to it; the C family, the biggest industry darling, is gotchas atop gotchas and the gotchas have gotchas, and last time I checked the best software I’ve ever used was written in it. Bonus meme for how comically inexpressive it is.

You may think it’s embarrassing that it took so long for JavaScript to kind of maybe catch up to your favourite language, which pioneered all these advancements a decade or more ago. Fair enough. But you don’t get to judge it as if it’s uniquely awful or still stuck in the IE6 era. We live in the current year and have seen more languages come and go than just $YOUR_FAVE and JavaScript; pretending otherwise is delusional. Then again, I’m talking to redditors, schizophrenia comes with the territory.

WebAssembly won’t fix the web

As I’ve established, modern JavaScript is, bare minimum, a passable language, with decent enough performance in purely algorithmic code. DOM interactions are significantly slower, but I/O in general is slow, and in that context DOM isn’t insanely slow; keep in mind the DOM implementation is native code, not JavaScript. For reference, Emacs is also a mixed environment with some native code (filled with bad decisions) plus a dynamic language (with even worse decisions), it isn’t even JIT compiled, and in my system it performs at least an order of magnitude faster than its web app competition, which makes no sense.

Your first problem is that the DOM implementation and arguably design are both terrible. WebAssembly does nothing to fix that; you’d have to rewrite the entire web platform from the ground up to see improvements here, and ironically your gains would evaporate overnight. And that’s because…

Your second, and most important problem, is that web developers are garbage, and this has nothing to do with the APIs or the language. The current web ecosystem involves several layers of interconnected abstractions, duplications of duplicated functionality, megabytes of dead code, pictures of Guy Fieri, and an almost intentional obfuscation of real functionality. Sure, you could make the language or the APIs faster, but nothing would be fast through the layers of indirection the modern web framework mess has introduced. If anything, any performance improvements would allow developers to be even sloppier, like for example by including a full copy of John Wick with AngularJS. Client-side, of course.

If you haven’t been living under a rock the past 60 years, you might notice this is a problem software development has had forever, and there are more megaprojects out there with useless and incomprehensible dependency circles, code that’s impossible to parse, and crippling overhead than there are scum redditors. I mean, have you looked at AAA video games lately? It’s impossible to create a performant anything when every keystroke, every scroll event, every mouse flicker calls thousands of lines of code because some webshit couldn’t read the CSS animation tutorial on MDN and instead included 4 different keyframe libraries using 3 different module bundlers plus analytics.

This debate, like programming, is a fashion statement

This never was about technological merits. I’m not very old, but I’m old enough to have seen about a dozen technology fads come and go. The current fad is the cult of Rust and JavaScript antagonism, pitted against analytics and cancerous frameworks. Of course shipping dozens of megabytes of cruft hurts your AWS bill, costing you thousands upon thousands of dollars in bandwidth fees. Of course it makes people not want to use your webshite and sends visitor retention on a trip to the Mariana Trench. Of course the ad industry is a bubble with ever-decreasing returns for ever-increasing costs, and of course basing your entire business on it is a terrible investment. But it’s the fashionable thing to do, because that’s what everyone else does, because that’s what that Medium article suggested you do.

And of course all of you know it’s these bad decisions that give us a dysfunctional web, because of course we like seeing comments and videos and animations online—the things the modern Web 2.0 brought us—but you can’t affect the Googles and the Facebooks of this world no matter how much karma you amass. They have barricaded themselves inside an impenetrable hugbox rationalising Paris Fashion Week. So you do the only thing you can and barricade yourselves inside an impenetrable hugbox of your own, scapegoating JavaScript while rationalising your fashionable counter-fashion because it signals your group membership and your place in its hierarchy.

I hate all of you. I’m sure you’ve noticed by now. I unironically, whole-heartedly believe webshits and their rusted webassembled antagonists deserve death. Kill yourselves. You are the reason why modern software is such unadulterated garbage, why for every advancement in compiler research and computer hardware there has to be a framework and a paradigm with more layers of indirection that somehow undoes all progress and then some in the name of some autistic standard of artisanal elegance, when really all we want to do is parse some text and display our waifus doing lewd things with their butts on a dot matrix; why every time we have something good, just around the time it finally works well enough, we have to rewrite it from scratch, and for some magical reason the rewrite is worse in every conceivable way.

WebAssembly won’t fix anything because the only thing that can fix any of this is a superintelligent God AI going full Yezhovshchina on the entire software industry, but I guess until then at least we’ll be able to play shitty, soulless console ported sequels of raped nostalgic franchises on East Germany Mozilla Firefox so long as we have invested enough in overpriced nVidia hardware to buy a house. Holy shit, fuck computers. I wish we lived in a world where all we needed to read and write about our waifus doing lewd things with their butts were analogue typewriters.