back

by locknitpicker·2mo ago·view on hn ↗
> Maybe just me, but doesn't most C++ code being written today not use inheritance very much, and so make virtual dispatch moot

Most C++ code being written today is the same code that has been here for years. What compels you to believe things are rewritten on the spot? I mean, I personally know of flagship C++ projects that are still stuck in C++14 and earlier. Why would this change?

Perhaps people should pay attention to the fact that C++ goes way out of its way to be backwards compatible.

2 comments
The flagships are the laggards usually! They are large, complex projects with lots of ongoing maintenance and commitments. "Upgrading to the new compiler" is seen as tech debt payback... there are deadlines, new features, and more important things to implement!
Upgrading a compiler in production code is always a major task. It often involves introducing breaking changes in dependencies, some of which are far from trivial to fix.

If you tell a Product Manager that you want to upgrade a compiler just because, and all it will take is a month or two of work including full regression tests on all target platforms and collaboration from all teams, that isn't an easy sell.

Well, back when I wrote C++ for a living I tried to keep up with better practices and newish, more compact and sensible language features. So some code I might have written in the 1990s would almost always have overused inheritance, while when adding a feature in the 2010s, I would have minimised such use. I would expect most C++ devs to do something similar today.
> Well, back when I wrote C++ for a living I tried to keep up with better practices and newish, more compact and sensible language features.

That's fine, but definitely something that does not happen in professional settings. You simply don't look at a codebase with a few million LoC and decide on a whim that you are going on to, say, replace all raw pointers with smart pointers. That is not going to happen. That definitely did not happen at all.

May I remind you that Google's C++ coding guidelines discourage exceptions because they do not have the resources to refactor all their code to be exception safe? Google doesn't have the man power but you do?

Not particularly relevant here, but may I point out that Google's C++ guidelines are generally seen as bad, and really only applicable to someone at Google scale, which you are almost certainly not.
> Not particularly relevant here, but may I point out that Google's C++ guidelines are generally seen as bad (...)

I don't have a dog in the race, but this is the first time I ever heard anyone express this opinion. Google's C++ guidelines are the first thing that critics cite when complaining about exceptions, and they do so as an example and not as something "bad".

They also have nothing to do with scale, really. That's a puzzling statement. I have no idea what compels you to make that claim.