Rust Is Surging Ahead in WebAssembly (For Now)
thenewstack.io
thenewstack.io
Why is it that you need to know something to read about that, but you only need to be able to form senteces to write about it?
EDIT: [1] This is of course contrasted by the elegance of Rust's "Hello world".
> The reasons are many, including significantly greater language support both historically and now, a better fit for computations inside WebAssembly modules, exceptionally lightweight and speedy for LLM (large language model), and other superlatives.
Why is Rust (a general purpose programming language) exceptionally suited for LLMs (which typically run on a GPU)? What major LLM projects even use Rust? Definitely not llama.cpp or ollama. They just had to slide in that buzzword.
It's not a genre that calls for nuance or even a little bit of understanding, you just need to make sure you use the right keywords to rank well for the query you're targeting.
C++ benefits a little in that you can almost just use C++ as C, and I think part of the reason I struggled less with C++ when I used to play with it was that I didn't do the weird stuff. That's not to say that C++ complexity doesn't matter, but it might make the language more accessible to some people because they don't need to learn the weird stuff until they start looking at other people's code or using tutorials? I'm not sure I ever completely fully learned C++ as much as I learned C and the handful of C++ features that fixed some of the things that bothered me in C.
And with Rust there are concepts that (to me) feel harder to avoid. Rust (from what I've used) seems to be overall a much more elegant language than C++, but it feels like more of its complexity is front-loaded and that you run into difficult patterns that test your knowledge more quickly. That might just be my impression though, I'm tackling the two languages at different times of my life and I'm doing different things with them.
I've also been approaching it in a fairly unstructured way, and I know that some people recommend just sitting down and reading through the Rust book cover to cover. Which to be fair, is probably a faster way to learn it than just trying to build stuff with it and then learning new concepts as they're needed and when I run into errors and problems. My (again, very early) impression of Rust is that it feels more purposefully designed than a lot of other languages I've used, but I have a harder time intuiting what the purpose of everything is and a lot of the systems interlock with each other that seems to make them a bit harder to tackle one at a time -- so I suspect it benefits more from guided learning.
That’s exactly it. C++ will let you do things that are 100% wrong, or worse, occasionally wrong, and you have to “just know” how to do them right. Rust will absolutely refuse to compile until you’ve used the correct concept to solve the problem.
It doesn’t eliminate pure logic bugs, but it can vastly reduce the set of possible inputs and code paths to include a subset of possible failure modes you’d find in C++ code. Which would only be enforced by discipline or code reviews, and forces everyone to be consciously anal-retentive to avoid introducing subtle errors in the codebase.
In addition, a lot of C++’s additions have been more type-safe constructs to partially accomplish some of the safety in Rust, but it doesn’t have a way to drop additions. As a result, the “bad practice” solutions are the ones that got there first and are easiest to reach for, and the best practice solutions have more complex syntax.
For whatever reason, new C++ additions also seem to often be half-baked because support isn’t added to other parts of the STL that they interact with, even if it’s painfully obvious you would absolutely want to reach for those tools. For instance, the limited types supported by std::to_string, or hash tables not supporting tuples for multiple editions (haven’t checked C++23).
So yeah, if you stick to or start out with C++03, single-threaded programming, small codebase, it seems simpler. But once you start scaling the complexity of the code or the size of the codebase, or digging deeper into the language (I haven’t even mentioned template metaprogramming), you keep on encountering more and more complexity.
Whereas with Rust, if you’re writing it idiomatically anyway, the difficulty tends to plateau as (1) the language is in the background minimizing side effects and enforcing cross-module constraints so the volume of code you have to “just know” to safely work on something doesn’t scale with the codebase (2) your initial learning only consists of the modern best practices constructs, and after that additional learning tends to be more bite-sized.
When you factor in C++’s still-chaotic DIY buildscript, packaging, linting, formatting situation, the level of cognitive overhead for the parts of a practical C++ project that you actively have to manage tends to be far, far greater than Rust.
And some teams just throw up their hands and decide they aren’t even going to try to keep pace, and just negotiate some arbitrary point in the past they’re going to keep the codebase.
So the editorial comparisons between the safety of bleeding-edge modern C++ and Rust aren’t even really practically relevant, because a lot of teams fall off from how user-unfriendly C++ tooling and later editions wind up being.
https://rustwasm.github.io/docs/book/reference/debugging.htm...
Web-Assembly not returning cleared memory is an issue, but not a dealbreaker:
https://webassembly.github.io/spec/core/syntax/instructions....
I have no problem with being unable to use debugger in WebAssembly, my primary approach to debugging is observable outputs from the system:
* Return value
* Logs
* Side effects
* Integration tests, unit tests
It's an amazing tech but it's stagnating, it's quite sad.
The DOM is kind of great for modeling documents, and quickly creating a form. As far as event driven design goes, it's very performant and accessible. But if you want to do anything that isn't vector graphics or form design, the entire browser stack can hold you back in varying ways.
Personally, I'm seeing a lot of potential in the wasm vector libraries, but I'm even more excited about shader-based, immediate mode guis. And honestly, the fact that you don't need a browser is a bonus, but definitely not the main selling point.
Your milage may vary, of course, but I'm very optimistic about what's coming with wasm!
Being able to access DOM is definitely an objective. It's just taking a lot longer than folks guessed to build a modular wasm ABI.
https://web.dev/articles/ps-on-the-web
Rust is slowly getting there but there isn't much to port over to the web that's written in Rust, and when you want to start your project by being web first, then there are much better solutions