C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Keeping C++ Young: Migrating to Modern C++

From: Matthew Taylor <mjtaylor214_at_[hidden]>
Date: Mon, 6 Nov 2023 00:01:29 +0000
I can certainly appreciate the frustration which comes from shiny new language and library features being ignored by developers who are set in their ways; but I can only imagine that if this feature were adopted, all we'd hear are questions about how to turn it off. I'm not sure the target audience for this proposal would be sufficiently motivated by compiler warnings to set out and learn the modern C++ stylings that they are missing, compared to seeking a way to simply have the warnings go away. Indeed I struggle to see the distinction between considering something so harmful we should actively encourage against it, and marking it as deprecated with the intent to remove it from the language. There is a lot of perfectly safe, perfectly valid code out there in the world which uses some of the constructs you recommend discouraging. Perhaps if it were written fresh today it would use different tools for the job, but it is nonetheless perfectly valid code. Why should it, overnight, become code which generates a hundred compiler warnings for using constructs which WG21 does not intend to remove and which are no less valid than they were before? Just think how many programs out in the world use pre-C++20 unconstrained algorithms - while I agree that in many cases the constrained versions are preferable when writing new code today, it's a little unrealistic to expect all the legacy code out there in the world to be rewritten to use them.

Plus, as has been pointed out, many tools which are actively discouraged in modern C++ still see valid uses. There is a lot of nuance to apply situationally which an attribute with a potentially mandatory warning cannot do. A lot of the old C-style functionality is discouraged in modern C++ programs, but if you're making something which can talk to C then you will often have to use them. Dijkstra wasn't wrong when he said that goto is considered harmful, but there are still some specific situations where it is the best tool for the job. An attribute which issues a potentially mandatory warning is taking a sledgehammer to the problem, a tool like a linter with the capacity for slightly deeper code analysis is a better tool to watch a user's style.

Received on 2023-11-06 00:01:32