WASM: Big deal or little deal?
theregister.com
theregister.com
One of the things that discouraged me from Front-end Web Development is JavaScript weirdness. It just has too many pitfalls and it's very hard to debug for a newcomer unless you study a proper JS course that tells you precisely all of these traps before you get burned. I've never found a programming language that didn't behave like I expected it on first touch, except for JS.
I am fully aware TypeScript exists, and there are transpilers where the syntax (modern ECMAScript) and rules are more appropriate to current times, but these aren't "native" of the browser. You must still transpile to the hazardous old JS. I know transpilers avoid many of these pitfalls, but I cannot avoid feeling like I'm building a skyscraper in quicksand.
The hard thing about talking about this exact topic it's that I'm sure my comment will trigger negatively a ton of developers, because talking about JS like this it's going to feel like I've insulted a cult. Let me be clear this is not my intention. I come from the static-typed programming languages world, so I have a preference for my programming to be the most correct.
WASM to me provides this solid foundation, if only (big IF) we manage to create a browser where the main execution virtual machine is not a JS one. I've dreamed of a browser that supports multiple stacks, instead of the HTML/CSS/JS monopoly. For instance, why'd be too hard to think about something like HTML/CSS/Python?[0]
JS has been a discourager to me career-wise, and I'm doing great in Back-end Web Dev, but I'm pretty sure I'm not the only one feeling this way about it. The web should be more accessible in this sense.
--
[0]: I am aware of the existence of Brython: https://brython.info/, but it's not my point, that is still Python-over-JS.
Just FYI this line of argument is called “poisoning the well”. Definition from Wikipedia:
> a type of informal fallacy where adverse information about a target is preemptively presented to an audience, with the intention of discrediting or ridiculing something that the target person is about to say.
It is not conductive to a reasoned discourse about a technical topic.
Although it was poorly phrased, what GP meant to say is that they weren't trying to intentionally offend anyone's sensibilities, they were just expressing their sincere opinion on a subject.
The GP described opposition to his argument, before it was presented, as coming from triggered members of a cult.
If this is not poisoning the well, what changes to his argument need to be present for it to cross over the line?
How much more clear does it need to be?
And to rub salt into the wound, he then went on to describe his preference as "the most correct".
I wonder what he primarily programs in.
Let me dissipate your wonderance.
I started my programming life with Delphi and C++ (pre-C++11), and when Delphi IDE became too bloated, I jumped to Python 3.x and didn't take it too seriously until Python 3.6 onwards.
But it's got all the same footguns that JS has, with fewer features.
If you're used to those footguns, why are you complaining about JS?
>my comment will trigger negatively a ton of developers, because talking about JS like this it's going to feel like I've insulted a cult. Let me be clear this is not my intention.
The salient points are:
* A lot of developer may take offense to these comments.
* "Because it's like I've insulted a cult" -> "Because it's like I'm killing the sacred cow." -> "Because it's like I'm trying to be intentionally offensive about something that's off-limits."
* This is not their intention.
If you take into account the entire paragraph I think the intent is quite clear. "If you take offense to my comments please keep in mind that I'm not trying to be intentionally offensive, I'm just expressing my personal opinion." I'll grant you that it's somewhat clumsily communicated, but that's not that surprising if ivanmontillam is not a native speaker. I think you latched on too strongly to specific words, instead of taking in the general message.
The crux is the speaker preventatively discredit any objection. In this case by suggesting they are irrational and emotonal.
“People will complain/get angry/be triggered by my theory X because theory Y is a dogma/cult/holy cow/religion/what they have been told to believe by mainstream media” - the point is of course that an objections to theory X might be perfectly resonable and fact based. Objections will tend to be defensive (“its not a cult, it is mathematically proven that…”) making them seem weaker.
(I speak natively Spanish)
Javascript is terribly inconvenient and has tons of weird edge cases ("semicolons are optional except for these three edge cases", scope switching through using, the unpredictable type conversions) but the rules aren't that hard to write a transpiler for. Transpiling another language into JS will probably leave some optimisations on the table (by reimplementating methods in a way another language expects rather than calling the native Javascript API) but at least it has the normal API to rely on.
WASM is like Docker; it works on my machine, I can't get it to work on your machine, so we'll ship half of my machine and call it even. You're shipping standard libraries and JSON parsers to a browser as if you're pushing code to a bare metal server.
Javascript isn't a hard language to learn and neither are HTML or CSS. What I see many WASM people want to do is write browser code without ever needing to learn how the browser works. That's a terrible idea that will only end in either bloat or broken abstractions. "Let's make backend devs do frontend" is how we ended up with Java applets everywhere, which barely worked inside the context of a desktop browser, let alone on touch screens and phones.
There's a reason "native" desktop development has become "run an outdated copy of Chrome with some OS glue", and it's that web development is easy compared to native frontend development, especially if you target multiple platforms. WASM isn't going to turn backend developers into frontend developers overnight, you'll be stuck learning new frameworks and barely usable tooling regardless.
Just use JS, it's inconvenient but much a much better option than the proposed alternatives.
I fully understand the reluctance or just sheer annoyance of having to set up a toolchain just to end up with JavaScript. I've written an absurd amount of JavaScript since 1995. And yes, it is quirky, and awkward, and at times seemed downright ridiculous. ES6 at least was somewhat of a paradigm shift towards normalcy. Granted, JavaScript was created "in 10 days" and then simply became the de facto language of the web.
But after I started working with TypeScript, and enforcing linting rules through ESLint, and working in a proper IDE for it like VSCode, there is simply no going back. And it's not just the development that is so much better. With tools like webpack you also easily get tree-shaking, bundling, and minification, which are all good things for the users.
For very small sites with a single developer, sure you can just write JavaScript and call it a day. But anything even slightly beyond that and I would take the small amount of time to setup a build environment. It's not that difficult, and once it's set up properly it should stay out of your way and help tremendously.
I'm full stack lead on an enterprise Angular project that happens to require all of this stuff, but I would use it going forward for many less complex, non-SPA projects as well.
After 20+ years I don't necessarily loathe working on the front-end anymore.
That's not to say I didn't have to be pulled kicking and screaming into this world at first, while yelling "get off my lawn!". That may have been the case.
WASM simply is a better compilation target. More general purpose, easier to optimize, more compact, can load incrementally, etc. If you are going to compile your code anyway, you might as well use a proper compilation target if you have the choice.
More generally, I think WASM is starting to challenge the whole "there can only be DOM/CSS/JS" thing that has held web developers back for two decades. It was fine when that was the only thing that worked but there's a reason mobile developers, game developers, etc. prefer native: the web sucks. There has always been this creative tension between what designers want and what the web can do. We used to have things like Flash, Shockwave, and Silverlight. HTML 5 has largely failed to replace those. We deprecated the plugins for security reasons. But we never got a decent replacement.
With WASM there's no good reason left to keep on preferring DOM/CSS/JS. It's there if you want to, but there are some alternatives now. In its current state, that still requires things like C++ and Rust.
But WASM is maturing rapidly. There are a bunch of things behind feature flags in browsers (like the new GC stuff) that will level the playing field once those flags get removed. From there, it's mainly a matter of UI frameworks and tool chains that need adapting. Jetbrains is actually targeting wasm with compose multi platform. It renders to a canvas. Currently experimental and it only works if you set some feature flags on your browser. But it allows for portable UI development with Compose and allows you to target Android, IOS (alpha release), Desktop (jvm), and soon Web via wasm with the same codebase. There are probably other UI stacks that might soon start targeting web. Blazor of course was an early adopter but it ships its own GC and that makes for a bit chunky apps. And of course there is a wasm based replacement for Flash.
HTML 5 is no longer the only game in town. It will have to compete on merit now instead of merely holding a de-facto monopoly.
We're going to need a pretty advanced WASM decompiler suite built into the browser before I'll accept it as just as opaque as Javascript.
I despise the WASM web application platform and its blatant <canvas> abuse. It's building a browser inside of a browser to save developers time, and every time web pages become slower and worse to use because of it. React (Native) did cross platform app+web development years ago without downloading several megabytes of executable blobs for every page you visit.
WASM is just Java applets and Flash embeds, but invented for the fourth time. They have the same problems and will inevitably cause the same slowdown and headaches a few years from how. The only difference for developers is that you can now use Rust to write them and that your users can't turn off loading your binary blobs.
https://docs.google.com/document/d/1oDBw4fWyRNug3_f5mXWdlgDI...
Some of the outstanding issues still to figure out:
• Autofill. Users want browsers to be able to autofill/autocomplete things, but without that leaking personal data to sites unexpectedly (i.e. the content needs to look present but can only actually be present from the API perspective once the user has confirmed they want it).
• Secure composition/iframes. Essential for anything with ads, social buttons and some other use cases. Yes, you can define ads as being out of scope but then a lot of people won't bother to learn your new framework because it will be less general.
Ultimately, the technical problems are severe enough that WASM frameworks will be of limited use, quite possibly forever. It's just not in the interests of browser makers to disintermediate themselves like that. You can get a long way by blending DOM widgets with other stuff though.
There are x-platform UI frameworks out there. Making good ones is hard but again, HTML is not a good UI framework by any measure. Normally UI toolkits are compared based on the breadth and depth of their control library but HTML barely tries to compete in that realm. It prefers to focus on things like advanced typography.
No one was held back, people keep choosing the web because it's consistently better.
What I think is crazy is this drive to take something that is working great (the Web), and then jam in an approach that has already failed multiple times. We already tried several iterations of binary-heavy, non-transparent, non-searchable, non-web-native, second-ecosystem application platforms including Java Applets, Flash, Silverlight, etc. They had a chance and users rejected them.
If you think the web sucks, then by all means, I encourage you to make a compelling alternative. If it really is better then people will use it. But maybe don't try to spoil the working recipe of HTML/CSS/JS, especially if you don't fully understand the reasons why it keeps winning.
It's not consistently better. It's just marginally easier to develop simple things for.
> They had a chance and users rejected them.
Users rejected them because they were slow, bloated, and didn't play nice with a lot of things. Fast-forward to 2023, and users have embraced mobile apps (and not mobile web/PWA crap that we're told is about to get just as good as apps any time now).
> If you think the web sucks, then by all means, I encourage you to make a compelling alternative.
It's already there. It's called apps.
Your position is that Flash didn't compete (and lose) on merit?
After that, security concerns lead to browsers eventually deprecating their plugin support. But it started with Flash getting a huge access denied on mobile, courtesy of Steve Jobs.
So, Flash became a lot less popular after that and Apple and Google successfully transitioned a lot of that stuff to their native mobile SDKs. That's why you have lots of games on IOS and Android and not a whole lot on the web these days. HTML 5 is hopelessly clumsy for that sort of thing.
A lot of the stuff people did with Flash is of course technically doable with HTML5 but mostly it seems designers shy away from doing those things because it's too hard.
Wasm is going to open up a lot of native and mobile SDKs for the web. And the web of course also works on mobile. There might even come an end to Apple blocking non-safari browsers in their app store.
Or... he blocked it because of all the actual reasons listed when Flash was blocked? And the same reasons why it was blocked on Android just a year or so later?
I mean, it's not ancient history. It only happened 10 years ago.
And the fact was that Steve Jobs had a history and long habit of forcing walled gardens on consumers - something well known in that era.
In fact I would call it the "widely established" fact https://www.infoworld.com/article/2627117/iphone-developers-...
Of-course most of this depends on whether you had personal experience developing productive flash apps and whether one suffers from the Apple propaganda effect - where Apple's position is King and all other positions are null and void. I happen to see the latter quite often on HN.
There's lots of times in my work when I will read minified JS code to debug a stack trace. Using the "Pretty Print" option it's not too bad. So I'm glad it's there.
Also transparency is not just about humans reading it, it's also about automatic scanning of the source, and in some cases automatic modification of the JS (for browser extensions or code analysis or etc). Those are useful things that are drastically harder using WASM.
The times when people "hacked" the JS of the websites they visited are long gone, and for nearly all web applications (which is what WASM is useful for, as opposed to simple websites) the code is already completely unreadable (even if it were not minified, I mean, you would probably need to spend weeks understanding what it's doing for non-trivial stuff)... it's even illegal today to alter websites you visit to use "hidden" features, depending on your jurisdiction.
Besides, WASM is not going to displace JS, it will just give people an option to achieve things they couldn't with JS alone.
This is an overly narrow and ungenerous interpretation of the criticism here. Frequently JS can be close to unreadable after minification (and even then, that's still only "frequently", "can", and "close"), but the anatomy of the page is as manipulable as it's ever been through standardized interfaces (DOM). Browser extensions and other features baked into browsers that depend on this ability to fiddle with or read e.g. form controls are ubiquitous. Flutter (or Flash) rendering a blob of pixels to a canvas destroys this. We'd never have gotten tabbed browsing or popout picture-in-picture videos with native playback controls or password managers or AdBlock Plus and uBlock Origin if executing opaque SWFs and Silverlight bundles were gating users' access to Web apps.
(Worth pointing out that there's nothing really "Web" about them at that point, either—only through a dubious transitive argument involving the fact that the thing they're executing in has traditionally been called a Web browser).
What? No it's not. It seems to me you completely misunderstand WASM by saying "the anatomy of the page is as manipulable as it's ever been through standardized interfaces (DOM)" as that's clearly unchanged with WASM! WASM doesn't even have access to the DOM yet, so literally WASM uses the same JS code browser extensions do.
Though truly no software is obscure enough, given enough resources (time and money). All software is open source if you care to look hard!
Not really, because open source has a definition and that definition refers to the form that the software was authored in.
In addition, there are homomorphic encryption methods which make it possible to completely obfuscate the SW function, practically speaking. You don't even have to go that far, just look at a typical LLM network.
(As an aside, I think it would be funny if someone implemented a game where Minecraft-like crafting functionality would be implemented through a one-way hash function. So no one could look up the recipes in the source code. Or an adventure game which would hash the input command and the world state to decode the resulting progress.)
Well, yeah I was referring to reverse engineering it.
> ...which make it possible to completely obfuscate the SW function, practically speaking.
"Practically speaking" is the keyword here. Given enough resources (time and money), anyone with enough skills can find out how any software works and re-implement it, even if the original source code is lost.
The main premise here is that the CPU has to be able to see the instructions to execute them. If the CPU can see them, I, as a reverse engineer, certainly can.
> (As an aside, I think it would be funny if someone implemented a game where Minecraft-like crafting functionality would be implemented through a one-way hash function. So no one could look up the recipes in the source code.)
I like the idea!
Though I'm not clearly seeing why is that a challenge. From a security standpoint, browser security and compartmentalization is very strong. From a learning standpoint, many wheels will be reinvented (but that's true today even in a JS world, just check out npm registry).
This _should_ be gotten thanks to work on stack switching in WASM. As of the most recent working group meeting on this [0], it seems like V8 has made a good amount of progress on this. They published a thing back in January[1] on this, and hopefully if things go well and this is available across WASM engines then there will be one less "JS-ism" (everything async) that causes issues for transpilation.
[0]: https://github.com/WebAssembly/meetings/blob/main/stack/2023...
The fact is right now if the source language has a notion of blocking calls, the when compiled to a non-blocking target like WASM it currently has to do a bunch of tricks that outright makes things slower. WIth these improvements, those "blocking calls" can properly end up non-blocking at the JS layer, matching what we all know computers can do.
JS stuff is non-blocking because of the original sin of Javascript (we have to execute all the JS before we can render a page, since there can be some document.body = ... nonsense in there). This is incidental to the programming model, and not some deeper truth about how things should be programmed.
Case in point: non-blocking `async` code in Javascript ends up sometimes turning into blocking code for performance reasons in specific cases (when awaiting an already completed promise, notably). Jumping in and out of an event loop isn't exactly efficient either.
What a completely unnecessary thing to say in the middle of an otherwise reasonable post.
It's applies for many programming groups. Those like to live in their realm, one where that their language is the greatest and thou can't be spoken negative about.
Just try mentioning C++ to a bunch of Go programmers or Python to a bunch of Rust programmers.
Not to say there isn't crossover but it's all ironic really, as most languages were crafted from C.
Still I agree with your other comments, and in particular not being able to share caches in the browser is very unfortunate (but understandable).
Typescript is ok overall and the various frameworks / libraries used to generate a browser elements are really to my simple take not so much a language workaround than the best some very smart people have envisioned to build/update browser elements Well maybe in another language react hooks wouldn’t be so quirky
These existed. You could have used VBScript instead of JavaScript (Internet Explorer). Or, perhaps, you might have wanted to go all the way in the other direction, and use JavaScript syntax for your stylesheets, instead of CSS (Netscape Navigator, JavaScript Style Sheets aka JSSS). As for HTML, it might be possible to use pure XML styled directly with CSS or something like XML-FO, without having a XSLT which transforms it into HTML, but I don't know which browsers support or have supported that.
Can you share some examples?
Since this has nothing to do with JS per se and is a standard example to showcase the counterintuitiveness of IEEE 754 doubles, then does this mean that you have never worked with another language that uses IEEE 754 doubles? (And in what other languages do you find yourself typing "===", i.e. what would motivate you to type it out "on first touch", anyway—rather than "==", that is?)
The quiz is filled with other examples like "+!![]". Can you briefly explain what intent/expected behavior is associated with the mindset a decision to type this out in a program and how JS violates those expectations and would therefore would be better if only it could be changed?
Do you have some real-life examples of things you've personally encountered, rather than crazy examples that no-one would actually write?
WASM will be used in cases when performance and correctness is worth the extra effort. Libraries, components, etc. Js will glue it all together, like the Python of the web.
There is now a generation of developers equating front-end with web.
> ...but I'm pretty sure I'm not the only one feeling this way about it...
There are dozens of us!
I'd go further than that. There is now a generation of developers equating all of Software Development with Web.
The irony? They don't think their web browser, code editors, IDEs, operating systems, etc. are also software that someone developed. For them, it's like firmware that just magically appeared.
As a somewhat extremist on this front, I'd rather "the web" was still Gopher that shifted nice PDFs generated in LaTeX and 80 column formatted text files. And email was plain text only. And leave the rest to native apps on whatever platform you happen to like.
WASM is basically Flash but less shit.
Yes there are a few weird things around true/false evaluations and other syntax "gotchyas", but they take at most 5 minutes to grok the ones that actually come up in normal day-to-day coding, and many of the other things that people like to flag up (like scope in blocks/functions) are often the same in statically typed compiled languages too - there was a blog post from golang just recently about a "common mistake" around scoping of variables in loops etc for example (sorry cant find link). Don't even get me started on Python's weirdness.
What I am saying is there are many ways to shoot yourself in the foot in any language - you'll "get burned" in anything that you don't really understand. First-touch of rust without really knowing the language that well? First-touch of c++ without really knowing the language that well? Have fun not getting burned with those until you have studied a proper rust/c++ course that tells you precisely all of the traps. It turns out that you need to know about a programming language to use it effectively.
And for what it is worth, modern ECMAScript does not need a transpiler - it executes directly in the browser without any molestation. Typescript requires transpilation to javascript before execution, but you can get a long way without typescript if you want to without sacrificing too much besides types (and tooling these days for standard ECMAScript is excellent)
I think that maybe perhaps you are confusing javascript with browser-based frameworks like React? React and NPM are a total dumpster fire of awfulness, but they are not javascript.
I'd encourage you to give modern, native ECMAScript another go.
\LoadExtension{yoyodyne:csv-reader:1.0}
to bring in an extension and if there isn’t a local copy of the extension, it will fetch it from a repository, and I’ll want to bundle a bunch of stuff into a standard ZIP file layout (so that documentation, etc. will be easily fetched).The list of languages that can compile to WASM increases on a regular basis and it seems by far the best route for plugin handling in a greenfield project.
> and I’ll want to bundle a bunch of stuff into a standard ZIP file layout (so that documentation, etc. will be easily fetched
I've always, thought it would be cool if Wasm runtimes had a generic supported format for this. Kind of like a Java JAR. But of course, you can implement a custom version for application pretty easily.
Your phrases made me think the wasm support was an official nvim move, but it looks like this is a third party project. Is that right?
It would be an huge deal or revolution if it could perform faster on plain DOM manipulation. By now, plain Javascript is faster than WASM [0].
That's because all WASM's DOM manipulation must go through the Javascript engine and many browsers do JIT compilation on Javascript.
Edit: be aware that the article has a more interesting discussion on WASM on the server side, as a replacement of technologies such as Docker/containers, Java Virtual Machine and .Net.
[0] https://krausest.github.io/js-framework-benchmark/2023/table...
That's not something you'd use for "computationally intensive" applications. Frankly this shit has been around for years and the major implementations still suck.
As for servers, it's insane to pretend you don't know what your server's CPU is and run your crap in what's essentially a handicapped JVM. Made up solutions for made up problems.
Here’s an example of an architecture that seems to work well: https://x.com/paulgb/status/1688919428740816896?s=46
What I did was rewrite a chunk of our matrix math library, previously written in C, directly into WASM with the shiny new SIMD operations.
Rewriting a naive 4x4 matrix multiplication with SIMD gains you 3x to 4x on on x86 (with the algorithm from the answer in [1]), and a direct translation of that using the WASM SIMD instructions gains you nothing on Chrome.
On Firefox the WASM SIMD is 20-30% faster than naive multiplication, which is not much, but it's something. The issue is that on Chrome the WASM version is dead even with the scalar implementation, and to be honest I care a lot more about performance on Chrome than on Firefox.
[1] https://codereview.stackexchange.com/questions/101144/simd-m...
My apologies, that was clear from your original post but I misread it as saying you were porting into C to use SIMD in Wasm.
Thanks for the stats, that's good data to know.
I am an author of a large ClojureScript app, which sometimes does need to do intensive computation. In my experience, the performance of compiled ClojureScript (it uses the Google Closure compiler in "advanced" mode, so the code is really optimized) is not a problem at all. What is a major issue is DOM manipulation: any time you touch the DOM, you run into slowdowns of two orders of magnitude. And that can't be magically waved away by WASM.
In my case, if I had a ClojureScript->WASM compiler, it would likely provide me with an overall perceptible app performance gain in the 5%-10% range, while introducing a whole range of interesting bugs and issues. Not something I'd like to use.
It would enable any language to simply render their own UI and handle things like accessibility with their own accessibility based DOM that just handles the accessibility parts rather than the entire logic of the app. I believe this is what Flutter does.
For example on macOS with Chrome, you’ll have Flutter running on Chromium running on AppKit. All of these provide text layout engines, compositors, 2D and 3D graphics, widget hierarchies, scripting languages… Hundreds of megabytes of redundant stuff loaded in memory to run some typically basic Flutter app.
I know, we can’t magically have native binaries delivered on the web (that was ActiveX and it was bad). But it somehow boggles the mind that this is what we ended up with.
simply is doing a lot of heavy lifting here.
> and handle things like accessibility with their own accessibility based DOM that just handles the accessibility
just is doing as much heavy lifting as simply before it.
> I believe this is what Flutter does.
Flutter "just" "simply" have a trillion-dollar company sponsoring their project that came out of internal power struggles. And they have "just" "simply" been working on it for 6 years, and currently has 11 thousand issues in their repository.
Yes. Instead you're shipping the entire app, including the whole graphical framework, with every app.
To quote Figma, "Pulling this off was really hard; we’ve basically ended up building a browser inside a browser." https://www.figma.com/blog/building-a-professional-design-to...
Are you sure this is what you want?
Now if you just want to make a website or webapp (with no intention of making it cross platform), stick with the DOM, it's not going anywhere.
You're still going to ship basically an entire browser per every app in the browser. Where do you think the new glorious UI for your app is going to come from with WASM?
So, for example. The currently featured app in iOS app store is Plane Finder. It weights 99 MB. [1]
So your proposal now is to ship those 99MB to every user of the web app written in WASM. However bloated we think modern web apps are, they are not even close to these numbers.
https://apps.apple.com/se/app/plane-finder-flight-tracker/id...
If you want a thin client app, put all your logic in the server side and don't ship as much code on the client side, whether it be in the DOM or WASM.
In contrast, I can have native performance via WASM, even if the binary size is large (it will get smaller over time, but even then, most people don't really care about binary size, they care about speed).
If it's, say, 300 MB, 3 apps will be over that limit, and the fourth will purge at least one of them.
Why not just use desktop apps you ask? Well, people apparently don't like desktop apps, they want to work in the browser, so we have come to this roundabout way, using WASM.
They've already done that. That's why compiled wasm storage exists.
Streaming, diff updates etc. are not the property of the browser, but of the app.
And, again, browsers cannot have unlimited storage for downloaded apps.
> Why not just use desktop apps you ask? Well, people apparently don't like desktop apps
People do want to use desktop apps. Instead of actual desktop apps we get shitty web apps running on Electron.
When WASM becomes popular enough, browsers will indeed implement streaming and diff update optimizations, just as HTTP 2/3 does today for DOM based sites and applications. Browsers will become the unified runtime for WASM apps, so they will support the common operations and optimizations for such apps.
> People do want to use desktop apps. Instead of actual desktop apps we get shitty web apps running on Electron.
Yes, that is my point. WASM will make these apps fast because they are actually compiled rather than be interpreted by the JS JIT as well as shipping an entire browser per app.
I am honestly not sure what you're arguing for. You talk about shitty Electron apps, which I agree with, but then don't seem to have a solution, which in my case is WASM apps on the browser or via a runtime like Wasmtime. What is it that you actually want?
Solid is at 1.09
Dioxus 1.14 - wasm
Leptos 1.18 - wasm
Angular 1.62
React 1.64
Now, that's just DOM manipulation. Any real app, especially ones where performance matters will have a huge shift towards computation that's not DOM related, even if the app is not computationally extensive.
For a very narrow definition of "computation intensive applications" where definition is "speeding up some parts of some workloads in some situations on web pages"
The browser will be the unified runtime for WASM apps, native level performance with the linkability and other advantages of the browser.
Later, the Java VM was created, to avoid rewriting the same code over on every platform, but it was slow because it was interpreted, but thanks to JIT, that was pretty much taken care of. The main problem then became the fact that it, like ActiveX before it (which wasn't cross-platform), got general access to the file system, and could never really be safely used.
It remains to be seen if WASM/WASI retain their commitment to capability based security, which is at this point the main selling point. There have now been fast cross platform systems, but this is the first that builds in capabilities, and doesn't give general access to the file system.
Analogy #1 - We need such a system... it's like power in a home... with a circuit breaker, and the promise that you're only going to get 15 amps, not all of the power of the grid, flowing to anything you plug in.
Analogy #2 - It's like cash in a wallet, you decide how much to hand over to an untrusted partner in a transaction. You should be able to decide what files/folders to hand to a program, and know it won't get anything more than that.
Analogy #3 - The IBM PC XT with twin floppy disks was the most secure general purpose computer of its time, and still is. You had control over your data, full and transparent control, because you decided what the allowable side effects were when you decided what disks to let it access, and also if they were read-only or writeable. You can't do that today.
I'm a fan of the concept of WASM as an isolated runtime you can safely embed into any application, basically allowing you to load and execute untrusted code if you have to, but the people driving WASM adoption are quickly expanding the attack surface to the point I don't trust such a setup anymore.
Burroughs in 1961 was already bytecode based, all Xerox PARC systems used bytecode, as did several other systems.
Pascal P-Code might be one of the most famous ones, however there plenty others to learn from.
WASI is probably doomed to fail, so far it was proven to be challenging to make "write once run everywhere" API, for example it's difficult to abstract over epoll vs IOCP vs io_uring without reinventing libuv, but making a standard out of libuv API will make adopting any platform changes too slow, because of losing control over the implementation of the API. Having a single standard implementation where the industry is collaborating might be a better way, similar to how .NET is an abstraction over platform API.
(Feature-limited) Photoshop was ported to WASM in 2021.
https://web.dev/ps-on-the-web/
With the deprecation and imminent removal of WebSQL, the official (Google) recommendation for SQL-in-browser is WASM SQLite.
I'm all for WASM but it seems more on the level of a new processor generation or faster RAM than something revolutionary. I'm sure it took a lot of hard work by smart people, but for most of us it's an implementation detail.
In retrospect, with the chrome monoculture we have today, this seems like a silly argument but at the time it was a legitimate concern.
See the aside about SQLite WASM on this blog post.
But absolutely there are a lot of of less demanding web applications out there that don’t need this. And in the case of Figma, it’s the core of the application that uses WASM, with the more webby UI bits outside of it for all the devex reasons you’d expect.
In truth it’s a medium deal in the sense that it enables use cases that simply aren’t feasible without it, but is arguably irrelevant for most “conventional” web dev problems.
In that vein I’d argue it is more relevant for use cases that currently aren’t on the web at all versus as an improvement for those that are.
Therefore, "Figma is built on WebAssembly so WebAssembly is good" is weak argument.
They are using WebGL. Using WebGL from WebAssembly has some nice advantages; with Wasm you can use languages that are more accommodating to the sort of densely-packed data that you need to send to GPU buffers.
Here’s an interview I did with a raster graphics editor that touches on why they use Wasm for GPU. https://digest.browsertech.com/archive/browsertech-digest-ho...
One way or another, the command buffers are an encoding process. They're not WASM code nor JS code, they're GPU code. You need to build them from one platform for another platform. There's no any direct correspondence between WASM and WebGPU, let alone WebGL.
Here’s an example of a Rust object with a layout that can be sent directly to a GPU buffer: https://github.com/paulgb/webgl2-glyph/blob/ef5a64a708856d67...
That doesn't mean it's a technical thing they're doing right, particularly.
HN loves to shit on webapps and honestly with very good reason but the reality is that for a lot of people a cloud-based app they can use on absolutely any computer (or, often, phone/tablet) they can get their hands on is a huge boon.
Web apps remove initial friction of installation, and for big apps not even that much because you still need to download it and run it. But they also pay up this gain, with huge interest, for every single second you use the app. This is not benefitting the users. The bottom line is dire.
However removing initial friction is all about getting your foot in the door. It's like selling a printer under cost and then you get them with the ink. Get them the first drug dose free, and then you get them when they're dependent. Offer a cheap design, and then you destroy them with the manufacturing.
A story as old as the world, of which this "web megaapp" model is a tiny microcosm of. The web is an excellent platform for small to medium apps. Photoshop is gigantic. And Figma and the other rest of its ilk are absolutely insufferable and I'm saying this as a webdev. I would be significantly happier if these products did NOT exist.
Heck if we took out WASM and these kind of products went away I'd consider it a net positive.
Consider that a WASM build can be run server side on multiple OS and arch. The same build. The API can be controlled and locked down (think security).
The web is not the most interesting place for WASM.
However none of this matters. Because we have Java and countless other cross-platform runtimes. WASM is at best just another variation on the same theme thrown in the same pool. I definitely see how one could justify WASM hype by saying all the things will be WASM because it's so sandboxed and multiplatform. But that's the engine of all hype cycles. Truth is it likely won't happen, because WASM is nothing new and nothing unique. That niche is filled with solutions already.
We could theorize everyone will have a WASM compiler backend because it runs in browsers, therefore it'll become more useful on servers as you have compiler backend for everything to WASM. However YOU yourself said the web is not the most interesting place for WASM. So what will supposedly drive the WASM ecosystem, that makes it interesting (the web) isn't interesting, but it has to be interesting so the server use of WASM becomes more interesting. Quite the chicken egg problem there. Might work, might not.
I lived through a period on the web when every language had a JS compiler backend. You could compile Java to JS, Delphi to JS, C# to JS and so on. Maybe some of those solutions still exist in some half-dead form, but they're largely abandoned, because people realized the best language to write JS in... is JS. This is also why TypeScript has such success, because it's JavaScript itself (but with types).
For WASM we can argue there's no such pressure to "write JS in JS" but there's just very little value for it, outside the nerd realm of "OMG assembly on the web". I know why Google wants it. It wants it because it indexes the web, and puts ads on the web, and so therefore it wants everything to be the web, because then it means Google can index and put ads on everything. That's good for them, but not for anyone else. Downloading and running hundreds of MB of code for an app like Photoshop, or whatever, over the web is an absolutely miserable experience. Not to mention the HCI input capabilities and OS services available to the app, which are understandably limited in a browser.
Can you give an example of how builds are a problem due to Linux/BSD distros?
Plenty of WASM advocates act ad if we haven't had endless attempts at since the 1960's.
Also doing kubernetes with WASM containers must be a bad joke, when comparing how managing Websphere 5 in 2005 was so much easier.
On the browser side, it is a convoluted experience versus using Flash/Code Alchemy, Java Applets, Silverlight, with Blazor/Flutter being the only ones that somehow come close to how it used to be 15 years ago.
Two (very?) significant distinctions though:
- wasm actually try to be an open standard
- through WASI it will attempt to be a first-class VM, with typed (though wit), direct access to all web APIs and the DOM
Admittedly, WASM is making slow progress (much to it due to Google actively/passively sabotaging it) but it is the closest we have got to a universal compile target. In particular, the combination with Rust could be a game changer and make whole categories of DSLs obsolete.
It also has the potential to open FE work for people which categorically refuse to work with the mess that is the JS ecosystem.
https://docs.flutter.dev/platform-integration/web/wasm
Since Google use Browsers as their app and as distribuition platform, I always thought that anything that made browsers easier to target vs native apps was a win for them.
Yeah, I really don't get the value add of WASM here. If you are doing rust, then why not do a scratch container natively compiled? It's the same experience with half the effort.
You can do the same with most programming languages.
Wasm solves that problem, but is it really a problem?
The reminds me of java but with native web browser support instead of applets.
WASM should hopefully not be bad from a security perspective, but the up-front performance penalty of early demos in downloading megabytes for hello world was painful.
More purpose-fit, smaller modules ought to be broadly useful but I'll not be holding my breath. Anything that needs to take over a canvas probably isn't going to be widely adopted outside of some niche things like visual design tools or the occasional game.
> Megabytes are certainly an exaggeration, see 285.4 KB for Leptos
Those early demos were certainly quite large. I don't think that I found any early demo of WASM to be under a megabyte, for sometimes quite trivial things.
Google Docs switched to rendering a full screen canvas rather than using the DOM, and Flutter/Compose do the exact same thing.
WASM is very much heading in the direction of owning a rectangle on the screen. Plus, Java and Flash embeds could also call Javascript callbacks while leveraging the improved performance of their native plugins.
Another pattern I’ve seen is to render DOM on top of a canvas, with UI elements done in the DOM, and high-performance graphics on the canvas. This seems to be a good balance. https://x.com/paulgb/status/1688919428740816896?s=46
It doesn't. Any interaction with the page happens through a JS bridge.
> Wasm fits in with semantic web content to the same extent that JS does.
It doesn't. It's a VM that runs side by side and only has a tiny window into the rest of the browser through arrays of integers passed between it and Javascript.
Right. The point I’m trying to make is that Wasm can only interact with the user through those JS APIs. This is in direct contrast to Java/Flash, which could directly render on the screen with an API that bypassed the browser’s JS layer.
Some magic incantation has to change those bytecodes into executable code.
Java applets used Java Swing UI
Are you telling me I will need to print more invoices and sell more training?
Don't threaten me with a good time. I'll fork a wasm lib make a few changes rename it and put it on my CV. That's how the webdev world has been working for over a decade now. Oh I'l also misuse some design patterns and other plausible sounding "engineering" practices to make it look cool.
Push the boundary too hard (as an industry) and I'm pretty sure we'll go back to the dark ages of desktop apps. I miss Delphi so much sometimes!
> I'm sorry, are you telling me there will be more work needed for achieving the same thing that could have been achieved using plain HTML, CSS and JS?
I also never understood why junior Web Devs prefer to write a ton of React code, when there are obscure frameworks that have a Qt-like API. Consider this Qooxdoo[0] code:
var win = new qx.ui.window.Window("First Window");
win.setWidth(300);
win.setHeight(200);
win.setShowMinimize(false);
this.getRoot().add(win, {left:20, top:20});
win.open();
I don't quite understand the JSX hype.--
<Window width={300} height={200} minimize={false}>
and rendered on demand.Painfully constructing UIs one line at a time is, well, painful. The whole DOM API is like that, and people have been trying to get away from it since at least jQuery.
After considering electron for a split second, even with no framework, I legit went for Gambas.
I drew my UI, added event handlers, compiled it and that was the end of it. Easier than faffing around with the bloat of react, vue, node or electron.
I'm not a web dev (particularly) and I'm watching wasm keenly.
It will be amazing for compute heavy stuff in the browser I'd imagine. Cross platform assembly is a super cool idea. If they can get it right at least we might have something besides a container that runs anywhere.
I'm just not sure I want them to mess with JS/HTML based UI just when it was really getting awesome and declarative was becoming standard... And since web devs like. Making stuff harder than it needs to be they might...
They should've stuck with "this is crossplatform bytecode for the web", and it would've flourished there. Instead, now it's "designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications." [1]
Servers! Applications! Tigers! Lions! Oh my!
And it's not particularly good, or effective, or performant at any of those.
I think for that reason wasm will win. Outsource your compute to your users.
Getting all this to work was ... laborious. The debugging situation for worklets is pretty painful at the moment... it's more like writing microcontroller code than normal desktop. But that will improve, and being able to do it all in the browser such that the guts of my work can be reused across browsers, Max, or stand alone C++ is huge for me.
I think WASM will really take off when we get proper browser API access direct from WASM. Right now the passing back and forth to the JS host adds a lot of work.
For example, I've toyed with the idea of creating a game which runs its logic/simulation entirely in WASM with the only input being the controller/keyboard inputs. That way you can create perfectly reproducable replays which could be used for racing games or timed platform games similar to Mario Maker. Then your leaderboard of best times can be properly verified (not accounting for manufactured/edited replays similar to TASs, Tool Assisted Speedruns). You could take it a step further and include previous versions of the game simulation WASM to get backwards replay compatibility, which is also uncommon in games.
https://docs.flightsimulator.com/html/Programming_Tools/WASM...
That exchange of knowledge was possible because a) for all it's warts, JavaScript became the standard for everyone in the field and b) the only way to publish your work was to publish the source (at least a derivative). WASM blows away both of those assumptions and takes us in a direction more similar to desktop software, where you may have a copy of the binary but may not even (easily) determine which language it was written in.
I've been a Chrome OS user for a decade. I no longer worry about the OS, files, or versions. This is great. What we do need is the ability to build the UX locally outside the confines of the browser outside of the existing OS.
The idea that files can share user space with other files without explicit permission always felt off.
The point of HN is in large part about thinking about the future and not just look about how things are just "right now". There is no point discussing the impact that things have right now, we can just measure it.
Other people in these comments have mentioned using it as an extension mechanism to other applications. That’s nice.
But what browsers use it internally? What popular JS/TS libraries? What big websites?
It seems Figma does, but I had to Google to find that.
It’s an interesting idea, but it feels a bit like VRML or something else so far. “It’s going to take off, just give it time.”
Some things will. Some won’t. But WASM doesn’t seem to provide enough above JS to overcome the “we can just use JS” hurdle for the vast majority of uses so far.
This will have a detrimental effect on third party tools and plugins like accessibility tools and ad blockers.
True, you can already do this with canvas & plain JS, but more obfuscation will make everything worse.
Eventually we won't be able to browse even the simplest websites without executing JS(wasm).
That being said, I'm all for making things run faster. But I doubt it will actually benefit users in the long run. Web companies will just run more ads/tracking/AI Learning on peoples machines, making things slow again.
But I also don't think it diminishes WASM's value on the web. It will allow us to drop JS for good, at last.
This stuff has been fixed with ts and, ESM in the browser.
But if your answer is “I’m building a SaaS, I don’t need incredible cutting edge performance” - it seems less necessary.
Yes you can, ONNX. Yeah, it's not _literally Pytorch_. But it takes about 10 minutes.