Here sucks is in the sense of suckless philosophy, I don’t think everybody likes the suckless movement but I’ve seen that many people, me included, don’t like how modern web apps look like (messenger and tiktok are like the worst). So if I want to make interactive web apps, what are the better technologies to not make the web shittier ?
Well, part of the problem is that web apps themselves are kind of alien on the web. The web is generally document-based. Web apps take the document format and try to turn it into something it’s not.
There’s a way to not do the JavaScript, but it doesn’t fix things being document-based and it can be argued that it makes other things worse in some respects.
I’m talking about WebAssembly. Basically, you can write your web app in HTML+CSS+Rust and then the Rust part is compiled to WebAssembly, which then takes the role that JavaScript would normally take. It does not have to be Rust, lots of languages can be compiled to WebAssembly, but Rust has the most mature ecosystem for that, as far as I’m aware.
In principle, it is also possible to use WebAssembly to render directly to a pixel buffer, but that’s really rather heavyweight and not terribly responsive, so not generally done, unless you implement a game¹ or similar.
Alright, so back to the document mangling approach. There’s various frameworks available for Rust. I’ve used Leptos so far. There’s also Dioxus and Yew and probably others.
Advantages:
Result
andOption
types for error handling, which you can pass directly to your rendering stack and it can show either the data or the error (or nothing).Disadvantages:
I’ve listed a lot of disadvantages, so just to point out that, yes, to me, the advantages are absolutely worth it. But I can totally understand, if others see that differently.
¹) See, for example, Bevy and this UI example in particular.
Webassemby is still limited to a single thread as far as I’m aware, so it’s not a full runtime for the language you are writing in as anything using threads behind the scenes tends to fall over unexpectedly at runtime.
Its also an absolute bastard to debug (young ecosystem)
Yeah, I doubt WebAssembly when executed in a browser will become multi-threaded anytime soon, since JavaScript is single-threaded just as well. If you need multiple threads, you need to use web workers. Haven’t done anything with those yet, but I’d assume them to be usable from WebAssembly as well, since the whole JavaScript API seems to be accessible.
Well, and in Rust, I’m pretty sure the runtime that’s typically used for async stuff (
tokio
) will produce a compile error, if you try to enable the “multi-thread” feature flag on the WebAssembly target.But yeah, might be more of a problem with other languages.