Theme 1 – Contracts as richer assertions with selectable semantics
Participants see contracts as a way to get the benefits of assertions (documentation, tool‑visibility) while allowing static checking, runtime control, and possible optimisation.
- “You can set a contract evaluation semantic for contracts. One of them is ‘observe’, which only prints a message on contract violations. With ‘ignore’, nothing at all happens.” – ahartmetz
- “Graceful handling is a trade off. Sometimes the check is expensive … but you don’t want to lose this.” – bluGill
- “Contracts are intended to document hoare logic … They can be compile time if the compiler can verify them statically (where they become a noop), runtime otherwise, or disabled entirely if you can't prove them statically but don't want the overhead cost.” – OneDeuxTriSeiGo
Theme 2 – Uncertainty about the proper scope of contracts (input‑validation vs internal correctness)
There is lively debate over whether contracts should guard against bugs that “can’t happen” or also be used for validating external input, leading to confusion about their intended purpose.
- “If it can happen, but shouldn’t, that’s input validation (e.g. the user inputs an empty name). If it can’t happen and shouldn’t, that’s a contract (e.g. I checked that this string is non‑empty in the function that calls this one, so I already know it’s non‑empty).” – wongarsu
- “The line between what's ‘input validation’ and what's ‘What you expect’ is very muddy.” – cogman10
Theme 3 – Concerns about added complexity and a preference for simpler languages or disciplined subsets
Many commenters worry that contracts further bloat C++ and advocate for using simpler languages or enforcing language subsets, though some view contracts as a way to gradually introduce stricter reasoning without leaving C++.
- “Maybe just me, but huge complicated languages like C++ seem as unappealing as ever.” – randyrand
- “Languages like Go … appear simple on the surface, while in reality is full of gotchas and boilerplate …” – pjmlp
- “Profiles should (hopefully) rein this in by getting people to start subsetting language features in their codebases.” – nickorlow