r/cpp • • Oct 24 '24 • Take My Silver 1

Why Safety Profiles Failed

https://www.circle-lang.org/draft-profiles.html
180 Upvotes

347 comments sorted by

View all comments

Show parent comment

4

u/srdoe Oct 27 '24 edited Oct 27 '24

You're all over these threads being wrong and ignoring what people are telling you, so I'm sure this won't make any difference, but here goes:

What migration?

As per this comment whether you feel like migrating existing code is entirely up to you. You don't have to migrate any existing code if you don't want to.

You can call the safe subset from unsafe code just fine, so you can write new code in the safe subset and plug it into existing programs.

If the new safe code has to call existing unsafe code you don't want to migrate, you can do that too if you have to, by marking that call as unsafe, which means you still benefit from safety outside those unsafe blocks.

That's without even addressing the problem you keep handwaving away: Since profiles don't have enough information to accurately tell if something is unsafe, they either have to let things slip through (i.e. they don't work, this is likely a non-starter for regulators, and this is where profiles are at right now. Profiles as they exist today in implementations are not viable.), or they have to be extremely conservative and flag lots of false positives which then have to be marked as excluded in your source.

You said previously that you think the latter is fine. If you look at Sean's post in the OP, plenty of the stdlib will need exclusions, and likely so will your own code.

That's exactly the kind of littering of the code with annotations you claim not to want, and it is migration work.

It's completely unclear that there will be less work in migrating to profiles than there would be in adopting Safe C++. And at least with Safe C++, that work would be something you do once, not something you have to do repeatedly forever as you write new code, as you would with excluding false positives with profiles.

And just to be clear: Complaining about how disruptive this is won't help. Due to regulators getting involved, this isn't simply a discussion about how to make C++ better where "do nothing" is a viable option. Neither is "Let's research this for another 10 years".

Regulators are already out there right now strongly recommending that companies look at migrating to memory safe languages. Can you be sure they won't start explicitly blocking usage of memory unsafe languages 5-10 years down the road?

If the committee makes a decision that doesn't solve the problem, such as adopting a version of profiles that lets lots of memory safety issues sail through validation, it could very seriously harm C++ usage going forward.

Most companies aren't going to be choosing a language that blocks them from government work. Why would they?

If the committe does that, they're basically betting that regulators will back down on their demands. I think betting that way is irresponsible.

0

u/germandiago Oct 27 '24

Since profiles don't have enough information to accurately tell if something is unsafe, they either have to let things slip through (i.e. they don't work, this is likely a non-starter for regulators, and this is where profiles are at right now. Profiles as they exist today in implementations are not viable

This is true given the restriction that all info must go into the signature but not true if you change the constraints of how to compose it and I am trying to figure out ways. 

Of course I am not ignoring all things here. I am collecting them, checking, thinking and trying to improve my understanding and I have at least already two things that are fixable given two assumptions: I believe one to be the aliasing problem. Another is the invalidation problem. There are more like "std::move" does not move.

This analysis will never be as accurate as a full-fledged type system but it should be mich more compatible.

I meed time to digest all the information. There is lots and I am trying to centralize some of it at this point.

Thank you for all the feedback in the thread, it helped me a lot to understand what I did not explain well enough, what I can be wrong about and what I think is fixable to reasonable extents.