5 ms·
No, it’s not just theory. Like anything in C++, codebases and their styles widely vary. But my comment holds true for the vast majority of developers I have wor
by jb1991 4y ago
No, it’s not just theory. Like anything in C++, codebases and their styles widely vary. But my comment holds true for the vast majority of developers I have worked with over the last decade. With the exception of the special “placement new“ operator, it is nearly obsolete to use new and delete.
- pjmlp 4y agoI suggest browsing around code from Microsoft, Google, Apple,... 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.
- jb1991 4y agoIf you are going to work with a legacy codebase, then sure. My comment was more about fresh codebases, which are fortunately the only ones I've worked on.
- pjmlp 4y agoA niche in the C++ world.
- kps 4y agoHmm, I was at G until the recent decimation, and would have been surprised to see `new`, especially in new (heh) code, because it immediately raises the question of ownership, which means it costs time for every future reader. 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%20case:yes%20-file:third_party%2F%20-file:%2Fgen%2F%20-file:test.*%20-comment:new&sq=&ss=chromium%2Fchromium%2Fsrc https://source.chromium.org/search?q=\bnew\b%20lang:c%2B%2B%... https://source.chromium.org/search?q=\bmake_unique\b%20lang:c%2B%2B%20case:yes%20-file:third_party%2F%20-file:%2Fgen%2F%20-file:test.*%20-comment:new&sq=&ss=chromium%2Fchromium%2Fsrc https://source.chromium.org/search?q=\bmake_unique\b%20lang:...
- pjmlp 4y agoNow search for C arrays and strings, old style enums, str...() and mem...() functions, C style casts, preprocessor macros,..
- jb1991 4y agoThat’s called whataboutism.
- pjmlp 4y agoNope, it is called experience with large code and teams.
- jb1991 4y agoWe are talking about one very specific issue, the point of this thread is a joke about new and delete. And your response after evidence services against your position is, “what about all these other things?” Definition of whataboutism.
- pjmlp 4y agoNope, the whole issue is about modern C++ in practice versus slideware at conferences. Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it. Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.