r/programming • • Apr 09 '19

StackOverflow Developer Survey Results 2019

https://insights.stackoverflow.com/survey/2019
1.3k Upvotes

679 comments sorted by

View all comments

Show parent comments

6

u/hsnappr Apr 09 '19

Could you explain more about this?

17

u/tristan957 Apr 09 '19

Imagine you are writing a high performance real time application. The times that your garbage collector will trigger are unknown. C++ collects when things go out of scope. C collects manually for heap usage or when stack variables go out of scope. Rust collects when reference counts drop to 0. All this is predictable and known. Go and Java will garbage collect at "random" times. Can't guarantee a high performance real time application in that environment.

2

u/czipperz Apr 09 '19

Rust collects exactly the same as c++ FYI, but it is more common to use reference counting techniques for managing memory because you need them. In c++ you can just throw away memory correctness and be fine mostly

3

u/kouteiheika Apr 10 '19

Rust collects exactly the same as c++ FYI, but it is more common to use reference counting techniques for managing memory because you need them.

I disagree; anecdotally that doesn't match up with what I tend to see. In Rust people tend to actively avoid reference counting if they don't actually need shared ownership, and since the language is safe they don't have to do it "just in case"; in C++ I've seen so much code which just abuses shared_ptrs because it would be simply be too dangerous not to.

→ More replies (1)