The "Pit of success" and "Pit of failure" aren't really about what's available in a language, it's about what's easy and natural.
I'd argue that in a language with the `new` keyword, nothing is more easy or natural than invoking it. `auto Foo = std::make_unique<Foo>(args);` is absolutely the right thing to do, but would you really be surprised to find `auto foo = new Foo(args);`?
I absolutely agree unique pointers are the right call. They just aren't necessarily the easy or natural call.
The contrast is rust where all ptrs are, by default, unique ptr and the compiler validates that for you.
I've thought before about making a "dialect" of C++ that doesn't add any new fundamental capabilities, but simply changes syntax to make the more modern options easy and natural and make old C features verbose and difficult. For example, using "*" to represent unique_ptr and std::legacy_c_ptr<...> to represent "bare" pointers. Ideally, such a dialect could be fully include-compatible with all existing C++ code (although macros could be difficult), similar to how Rust "editions" or go "language versions" work. If C++ compilers offered a "#pragma modern_defaults" would people be interested in using it?
Actually in C++ the vast majority of the time, the right thing to do is
Foo foo{args};
Which is simpler than the other cases, more correct and more performant. The rare few times dynamic allocation of something that is not an array with new is needed is when you have polymorphic types - but then, the user code generally calls a factory function instead of new.
I'd argue that in a language with the `new` keyword, nothing is more easy or natural than invoking it. `auto Foo = std::make_unique<Foo>(args);` is absolutely the right thing to do, but would you really be surprised to find `auto foo = new Foo(args);`?
I absolutely agree unique pointers are the right call. They just aren't necessarily the easy or natural call.
The contrast is rust where all ptrs are, by default, unique ptr and the compiler validates that for you.