Originally posted by lowflyer
View Post
A lot of things used in rust are present before but rust group into one PL.
All the references are checked at compile-time and guarantee the reference are always valid and non-null, and these references can be point to anywhere, either heap or stack or global variables.
It also works for struct/enum that contains reference to other fields.
To archive this "ref counting" in C++, you would have to make every field an atomic ref pointer which also requires heap allocation.
Rust also checks for mutability rule to prevent multithreaded modification without synchronization such as mutex/read lock or use of atomic variables while permitting concurrent reading.
Comment