Enjoy a sample of AOSP source code, https://android.googlesource.com/platform/art/+/refs/heads/m...
Enjoy a sample of AOSP source code, https://android.googlesource.com/platform/art/+/refs/heads/m...
In fact, if we focus on traditional enterprise shops they are stuck in what I call the C+ mindset.
Those of us that bother to live in HN, Reddit, attend CppCon, C++Now, C++ on Sea, ACCU in whatever form, are 3lit3. A tiny minority that actually cares about quality.
That is the point.
In fact, see Python 2 vs 3 for probably the most impactful case of people being slow to take up new language versions/features.
There's going to be shops writing C89. Some reasons might be well founded, some reasons might be less well founded.
Lasted surveys, which are anyway only answered by people that are active enough to care about stuff outside job, places use of tooling to validate modern practices at about 20%.
Now do some statistical extrapolation and it is relatively easy to find out how much "modern C++" is actually used in practice.
Bjarne hasn't dedicated two CppCon to the subject to improve adoption of better C++ practices just by accident.
So in result, just by the means of statistics, all code is necessarily crap. (Besides the extremely seldom pearls written by some independent geniuses).
Frankly this is unavoidable on an industrial scale of production, I guess. At least as long as we can't clone "10 x programmers".
What am I looking for? Is it just the use of smart pointers?
Personally I wouldn't like to slog through this on a moment's notice but it seems named well and there are a lot of comments, and appears to have been through clang-tidy.
You posted this for a reason .. would be good to get your thoughts.
edit: adding one more point. I went to a fairly high-ranked university(top-20). We would get graded based on how clear our code was, comments (both for functions and inline comments). This code would get a zero on those metrics.
https://android.googlesource.com/platform/art/+/refs/heads/m...
like, just this, basically C:
if (strncmp(argv[arg_idx], "-XXlib:", strlen("-XXlib:")) == 0) {
...
is just so complicated and error-prone over if(std::string_view{argv[arg_idx]}.starts_with("-XXlib:"))
...
(which I guess is the intent)The code it replaces also had a strlen in it.
(not OP). I examine the output if someone tells me it's slower, or if I care about performance. I did a very rough benchmark which says in this case they're equivalent [0], however that's not necessarily representative of the places it's called in. There's definitely a compile time overhead though [1]. On my current project there's ~20k files. On an 8 core machine (as an example), adding 150ms per file would add 7 minutes onto a clean build (before optimising the builds).
[0] https://quick-bench.com/q/LBarCDIigwpmXcwZSx-RgV2x4_4 [1] https://build-bench.com/b/OH8qf9AgEB_l-BhANV5qP_uSCys
So you either validate it actually takes place or believe in fairy tales.
So, the example is of bad old code, at a place that enforces bad coding practice. The intent appears to be to suggest this is typical practice, which is not supported.
If this what a company with deep roots in C++ world is doing, what are the large majority of "dark matter" software factories doing, specially the sweetshop ones.
There are shops where people still write new C++ like it's 2011, or 2003, or 1998, or 1992, or C. There are plenty of shops where people code the best way their current production compiler allows. There are plenty where different people do some of each of those. Vanishingly few shops make an effort to rewrite ancient code according to current best practice.
I guess a sweetshop company is one with Oompa-loompas.
I guess I need to catch up with some Twilight Zone episodes.
Looks just like regular PHP. So what's the point? Or did I miss something?
/s