3 ms·
> Is Rust web yet? Only if you REALLY need it, like if you're embedding a web server into an existing Rust service. Otherwise, it's going to be very time consu
by gwbas1c 6y ago
> Is Rust web yet?
Only if you REALLY need it, like if you're embedding a web server into an existing Rust service. Otherwise, it's going to be very time consuming to do things that are straightforward in other languages.
(TLDR: A Rust++, or "Objective Rust" that simplifies some memory issues could make Rust web ready.)
For the past few months, my occasional hobby has been trying to learn Rust. BUT, I've also spent a considerable amount of time getting up to speed in NodeJS.
Regarding running Rust in the browser with WebAssembly: I've spent DAYS trying to figure out how to hook callbacks into the DOM cleanly. I basically went through the "Game of Life" walkthough, (https://rustwasm.github.io/docs/book/ https://rustwasm.github.io/docs/book/), and then ported all of the JavaScript sides into Rust. Trying to make registering a callback from the DOM as clean as implementing a button click handler in C# is just a nightmare.
The problem is that Rust just isn't good for complicated object graphs. This is where almost any language that's garbage collected, or uses some form of automatic reference counting, shines. And, if you're building a "normal" web application, Rust isn't going to have tangible performance advantage over Java / C# / NodeJS / Python. (Meaning, if you aren't running at Google Scale, there's no tangible performance advantage for Rust.)
Part of what happens in Rust is that it's very hard for a struct to reference itself so it can register event callbacks. You're forced to either make all users of the struct use reference counting, or you have to encapsulate a reference counted type used with callbacks. In a garbage collected language, this kind of hurdle isn't needed. In reference counted languages, registering event handlers just requires a weak reference to yourself to avoid cyclic loops. This is because GC / ARC languages assume the same memory model for all objects; which isn't the case in Rust.
Anyway, to make Rust easier to work with, it needs a way to trade some of the raw, "0-cost-abstraction" advantages for the advantages that come with GC / ARC languages. Need raw performance? Use pure Rust. Just need to get it done? Use a higher-level syntax.