4 ms·
Surely anything you do with a GC you can do in a language with no GC?
by heavenlyblue 4y ago
Surely anything you do with a GC you can do in a language with no GC?
- deleted 4y ago[deleted]
- amelius 4y agoNo, because if you have to spend e.g. 80% of your lifetime building the application, and having no GC would require you to spend an additional 30% of your lifetime on memory management, then tough luck.
- jjnoakes 4y agoAren't you assuming that you need to spend substantially more time on memory management without a GC? I don't find that to be the case personally.
- adgjlsfhk1 4y agoNo. Writing a good GC is a really big project (i.e. it takes a team of smart people multiple years).
- jjnoakes 4y agoSorry, did you reply to the right comment? We are talking about writing code that uses a GC vs doesn't use a GC, not about writing a GC.
- jandrewrogers 4y agoWriting 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.
- wvenable 4y agoYou can implement the same sort of algorithm as described here but then you've just re-implemented garbage collection.
- deepsun 4y agoSure, and even more, you can do even better with assembler or machine codes.