this post was submitted on 28 Nov 2021
11 points (100.0% liked)
Rust Programming
8306 readers
12 users here now
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
On the garbage collector point: I used to do java professionally, and it made me never want to use any garbage collected language ever again.
I have some nightmare stories... one giant monolithic program was so bad on memory, that after running for a few days, it would take up all the memory of a 24 GB machine, and one of our devs had to manually write a ton of code to garbage collect certain things just to keep the thing alive.
Even small programs in GC languages have that problem: they can never really be smart enough to know which data can be scrapped, and do the safest thing, which is to keep it all in memory. Even a simple java program I wrote a few years ago grows to fill up the memory of the 1gb box I have it on, after it runs for a few weeks.
Rust doesn't have that problem, as it forces you to think about borrowing, stack and heap from the very beginning. When you realize its not that much more work to do so, you can see why go and java will never beat rust on memory performance.
That's a bit generalized you can leak memory in rust e.g. by keeping around old Weak pointers, also std::collections::* don't shrink by themselves.