placeholder

A comparison of Rust’s borrow checker to the one in C#

OK, so C# doesn’t share the Rust concept of “borrowing,” so it wouldn’t technically be correct to call this “borrow checking,” but in practice when people talk about “Rust’s borrow checker” they’re talking about all of the static analysis Rust does to ensure memory safety, for wh...

Click to view the original at em-tg.github.io

Hasnain says:

“Maybe I’m bad at searching for these things, but these changes to C# seem to have gone completely under the radar in places where you read about memory safety and performance. Maybe it’s just because the language additions have happened super slowly, or maybe the C# and Rust communities have so little overlap that there aren’t enough people who program in both languages to notice the similarities. Maybe there’s something that makes C#’s ref subset so unusable that people just ignore it (I’ll admit to only having played around with it a bit, so far).

Here’s my theory: C# already had an equivalent to all of these things in its “unsafe” subset, so when introduced, ref-safety changes were typically framed as “bringing the performance of safe code closer to that of unsafe code,” which is arguably the opposite perspective of Rust’s “bringing the safety of high-performance code closer to that of high-level languages.” Perhaps that framing makes people miss that although the two languages are pushing in opposite directions, they might actually be getting closer together.”

Posted on 2024-11-10T01:49:07+0000