by jb1991 · 3y ago · 0 comments
You haven't programmed til you've come to the realization that billions of dollars worth of man hours are about to go down the toilet because of an assumption made 20 years ago, in a 4th order dependency, that you can't get rid of, and to rewrite is going to cost another couple million dollars, and spent a night with a bottle of whiskey wondering whether it's really all worth it.
Where my maintainers/InfoSec bros at?
I hope you can understand why that's offensive.
Plus there are those tons of enteprise code, hardly the "vast majority".
The only place I see modern C++ as advocated, it at C++ conference talks, and my own hobby coding.
Taking chromium as a proxy (though the style isn't identical), there are currently 5 or 6 times as many `make_unique` as `new`. (Some false positives on the word ‘new’ in strings, because I don't remember how to exclude them.)
https://source.chromium.org/search?q=\bnew\b%20lang:c%2B%2B%...
https://source.chromium.org/search?q=\bmake_unique\b%20lang:...
If I was writing for example libraries of custom high performance containers the situation would have been different but still highly localized. And it is sort of very specialized type of development anyways.
What? How do you (de)allocate memory without new and delete?
If the answer is "smart pointers" then why bother use C++ in the first place, just use Go or something.
It's fairly simple:
instead of new --> make_unique(); this returns a pointer, but it will automatically delete its memory when it goes out of scope.
instead of delete --> do nothing; the memory is deleted when you don't need it any more.
There are additional API methods on the unique pointer that allow you to do other things for flexibility, but while continuing that memory safety.
This is nothing at all like a GC language like Go.