Supporting FOSS projects to transition to memory safe tech
10 points by wofo
10 points by wofo
transition to memory[-]safe tech like Rust
At a high level, this is a generally good idea seeing the amount of security issue being found for a lot of projects… So long as this isn’t prescribing rewrite in Rust (or Go or Python as mentioned) only. There are more options—some even compile to C—which doesn’t throw C & its portability/ABI away.
Kinda curious about your mention of Go here (I know you are quoting). I don't really remember anyone ever touting memory safety as one of Go's strengths. Or have I been living under a rock?
Even more so for Python, that completely confuses me in this context, so again I'm wondering what I missed. Not that I have a real opinion on RIIR, but if you have to rewrite it anyway, Rust feels like a better candidate than Python for most things that are not web apps?
Memory safety is in no way unique to Rust. What makes Rust "special" is memory safety without garbage collection. Any garbage collected language is generally memory safe unless you are bypassing the garbage collector.
What Rust might offer over Go is its stronger guarantees around thread safety.
“special”
But not unique. There are other languages without GC & same (or more depending on your criteria) safety. …Or there are languages that normally have GC but you can opt out for the performance-critical parts. OxCaml, ATS2, MLKit’s Regions, Austral & I think maybe even Swift can fit the criteria—while not even being an exhaustive list.
MLKit’s Regions
That’s an unusual one. The original MLKit region allocator was based on a static lifetime analysis “region inference” that required lifetimes to be strictly nested. Each region corresponded to a stack frame, and all the heap allocations within a region were released when the function returned. (It’s somewhat like RAII but a leaf function can assign an allocation’s cleanup to some caller further up the stack; or you might think of it as a whole-program escape analysis.)
The problem with nested lifetimes is that when a program’s allocations can’t be statically bounded, they get assigned to a pessimistically long-lived region. So you end up with space leak problems. The solution was to run a garbage collector in the long-lifetime regions near the bottom of the stack. https://elsman.com/mlkit/pdf/pldi2002.pdf
I mean sure, but none are as mainstream as Rust unless I am blanking on something obvious. Popularity != quality of course. However it is significantly easier to attract contributors to something like Rust rather more obscure alternatives (which you might, or might not desire depending on the project in question).
If I wanted to be really pedantic I should've specified without any runtime bookkeeping all together to exclude things like Fil-C which does incur a pretty hefty runtime cost if I've understood the technology correctly.
While the borrow checker is obstructive as hell sometimes, at least you can always (barring unsafe code) work in the same mode of thought. Suddenly turning off something as fundamental as the garbage collector is quite the mode switch. I haven't worked in any of those languages so I have no conception of how often you'd need to disable GC to approach GC-less levels of performance. But it would seem to me like that would be way more common than unsafe blocks in Rust. Might be totally off on that front though.