3 ms·
Writing C++ code than can outperform GC memory management is practically idiomatic at this point. It is muscle memory for people that do it for a living. There
by jandrewrogers 4y ago
Writing C++ code than can outperform GC memory management is practically idiomatic at this point. It is muscle memory for people that do it for a living. There is nothing a GC can do that cannot be done as well or better in modern C++.
The real disadvantage of a GC is that it makes schedule-based optimizations difficult-to-impossible, which are a major optimization class in modern systems code. Even if it performed identically to manual memory management (which it doesn’t), the loss of scheduling control would adversely impact performance of codes that make heavy use of scheduled-based optimizations e.g. modern database kernels.
- pjmlp 4y agoGood luck implementing lock free algorithms without the help a GC (of any form).
- CyberDildonics 4y agoThis is done all the time, I don't know where people get the idea that a GC is some sort of magic that enables lock free algorithms. There are tons of modern C++ lock free algorithms out there.
- pjmlp 4y agoThe magic is called productivity and helping hand. There are also lock free algorithms written in Assembly, that doesn't mean the authors had any fun writing them. Unfortunately Modern C++ is mostly found in conference talks. Most the real life code looks quite Orthodox C++ to me, including from big name ISO members on their SDKs.
- jandrewrogers 4y ago> Unfortunately Modern C++ is mostly found in conference talks. I would suggest that you might be projecting your experience on the rest of the industry. I’ve seen nothing but modern C++ at several companies for the last decade. I haven’t seen legacy C++ anywhere in a really long time, thankfully. I occasionally see very early C++11, which is definitionally modern though dated by modern standards. Baselines tend toward C++17 these days on average.
- pjmlp 4y agoI suggest the same, unless your industry experience for some strange reason is more representative than mine.
- CyberDildonics 4y agoGood luck implementing lock free algorithms without the help a GC The magic is called productivity that doesn't mean the authors had any fun You went from implying that it can't be done, to saying a GC is about productivity, to saying it's about "fun". The goal posts are all over the place here. Meanwhile, I've done it over and over in C++. The reality is that memory allocation shouldn't be a big part of a fast data structure anyway, let alone a good lock free algorithm, because if you're relying on allocation that much you are hopping around in memory, not to mention leaving a big part of your data structure to a black box. Unfortunately Modern C++ is mostly found in conference talks. Most the real life code looks quite Orthodox C++ to me, including from big name ISO members on their SDKs. I don't know what either of these is supposed to mean. If you want to be explicit, tell me what algorithms need a garbage collector, because this all sounds a lot more like something you want to be true or want other people to agree with than something learned from extensive experience.
- pebal 4y agoThere are pauseless real-time GCs: https://github.com/pebal/sgcl https://github.com/pebal/sgcl