4 ms·
Huh? > Rust: "It sounds like it's a great language — for certain things. Uncontroversial > Rust really improves on C++ in one particular area — it makes it m
by iudqnolq 5y ago
Huh?
> Rust: "It sounds like it's a great language — for certain things.
Uncontroversial
> Rust really improves on C++ in one particular area — it makes it much harder to bypass the checks in the compiler.
Yep. You can bypass anything with sufficient raw pointers and unsafe, but there's no way to say "let me write normal Rust but ignore that annoying borrow checker stuff".
> And of course it solves the memory allocation problem in a near perfect way...
Many people describe the borrow checker like this
> if you wrote the same thing in C++, you could not be as sure, as compared to Rust, that you've gotten all your memory allocation and memory management stuff right.
As he says, Rust provides greater certainty you've gotten memory management right. Maybe you object to the idea it's only a matter of degree? All Rust programs I've heard of ultimately involve some unsafe, at least in a dependency. Memory safety bugs have been found in well-tested components like the stdlib, and formally proving memory safety of unsafe Rust code is still a work in progress.
> So Rust is an interesting language."
- ncmncm 5y agoThis: >> if you wrote the same thing in C++, you could not be as sure, as compared to Rust, that you've gotten all your memory allocation and memory management stuff right. Memory allocation and management are exactly the same in C++ and Rust. Both allocate from a heap or the stack, as needed, and return memory to the heap or pop it off the stack at end of lifetime. For heap allocations, both have single-owner pointers and reference-counted pointers, and memory is freed when the last such pointer's lifetime ends. There are differences, but they are not where he says. C++ uses a library type, std::unique_ptr, where Rust uses a built-in type, for single-owner; both use library types for reference counting. Rust has versions with atomic and non-atomic counters. But those are implementation details. All of the semantically-significant differences are around copies of pointers, their lifetimes, and when they are and are not allowed. The memory itself, and its allocation, are not party to that process. So, downvote me to oblivion if you like, he got it wrong where it counts.
- iudqnolq 5y agoI see. From your phrasing I thought you meant what he said was conventionally known to be false. > He used the same words people use, but assembled them in a way that diverges from reality. I disagree with "Rust is C++ with different names", but I'm not interested in having that argument. I think we can both agree that it's not conventionally seen as obvious though.
- ncmncm 5y agoNobody says it is obvious. It is specifically because it is not obvious that it is important to not get it wrong in prominent places such as quotes from Guido. Or to downvote and lambaste people calling attention to getting it wrong.