re: aurora::CopiedPtrYep, good arguments.
There's no doubt that having to write some/all of a constructor, destructor, copy constructor, copy assignment operator, move constructor, and move assignment operator gets pretty burdensome. I am highly sympathetic to simplifying this.
I recall reading an article (or maybe it was a video) by Jonathan Blow, who is a pretty popular and influential indie game developer. He discussed the need for a new programming language for games. He has many issues with C++ but these complexities addressed by aurora are one of them. So it's not an insignificant problem. It legitimately pushes some smart people away from C++. Blow is actually
working on a new language for games. That link is off-topic, highly optional reading, but just figured I'd include it for those interested.
Personally, I'd have to be dragged kicking and screaming from C++. But I get people's complaints. I would actually be interested in official C++ tackling this problem, similar to how your aurora stuff does. If it were part of the standard, the "principle of least astonishment" argument (whether you agree with it or not) would completely disappear.
re: C++ RAIII definitely agree that shared pointers have disadvantages and their use cases have to be considered carefully. I've also noted this in my article and mentioned here that I consider it overused. Still, the article you linked is definitely interesting to read, as it outlines some lesser known problems in detail.
Cool. Thanks.
So, it seems like we agree that RAII can greatly simplify and improve code, and abandoning it is primarily reasonable due to problems with concrete implementations, such as std::shared_ptr?
Yep.
This is where I am at. If I liked the concrete implementation, I would try adapting RAII in my code. I can't guarantee I wouldn't find other issues once I got my hands dirty. But I would be sold on giving it a shot.
_____________
Here's the broader picture. There's a series of mental steps a person has to make to go from traditional manual mem management, to adapting RAII.
1. SyntaxIt is very common to dislike the syntax, which I readily admit is a very minor issue. But hey, coders will argue for hours on where to put curly braces. So while I might mention it, I wouldn't pursue it as a serious argument against RAII. But the first reaction is often an "ewww" one.
I'm just talking about the thought process, not trying to make arguments to debate here.
2. Old vs. NewIt's very common to require convincing, by oneself or others, that RAII is actually better, and if so, by how much. Memory management and memory leaks are issues programmers have dealt with for a long time. We've written a lot of software using our old, non-RAII tools and techniques. We are competent with them. We trust them. They have worked well for many of us in the past. Arguments telling us that they don't work just annoy us, because we believe they do. It would be like someone telling you you should use C# because you can't trust programmers to work with memory, with or without RAII (both of which are susceptible to programming errors, although RAII less so).
This is why people will mention things like memory leak detectors. I readily accept that there are reasonable arguments against these older techniques. But obviously, the argument for RAII would be far stronger if these older techniques did not exist. That's why they get brought up. RAII is a replacement to existing techniques. So you must examine both together. It's a debate between the old and the new. Personally, I believe it is wrong to frame the memory management argument as "the wrong way" and "the right way" (and doing so will likely alienate those who require convincing). Rather, I believe it should be framed as the advantages and disadvantages of different tools. Both advantages and disadvantages exist. "Familiarity", "existing, functional code", and "established technique" being some arguments for manual management.
For example, I chose to use CEGUI for my UI library in my current game. There are a lot of other GUI choices. Maybe some of them are even better. I don't know. But I have a huge familiarity with CEGUI. I have a lot of existing code. I have a highly efficient workflow. I just simply know how it works. So it's one less unknown piece of tech, one less big learning curve I have to deal with in my current game.
Maybe some other GUI libs do things a little better, in certain ways. That alone would not be enough for me to change. It would have to be a lot better.
I'm sure one day I will change to something other than C++. Some fancy new language. But when that day comes, it will take a lot of convincing. I'm good with C++. It works. Same kind of thinking.
Again, not trying to make arguments. Discussing thought process.
3. Examining reasons not to adapt RAII.This is where we hit the implementation, and smart pointer issues.
As discussed above, many programmers have to be strongly convinced to abandon tried and true techniques for something new. This is reasonable.
I'm pretty good with my existing techniques. Changing requires me to abandon those. Learn new stuff. Rework my existing code. Likely deal with new kinds of bugs and other issues as I adapt and learn. Take for example the difficulties associated with debugging non-released memory from shared pointers (memory I expect to have been released). That's a different kind of debugging than I've ever had to do before. I'm starting from scratch.
So, if I see definite problems in the implementation of C++ RAII, that may be enough to weaken the "strong convincing" I need to adapt it.
That's why discussing these problems associated with shared_ptr are such an important part of the process. Or, instead, discussing alternatives to shared_ptr that do not have these problems.
This is why I was so interested earlier in talking about shared_ptr alternatives, using a combination of unique_ptr and raw pointers.
That's a big wall of text. But I hope what it achieves is to be more sympathetic to those who either decide not to adapt C++ RAII, or are somewhere along the stages of accepting it, but not quite there yet.
Thanks for the great discussion, Nexus.