| > If you are doing manual memory management in modern C++, you are doing it wrong in most cases. You are still creating objects, be they heap or stack based. You are still choosing data structures and designing systems that will have an impact on object lifetime. You are still worrying about taking references during captures of objects, and making sure it is the right type of reference, and that the object does eventually get released. Bonus points if this happens across threads (and with today's async programming models, it will happen across threads!) And memory is still being fragmented, especially if the data model is complex. In a GC language, that fragmentation goes away. Worrying about when an object is out of scope goes away. Capture as often as you want, toss objects between threads, no worries, it will get cleaned up eventually. There are pitfalls to avoid, accidentally keeping a reference around will leak memory, but that it true in C++ as well. GCs solve most of the issues. Modern C++ makes it better, but there is still a quantifiable ease of use difference between modern C++ and a GC'd language. |
As you do in any language.
> You are still worrying about taking references during captures of objects, and making sure it is the right type of reference, and that the object does eventually get released. Bonus points if this happens across threads (and with today's async programming models, it will happen across threads!)
In the case of modern C++, Swift, even ObjC–by “you”, you mean the runtime? Following relatively simple rules does not create a huge cognitive burden on developers, I think.
> And memory is still being fragmented, especially if the data model is complex.
Agreed, but then, we are speaking here of desktop-class applications, and fragmentation issues should be very rare in this day and age.
> In a GC language, that fragmentation goes away. Worrying about when an object is out of scope goes away. Capture as often as you want, toss objects between threads, no worries, it will get cleaned up eventually. There are pitfalls to avoid, accidentally keeping a reference around will leak memory, but that it true in C++ as well. GCs solve most of the issues.
Modern C++ makes it better, but there is still a quantifiable ease of use difference between modern C++ and a GC'd language.
There is also a quantifiable performance penalty to GC’d languages and defragmentation. And GC introduces a class of issues that are so subtle, only experienced developers with experience are able to properly debug or even know about.