r/cpp
•
u/steveklabnik1
•
Oct 24 '24
•
1
Why Safety Profiles Failed
https://www.circle-lang.org/draft-profiles.html
180
Upvotes
View all comments
Show parent comment
13
u/steveklabnik1 Oct 25 '24
Are you familiar with the general concept of soundness vs completeness? I think it's a more useful framing of this issue than percentages.
Basically, if we are trying to figure out a property of a program, there are three possibilities:
The interesting part is #3. A sound solution says "For #3, if we don't know, say no." A complete solution says "For #3, if we don't know, say yes."
The issue with soundness is that you reject some okay programs, and the issue with completeness is that you accept some not okay programs.
This has lead people to prefer soundness over completeness, because being sure that something is okay is very, very useful. But, it's true that the drawback to that approach means that there are some good things that get rejected. So what do you do? You add the ability to override the no. That's what "unsafe" in Rust is. You're saying, "hey compiler, I know that you think this isn't okay, but I am checking it and vouching that it is." That lets you bridge the gap.
The inverse doesn't really exist, as far as I know: there's no way to say "hey I know you think this is okay, compiler, but it's actually not." And even if you could do that, are you really sure you've gotten 100% of the not okay things taken care of? It's much much harder.
In some ways this is parallel to a whitelist/blacklist. Soundness is a whitelist of what's okay, and completeness is a blacklist.
This is really the core issue between the two proposals: Safe C++ is sound, and profiles are complete.