The State of WebAssembly 2022
blog.scottlogic.com
blog.scottlogic.com
The last one to bite me is Linode’s login: I can’t even login to my account to adjust a DNS setting without WebAssembly. That’s a problem because the browser I use, Firefox on PowerPC 64 (a current production CPU, not an old Mac) does not support it.
Yes, I can and have found workarounds, and I do have a variety of machines around that include AMD64 CPUs. It’s still an annoyance for no good reason that I can see.
As for the linked article, I’m not surprised to see Rust rising there because in some quick tests I did, everything worked as advertised with minimal friction.
1: Know that webassembly does not work on the PPC version of Firefox.
2: Have access to a PPC machine for testing in 2022.
It is an unfortunate but exceptionally rare edge case that few websites will ever actually encounter.
(I wrote a web app in 1998, pushed the team to adopt shiny new HTML 4.0 and Java, but all the front end was data validation that was replicated on the back end anyway. In retrospect it was a lousy way to develop the system - I started with fancy and worked my way down, ass backwards that blew the dev budget - but at least the damn thing had a layer of fail-safe server that worked (handled errors and notifications) no matter what you threw at it.)
I'm writing this on an ancient iPad with JavaScript disabled. This is a text site. It works.
> “Unfortunately I have not had time to do much more work on the JIT because of the holidays, family responsibilities and $DAYJOB. I won't be offended at all if someone beats me to the punch especially as I'm starting to see WebAssembly becoming a hard dependency even for some add-ons (without the JIT there is no support for wasm).”
> https://www.talospace.com/2019/12/firefox-71-on-power.html
That’s from December 2019. As of 2022-05-31, there has been some progress but it’s still not working:
> “I can't figure out where the bugs are in our POWER9 Ion JavaScript JIT implementation, though I still strongly suspect it's because we use sign-extended 32-bit ints. This is enough to pass the test suite but still breaks with the web. MIPS does too and we are strongly based on the MIPS port, but one wonders if MIPS suffers from the same issues, and I'm quite sure it's not tested anywhere near as well. As 32-bit arithmetic instructions aren't orthogonal in Power ISA this change would require some significant rearchitecting and I've just come off a really bad week at work, so I'll just try to pull up the current JIT to 102 so that those of you building the new ESR can continue to use Baseline Interpreter and Baseline Compiler, and then it will be time for more major surgery on the source code. You can help (please!).”
> https://www.talospace.com/2022/05/firefox-101-on-power.html
Looks like it’s not that simple.
As adoption ramps up, the pressure to make filesystem access "easier" will increase. I just hope they hold it off, as isolation is the key feature of the platform.
Not sure where this worry even comes from? Browsers have never let anything (not even JS) have raw access to the host FS, so not sure why Wasm would be different.
Edit: Ah, I realize now you might be thinking about running Wasm outside of browsers, via some other runtime. If so, I'd understand the concern as most desktop technologies allow unfettered access to FS and more.
The design of the WASM vm seems to preclude escapes, unless people get sloppy and make ladders that can be climbed out of. That's where my concern comes from.
I'm not sure what you mean by "raw access", but the File System Access API certainly allows web applications to do a lot of things.
> The File System Access API (formerly known as Native File System API and prior to that it was called Writeable Files API) enables developers to build powerful web apps that interact with files on the user's local device, like IDEs, photo and video editors, text editors, and more.
https://web.dev/file-system-access/
> After a user grants a web app access, this API allows the app to read or save changes directly to files and folders on the user’s device. Beyond reading and writing files, this API provides the ability to open a directory and enumerate its contents. Additionally, web apps can use this API to store references to files and directories they’ve been given access to, allowing the web apps to later regain access to the same content without requiring the user to select the same file again.
> Additionally this API also makes it possible for websites to get access to some directory without having to first prompt the user for access.
https://wicg.github.io/file-system-access/
It's not just a draft, it's been part of Chrome since version 78 in 2019.
> After a user grants access, this API allows web apps to read or save changes directly to files and folders on the user's device. It does all this by invoking the platform's own open and save dialog boxes.
https://blog.chromium.org/2019/09/chrome-78-beta-new-houdini...
Discussion at the time:
I'm just keeping my fingers crossed that this one sticks .. oh and, please make WASM run in a browser without JS :)
Perhaps we should include HTML and CSS in the list of languages to choose from next year! :P
I picked JavaScript thinking of AssemblyScript as a tool (not a language) to use JavaScript (with types) as a language compiled to WebAssembly. Maybe the results are not accurate.
I also use Wasm for web (the largest category of use so far) and would not use a JavaScript engine inside Wasm to talk to plain JavaScript in a browser (I don't think any web developer would hehe).
Perhaps the survey should have an option to choose
"JavaScript running in a JavaScript engine inside WebAssembly",
and
"JavaScript compiled to WebAssembly",
to make the results clear as to which "JavaScript" people are using.
Does a JavaScript engine inside WebAssembly even count as a "WebAssembly language"? Or is that C++ and Rust actually?
Does running a browser in WebAssembly make HTML and CSS WebAssembly languages too?
I think that NEAR users just use the SDK, I don't think the users chose JS specifically for it to be in Wasm.
That's actually what I was thinking about when picking this option! Think of the following situation:
- You're a JS developer, and want to write a client / library mainly with JS
- You want to use Wasm only for some narrow, performance-critical parts
In this case, you may not want to use something like Rust, because that adds tooling overhead, makes the Wasm bytecode bigger & makes it harder to hand-optimize the Wasm. On the other hand, you might not want to directly write the Wasm in raw WAT, because that has crappy DX.
In this situation, having a JS library is a viable way to make the writing of raw Wasm somewhat more efficient. Example of this pattern being used in the wild: https://github.com/iden3/wasmcurves/blob/master/src/bls12381...
I still have not found a consistent way to construct a sqlite connection, pass it to wasm (language agnostic) and then return and close it.
> Note: This proposal is currently inactive, with work having moved on to the component-model repo.
This is never getting done, is it... this is the fourth rewrite of such a feature.
These things take time. If all else fails just write a polyfill. Component model doesn’t add anything new runtime requirements that can’t be polyfilled
I'm super happy to learn that Wasmer (https://wasmer.io) is the most popular runtime (regarding most people having heard of it). But I would like to cheer all the other runtimes for their awesome work, it's always good for the ecosystem to have a healthy amount of competition on the runtime space :)
I think the main use case is "serverless" or "edge compute" where start-up time is often hugely important.
If they're creating code that will run on my servers I need to have an EXTREMELY reliable sandbox around it - I see WebAssembly as providing the best possible option for that these days.
Letting them write their customizations in JavaScript which I then execute in a JavaScript interpereter inside a WebAssembly container sounds like a pretty good option.
2. WASM's best use seems to be to cross-compile C++ GUI apps in a browser (like Unity engine). Ok, but it's not platform native, so will this feel like weird Java desktop GUIs all over again? The best apps are native
3. Web apps are I/O bound. How does wasm help?
Have a look at Grain for a ML like language with GC runtime.
- speed up in some cases - ability to compile the same app to native
The weird Java desktop GUIs were weird not because they weren't native code, but because the standard Java UI didn't use native UI APIs, nor did it even try to at least look native (as e.g. Qt does). But, just as there are native UI libraries for Java, there could be the same for wasm. It's just too early to tell, given how immature the whole wasm-outside-of-browser story is in general.
2) Actually, wasm is showing up in a lot of js/ts applications as an optimization. Mostly developers don't even notice their npms are pulling in some wasm. For example react does this apparently. What is native is a pretty fuzzy notion these days. A lot of mobile apps are hybrids that lean heavily on embedded browser components.
3) IO gets done by the browser via native libraries. The Javascript facade for this is pretty narrow (browser fetch API basically). If you are manipulating lot of data (e.g. graphics) in binary form, having some native code with actual types is helpful.
Wait, what? Why? Is WASM not Turing-complete?
Javascript can be compiled to WebAssembly, and there are people doing it:
https://bytecodealliance.org/articles/making-javascript-run-...
Figma uses it.
We're using it right now to drive a new physics integration.
This is another good summary: https://ianjk.com/webassembly-vs-javascript/
I would say there is hope when SIMD is supported across major browsers if your workload will make use of it. Just waiting on Safari. And there might well be more performance to eek out of the JIT compilation.
You can read more about how they use it here: https://www.figma.com/blog/webassembly-cut-figmas-load-time-...
> Because our product is written in C++, which can easily be compiled into WebAssembly, Figma is a perfect demonstration of this new format’s power. If you haven’t used Figma before, it’s a browser-based interface design tool with a powerful 2D WebGL rendering engine that supports very large documents.
- https://mozilla.github.io/translate/
These are neural models that are compressed and optimized to run on user's CPU. I write some of the code which repurposes the underlying (C++) library for extension's needs, all of which gets compiled via emscripten to WebAssembly for use in the browser.
Previous discussion on HN: https://news.ycombinator.com/item?id=31596888
Other big examples: Unity games, Photoshop, Figma, Google Earth, etc.
https://venturebeat.com/2022/05/12/wonder-interactives-the-i...
I would really expect languages that typically implement server side APIs to be most interested. But the python/Ruby/go people I guess aren’t that into it
Ladies, Gentlemen and all non binaries, current vm runtimes have 32 bit adressing and therefore you can have at most 4gb memory for your webasm application. I think it should be top priority to make it 64bit
That would imply they weren't _already_ trying.