News for hackers. Stuff that matters.
Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by lelanthran on Monday October 30, 2023 @02:02AM (#38066179)
He's right in many ways. They did the best they could at the time under the constraints that they had - try adding type-safety to K&R C while maintaining backwards compatibility with K&R C.

But now the only way forward I see for C++ to maintain its position as a mainstream language is to draw a hard line in the sand and effectively only keep all of the stuff that people refer to when they say "write in Modern C++", and remove everything else.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by AlotOfReading on Monday October 30, 2023 @02:31AM (#38066319)
That's effectively what the profiles proposal is: a set of compiler warnings that error if you use anything outside a limited subset of modern C++.

I don't think it's a very good proposal, personally. For one thing, it effectively amounts to a rewrite of nearly all existing code. For another, the error messages that can be emitted are terrible. Worse, it relies on the compiler to do a lot of heavy lifting that just isn't going to happen in the industries it's needed most for years. It's also opt-in rather than opt-out. Depending on the as-yet(?) unclarified constraints on UB, there may be yet more footguns for those unwise enough to attempt incremental rewrites. Also, because it's C++ there are already a bunch of visual warts like having to continue using gsl::span instead of std::span because of subtly different semantics.

Or you can use a memory safe language and get essentially the same/better guarantees without all the caveats. However, you have to list a different language on future job postings.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by lelanthran on Monday October 30, 2023 @02:46AM (#38066387)
> That's effectively what the profiles proposal is: a set of compiler warnings that error if you use anything outside a limited subset of modern C++.

Subtly different - by "a line in the sand" I meant that anything past this line is New C++ and anything behind the line is Old C++. Your compiler for New C++ wouldn't compile anything that is Old C++, and the Old C++ compiler wouldn't compiler much of New C++.

Two different languages that both have Current C++ as an ancestor.

> I don't think it's a very good proposal, personally. For one thing, it effectively amounts to a rewrite of nearly all existing code.

For making it a set of errors in the Current C++, yes, it's a bad proposal and not what I proposed. Under my proposal, it's not like your Old C++ compiler will suddenly stop existing, or stop being supported, would it? You'll effectively have decades before this is the case.

> Or you can use a memory safe language and get essentially the same/better guarantees without all the caveats. However, you have to list a different language on future job postings.

Yeah. You list either New C++ or Old C++ (or both, if you can).

Like many others, I gave up on C++ a long time ago and stick with C for those projects that I both 1) do solo, AND, 2) need the low-level access and performance.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by pjmlp on Monday October 30, 2023 @03:26AM (#38066571)
As Python 2, Java 8 and .NET Framework have proven, that never works out that painlessly, plenty of people are still stuck on those versions to this day, with no end in sight, regardless how much the modern versions get pushed.

Regarding C, it isn't also not standing still and WG14 is quite clearly turning it into "C++ without classes" kind of language, look forward to more _Generic improvements and upcoming lambdas in C29.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by lelanthran on Monday October 30, 2023 @04:20AM (#38066857)
> As Python 2, Java 8 and .NET Framework have proven, that never works out that painlessly, plenty of people are still stuck on those versions to this day, with no end in sight, regardless how much the modern versions get pushed.

That's sorta my point: it worked out excellently for those languages. Those with legacy code and unable to change still use legacy and the new language gets the benefit of remaining relevant.

The point is not "keep that old shit as relevant for as long as possible", the point is "keep the language relevant", and that means jettisoning all the baggage that C++ has.

> Regarding C, it isn't also not standing still and WG14 is quite clearly turning it into "C++ without classes" kind of language, look forward to more _Generic improvements and upcoming lambdas in C29.

It's not standing still, but the pace and volume of additions is simply nowhere near to what the C++ committee does.

As far as C is concerned, while I feel that they are poor stewards of the language, anyway, the future additions do look helpful.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by pjmlp on Monday October 30, 2023 @06:40AM (#38067746)
It did not work out excellently, as there are now big problems regarding interoperability between old code and new frameworks, while at the same time finding people willing to work on those projects.
Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by Barrin92 on Monday October 30, 2023 @05:08AM (#38067131)
>and remove everything else.

That is not a good idea. Breaking backwards compatibility with a language that large is going to damage the ecosystem. the Python 2 -> 3 transition shows how slow and costly, ironically enough, this can be.

Stroustrup is correct when he says the way forward is evolutionary. In evolution you never cut things, they're always phased out. Vestigial structures stick around. Incremental change is ultimately going to be more successful, causing schisms and splitting the language community is not going to be success.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by lelanthran on Monday October 30, 2023 @05:51AM (#38067414)
> Stroustrup is correct when he says the way forward is evolutionary. In evolution you never cut things, they're always phased out. Vestigial structures stick around.

That hasn't worked in the past for C++. Why would you expect that approach to start working in the future?

I also think that it's a bad idea to have the language's direction set by what the existing (and attritioning) developers want, and not by what it would take to get new devs. A policy like that is almost guaranteed to result in death by attrition.

> Incremental change is ultimately going to be more successful, causing schisms and splitting the language community is not going to be success.

Two things:

1. I think we're defining success differently here. I'm defining it as market-share.[1]

2. You're looking at the way C++ has always done things, which has failed (IMO, anyway) to keep the language mainstream. You're predicting a future where this approach that has failed in the past, will succeed in your predictions.

BTW, I'm not predicting anything; I'm saying that the C++ approach has resulted in a dismal failure for the languages popularity, causing it to lose some ground against every single competitor in that space: Rust, Nim, Zig and more are all eating away at what's left of the C++ developer base after Java and C# took a shark-sized bite from it in the early 00's to late 00's.

All that's left for C++ is gamedev. If we want to avoid that, C++ needs to be more accessible. In order to get to that, it needs to remove anything that can be removed.

[1] Python is an incredible success, having gained marketshare since 3 was released and people started the "slow and costly" migration which only took 10 years for Python 3 to be the most-used language now.

C++, by comparison, has been losing marketshare with each new evolutionary and incremental change that never discards anything.

C++ has been doing what you say is the correct way, and it has been losing its status as a mainstream language with each new standard. Python did it the way you say is incorrect, and is still solid in it's use-case against newer and better languages.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by Barrin92 on Monday October 30, 2023 @06:41AM (#38067750)
>All that's left for C++ is gamedev

Okay we gotta agree on some baseline reality. C++ is everywhere. Google and Facebook probably work on more active C++ code than there is Rust, Nim and Zig code multiplied by 100 in the entire world. Most machines, web browsers, airplanes, routers, databases, all machine learning libraries, toasters and tanks run on C++. There's about 30x more open C++ jobs than for all other system languages combined.

>C++, by comparison, has been losing marketshare

That's not true either. As flawed as I personally find these indices, C++ has been, quite rapidly , gaining marketshare over the last few years.

https://www.infoworld.com/article/3684848/c-plus-plus-wins-p...

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by kibwen on Wednesday November 01, 2023 @03:50PM (#38103926)
The parent commenter is underestimating the usage of C++, but using TIOBE as an argument serves no purpose, and I wish people would let it die. Their methodology is incoherent, their grasp of statistics is questionable, their information sources are nonsensical and inconsistent, and their weightings are capricious, opaque, and ever-changing. And now consider that their "language of the year" exhibits all of these flaws and more; it's often the case that the language of the year is simply the language that lost the most share at a specific point in the previous year (which happens all the time for no reason at all, because, as mentioned, they have no idea what they're doing). Please do not cite TIOBE in any context.
Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by pjmlp on Monday October 30, 2023 @06:44AM (#38067777)
While I agree with most of the theme regarding losing market share, C++ isn't going away while HPC/HFT still depends on it, we keep using languages that aren't self bootstrapted and rely on LLVM/GCC for their toolchains, JIT runtimes written in C++, GPGPU programming infrastructure, OS device drivers like on iDevices/Android/ChromeOS/Windows,certified compilers for high integrity computing,...

Even if C++ loses everything else, it is still a big chunck of the industry to keep it going for decades to come.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by tobias12345 on Monday October 30, 2023 @08:23AM (#38068545)
So your argument is: C++ will be a great legacy language and we will enjoy its memory bugs for decades to come?

I really hope it can do better than that.

Note that Window ships a kernel driver written in Rust already, Linux (== ChromeOS and Android) are working to add rust support and iOS is moving towards Swift everywhere. Other languages are closing in on all the use cases you mentioned.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by pjmlp on Monday October 30, 2023 @08:35AM (#38068687)
One kernel driver is nothing in 28 years of development, the head of Windows security (David Weston) is the very first to admit C++ is not going away from Windows that soon.

I am fully aware of all those efforts, several links have been posted into HN from me, you can find all of them on my submission history.

A language alone, without the ecosystem, certified compilers and plenty of other industry needs isn't enough, it takes time.

Food for thought, despite all the best efforts and almost painless compatibility, after 40 years, there are still industries that would take C over C++ without wasting a single second thinking about it.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by tobias12345 on Monday October 30, 2023 @12:41PM (#38071886)
I am not arguing that there is a lot of C++ code and that this code will be around for a long time. But I would prefer to see C++ as a language with a future and not as the language some well-paid dinosaurs use to keep the legacy code-base running while all the cool stuff happens elsewhere. "C++ will make a great legacy language" is underselling it.

But we might be wrong: Some government or consumer org or something _could_ step in and start to require the use of memory safe languages or just discourage the use of C/C++ in anything they buy. That would hasten the replacement of C++. I am afraid this is getting more likely based on how the C++ community handles growing concerns about memory safety outside of the development communities.

I have seen presentation on safety by people I respect for their contributions to the C++ language that all said a combination of these things:

* you said "C/C++", so you must be clueless * you do not know what safety means, let us explain that to you * everybody else does it wrong and is not really secure either * we can not solve the problem, because everybody uses C++ for the tricky bits that other language can not do because they are oh so safe * other languages are not as safe as they claim as they can all call into C++ * it will act swiftly, it will probably only take us a decade or so * you can use some extra tools somehow, that somebody will probably write * asking devs to follow our recommendations has never worked before, so we need something to enforce things. Let's ask all devs to please use this new thing. * Devs unfortunately do not follow best practices and there is nothing we can do about that

That does not seem to be a very convincing communication strategy to me, even less so when other communities show that real improvements are possible.

Re:Bjarne Stroustrup's Plan for Bringing Safety to C++ by tobias12345 on Monday October 30, 2023 @05:58AM (#38067450)
C++ did a lot to improve safety over the decades, but it seems to have ended up in a local maximum. I doubt you can break out of that local maximum by doing all the things you did before. Something needs to change, backward compatibility would be the one thing with the biggest overall benefit -- but also with the biggest cost.