3 ms·
The point about Rust is to avoid any extra runtime cost by statically enforcing a set of rules (borrow checking) on reference use that are sufficient to guarant
by corank 1y ago
The point about Rust is to avoid any extra runtime cost by statically enforcing a set of rules (borrow checking) on reference use that are sufficient to guarantee memory safety. It also has ARC but it's reserved only for cases where those rules are too restrictive.
- steveklabnik 1y agoThe thing is, Swift has automatic reference counting, and Rust has an atomic reference counted type. Their “ARC”s are related but different.
- corank 1y agoI was actually talking about automatic reference counting. I think both Rc and Arc count as automatic reference counting? It's just that the term (which was apparently coined by Apple?) is not commonly used outside Apple's languages. I'm not familiar with Swift though so my understanding could be incorrect.
- steveklabnik 1y agoYou're a little off. To put it in Rust terms, the "automatic" means that Swift will insert the equivalent of calls to ".clone()" for you, whereas this is manual in Rust.
- corank 1y agoI see. My understanding is that Rust doesn't have _automatic_ reference counting as in Swift only because it has an alternative (move), which requires the programmer to specify their intent. The principle is nevertheless the same: ensure every time a reference is copied the ref count is incremented, free only when ref count is zero, and we get temporal memory safety.
- steveklabnik 1y agoIt is true that the idea is memory safety in both cases, absolutely.