Hacker News
points by rramadass 4 days ago | 0 comments
> While the C++26 variant of contracts doesn't provide the benefits of its static-analysis-centric ancestor from 2014

Do you have any information as to why they shifted the focus from static analysis to runtime checks? I only remember that it was based on some Microsoft annotation language or something.

[–] bluGill 4 days ago
Static analysis is hard. C++ 26 contracts are supposed to be the minimum viable feature that can be expanded on in future revisions.

Already the compiler is allowed to refuse to compile any code if it would guaranteed fail the contract. The next step is to see how far we can go with that static analysis and what those static analysis tools need to be better. However, this requires people having contracts in fairly widespread use so they can start trying their new ideas to see what happens when they hit the real world.

[–] rramadass 4 days ago
The original idea for C++ contracts was to implement something like Microsoft SAL notation (sometime in 2014) to enable full static analysis and that is what i was hoping for.

See my comment here - https://news.ycombinator.com/item?id=50361418

However, i also understand the reasoning behind this C++26 contracts proposition - https://news.ycombinator.com/item?id=50364593

While i understand the rationale here, i can also see the problems it might lead to in the future. Correctness concerns should be an all-or-nothing proposition, you cannot do it piecemeal. Hence whether you want to call it "profiles" or not, i would like a Eiffel/Ada-SPARK like system which gives me complete static compile-time analysis and verification along with separate run-time guarantees.

The contracts committee should go back to the drawing board and come up with a more comprehensive solution.

This is a real chance to finally realize the "Safe C++" dream! Ada did it and so can C++.