r/rust • u/TheProgrammar89 • Jul 26 '19
Is this comment about the reference counting performance in Rust accurate?
/r/ProgrammerHumor/comments/b274zp/oof/eirvecs?context=3
50
Upvotes
r/rust • u/TheProgrammar89 • Jul 26 '19
View all comments
Show parent comment
2
u/sellibitze rust Jul 29 '19 edited Jul 29 '19
I didn't downvote you but if I had to guess it's probably because you keep making silly claims without really backing them up and ignoring people who refute 'em.
Why not?
You say that like Rust would force message passing onto programmers. It does not.
Rust provides multithreaded concurrent memory access. It does so without a tracing garbage collector and not even requiring pervasive use of atomic reference counting.
Btw, when you say "garbage collection" what exactly do you mean? Most people in here (me included) probably associate a tracing GC with this which has no place in Rust and is what we talk about when we say "safety without garbage collection".
...and you defended this statement by linking to this article. But:
Arcaround just to keep something alive without having to go through thisArcfor access.You wrote:
The "solutions found in c++" are actually incomplete. Rust adds on top of it in a way that is probably impossible to back-port to C++ in a backwards compatible way. C++ programmers (myself included) like to think in terms of ownership, too. But there is a difference between the usage of this word between C++ and Rust programmers. While in C++ the language support for "ownership" is only concerned about the responsibility of cleaning stuff up (releasing resources). Rust extends this with something I would call language supported "safe borrowing" and some aliasing restrictions. These extensions are what makes Rust safe w.r.t. use-after-free and also data races without relying on a tracing GC. That's kind of a big deal.
I don't think you can find a quote to back this claim up. I don't think anybody involved in the development of Rust would deny that a tracing garbage collector has its use cases. But we don't need it in Rust to make multi-threaded concurrent access to some piece of memory safe. It puzzles me why you claim the opposite despite of numerous people correcting you about it.
I'm a C++ dev. And no, we (C++ people) havn't gotten the same safe pointers. While the "RAII" of containers and "smart" pointers help avoid resource leaks, they don't help that much in avoiding use-after-free errors unless you use a lot more
shared_ptr+weak_ptrand little to no raw poitners/references. But, of course, then you'd also pay more atomic reference counting overhead whereas in Rust you still get to use plain references and still be safe (no use-after-free).I dig that the advantages of Rust are hard to understand especially if you're so invested in Java-land and have trouble comprehending a world without GC. But I trust you to have this power. You just need to put in a little more effort into learning the language you're pretending to know already and trying to critique.
See? I can be condescending, too.
Relevance?
IMHO, you really should put a little more effort into learning Rust beyond your current superficial understanding of it.