The borrow checker is a feature of Rust’s compiler which places strict constraints on ownership of data to guarantee memory safety. It adds a lot of friction to writing Rust code if you’re not experienced with the language (or sometimes even if you are). OP refers to the “language restriction of Rust”, seemingly talking about the borrow checker, but has never even heard of it. It’s kind of like someone claiming they didn’t vibecoded their C++ project but having no idea what the STL is.
Yes, the end goal is very similar to a garbage collector. Both are advanced systems of memory management.
The most important difference being that a garbage collector runs at runtime, while the borrow checker at compile time. Which means that the borrow checker has 0 impact on the program’s performance. It just takes longer to compile the program.
Which also means that, while the garbage collector says “you can do whatever you want with memory, don’t worry about it, I’ll handle it for you”. The borrow checker says “you fucking donkey. Why did you do that? I won’t compile this if you don’t fix it”.
So you trade programmer comfort for performance (end user comfort).
The borrow checker is a feature of Rust’s compiler which places strict constraints on ownership of data to guarantee memory safety. It adds a lot of friction to writing Rust code if you’re not experienced with the language (or sometimes even if you are). OP refers to the “language restriction of Rust”, seemingly talking about the borrow checker, but has never even heard of it. It’s kind of like someone claiming they didn’t vibecoded their C++ project but having no idea what the STL is.
Sounds like java garbage collector but backwards… perhaps I will understand it better if I ever try Rust.
Thank you for explanation, YaBoyMax
Yes, the end goal is very similar to a garbage collector. Both are advanced systems of memory management.
The most important difference being that a garbage collector runs at runtime, while the borrow checker at compile time. Which means that the borrow checker has 0 impact on the program’s performance. It just takes longer to compile the program.
Which also means that, while the garbage collector says “you can do whatever you want with memory, don’t worry about it, I’ll handle it for you”. The borrow checker says “you fucking donkey. Why did you do that? I won’t compile this if you don’t fix it”.
So you trade programmer comfort for performance (end user comfort).