Stroustrup objects to adding Contracts to C++
Paul Backus
snarwin at gmail.com
Mon Nov 9 12:19:30 UTC 2026
On Monday, 9 November 2026 at 00:40:29 UTC, Walter Bright wrote:
> https://www.stroustrup.com/Contracts_fundamental_flaws.pdf
>
> An interesting read, relevant to resurging interest in
> improving D's contracts.
Honestly, contracts in D are kind of a flop. Not because there's
anything wrong with them in principle, but because the goals
you'd use them to achieve are usually achieved more effectively
by other means (unit testing, encoding invariants in the type
system).
Meanwhile, they add a significant amount of complexity to both
the spec and implementation, and have tricky edge cases around
inheritance and separate compilation.
If C++ can learn anything from D's experience here, it's that
contracts are probably a waste of time.
More information about the Digitalmars-d
mailing list