site banner

Tinker Tuesday for November 19, 2024

This thread is for anyone working on personal projects to share their progress, and hold themselves somewhat accountable to a group of peers.

Post your project, your progress from last week, and what you hope to accomplish this week.

If you want to be pinged with a reminder asking about your project, let me know, and I'll harass you each week until you cancel the service

1
Jump in the discussion.

No email address required.

find /usr/include/c++/14/ -type f | xargs grep '= new' still shows me nearly a hundred uses in standard library headers, so "long gone" is a bit of an exaggeration. If libstdc++ authors are still at that point, imagine where your average coworkers are. ;-)

I admit that shared_ptr was nice, and the development of "like auto_ptr, but you can put it in containers" was a godsend. Pointing grep at my own favorite project I still see 6 invocations of new in non-deprecated code, versus about 800 invocations of make_unique.

But I'd still argue that even modern unique_ptr best-practices count as manual management and are thus more annoying than "the programming language will just figure it out". Even if you try to mimic garbage collection behavior with shared_ptr you still have to worry about leaking unreachable cycles of pointers that a garbage collector would have been able to detect. This is all a useful sort of annoying if you write any sort of interactive code where big a garbage collection sweep might drop a frame or add input latency or whatever, and even garbage collected code can leak memory because "I forgot to remove a reference" isn't a drastically different bug from "I forgot to delete an allocation", but heap management is still the thing I notice the most complaints about when users of other languages first move to C++.