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).
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).