C++ Logo

std-proposals

Advanced search

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

From: David Brown <david_at_[hidden]>
Date: Mon, 6 Nov 2023 10:15:28 +0100
On 05/11/2023 16:01, Jason McKesson via Std-Proposals wrote:
> On Sun, Nov 5, 2023 at 8:48 AM Yexuan Xiao via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>>
>> It is possible to vote on whether to mark a feature as discouraged.
>> C++ didn't invent nullptr to coexist with NULL. If users continue
>> to use old algorithms instead of constrained algorithms year after
>> year, why is the standards committee working on this? linter is
>> also part of the c++ ecosystem, and the committee should respond.
>> C++ has long been plagued by security problems, print is a safe
>> alternative to printf, and continuing to use printf is hastening
>> the death of C++.
> > If C++ is dying, it's not because people keep using `printf` and
> `NULL`. These kinds of things are not going to make the language
> more popular. It won't make the language more attractive to the
> people who aren't currently using it.

One of the reasons C++ is popular is because, for the most part, old C++
code written to older standards can be used along with new C++ written
to newer standards. This is not true to the same extent as it is for C
(which is much more conservative in that respect, and where backwards
compatibility is even more important). Some other programming languages
have a much greater tendency to break old code in order to introduce new
features - this gets extremely annoying and costly over time.

So I agree that the use of "printf" and "NULL" will not "hasten the
death of C++" - rather the opposite. If it becomes too inconvenient to
re-use existing C++ code, that would encourage people to look to
different languages.

>
> All it's going to do is make the language harder to write code that
> can interface with C.
>
> `nullptr` was added because C++, and *specifically* C++, had
> legitimate problems with `NULL`. It messed with overload resolution
> in really unpleasant and unexpected ways. C doesn't have overloading,
> so that wasn't a problem for them. `std::print` was added because it
> is better than `std::printf`, but that doesn't make it *wrong* to
> use `printf`.

Note that "nullptr" has been added to C in C23. But that is, I think,
more for compatibility with C++ and because it is nice and clear in code
(without the "shouting" of an all-caps macro), rather than because it is
needed in the language in the way that it was needed in C++.

Received on 2023-11-06 09:15:40