|
|
|
|
|
by deathanatos
12 days ago
|
|
> Don't fall for the illusion that manual memory is the pinnacle of control. Manual memory management is not the only alternative to GC; RAII & smart pointers require, for the overwhelming majority of uses, no more thought than C#'s `new Foo` does, and don't require the concerns about manually free, use-afte-free, etc. that come with "manual memory". |
|
Especially in multi-threaded settings, smart pointers perform poorly (compared to GC) due to requiring atomics on hot paths, and the alternative (epochs, hazard pointers, RCU) is orders of magnitude more complicated to get exactly right than just using GC.
This also explains why historically the most interesting concurrent data structures were first implemented in Java, not C++.
eg. Java got a decent concurrent hash table WAY before anything else - in 2003 vs. the 2006 initial release of Intel TBB, and the performance was not as good for all use cases. C++ performance did not catch up until ~2017 with the release of folly::ConcurrentHashMap!