Rust bandwagon
Rust bandwagon
Posted Jan 9, 2023 22:50 UTC (Mon) by NYKevin (subscriber, #129325)In reply to: Rust bandwagon by khim
Parent article: Welcome to 2023
[1]: All of the bugs documented in https://youtu.be/9xE2otZ-9os?t=189 are the result of reusing statically-allocated memory. In fairness, this technique is technically equivalent to using a fixed-size (block) allocator with a very small heap. But then you can describe almost any use of non-stack memory as "technically" some kind of dynamic allocation.
Posted Jan 9, 2023 23:38 UTC (Mon)
by khim (subscriber, #9252)
[Link] (4 responses)
Well… affine types (which Rust and now Ada are using to solve handling of dynamic memory issues) were, initially, invented by mathematicians and adopted by GC-based functional languages. Not to manage memory, but to manage external resources (in that case “they would be freed but we have no idea when, precisely” is bad answer). Rust discovery (as with TMP it was discovered, not designed into the language from beginning) was surprising and somewhat startling and it's not even mathematical fact, but a social one: if you give people an easy-to-use affine type system then they can solve almost all practical memory handling problems without GC, just with a small amount of It's still not clear whether you can rewrite piecemeal any old code with similar results (which is what Linux Rust project is, essentially, trying to do) or whether you have to design everything from scratch for that phenomenon to work, but the whole thing wasn't pre-planned when Rust was first imagined. But yes, heap is definitely not the only resource which you need to manage… just, probably, the most important one. And it's scary how many really profound, important results are not designed, but discovered when people design something entirely different… are there similarly simple things which could have changed our computing (or maybe more than just computing) world as profoundly and which were just simply not discovered in time?
Posted Jan 10, 2023 12:12 UTC (Tue)
by kleptog (subscriber, #1183)
[Link] (3 responses)
The thing I found most amazing was its impact on some junior developers. They'd start with C and pointers and get themselves tangled into knots keeping the ownership/concurrency/etc straight. But after using Rust for a while they'd internalised the model such that after that coding C became much less scary because they had a model that they knew that worked, and all C needed was some boilerplate that the Rust compiler handles for you (i.e. working without guardrails).
The resulting programs became better simply because they understood the ownership of the objects they're manipulating, rather than just throwing pointers around. Some of us had to learn that the hard way using debuggers on segfaulting programs.
Posted Jan 10, 2023 17:08 UTC (Tue)
by farnz (subscriber, #17727)
[Link] (2 responses)
One thing I've seen time and time again with junior developers is that they've not yet internalised the rules of programming (in any language, not even the one they're working in), and are reliant on the computer telling them that they've made a mistake. Having this happen at compile time is better, but even a runtime exception (like in Java or C#) is an enormous help, since it means you get feedback that you've written something illegal.
In this context, C's thing of "if it's UB, the computer can silently do the wrong thing" is really bad for a developer's education, since the computer will often appear to work even though the developer has done the wrong thing (buffer overflow, use-after-free). Rust's move to "in order to even have UB, you need the unsafe keyword" means that junior developers know to stay away from potential UB, and thus avoid the C problem, since it's obvious to them that they're potentially making a mistake.
Posted Jan 10, 2023 19:36 UTC (Tue)
by khim (subscriber, #9252)
[Link] (1 responses)
This complicates life with junior developers, but they are not the most problematic case. Look on that whole discussion. Wol is most definitely is not a junior. It's not easy to educate junior developers, but it's almost impossible to educate senior ones… because often they firmly believe they know in this or that undefined language construct does. Even if documentation says something else.
Posted Jan 10, 2023 19:46 UTC (Tue)
by Wol (subscriber, #4433)
[Link]
(Not helped because C is not my language of choice.)
Cheers,
Rust bandwagon
unsafe
code.Rust bandwagon
Rust bandwagon
Rust bandwagon
Rust bandwagon
Wol