Project ideas from Hacker News discussions.

C++26 Contracts: Introduction to Preconditions and Postconditions

📝 Discussion Summary (Click to expand)

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

🚀 Project Ideas

Generating project ideas…

ContractLens IDE Plugin

Summary

  • Provides real-time navigation, highlighting, and lightweight static verification of C++26 contracts inside VS Code/CLion, reducing header bloat and compile-time friction.
  • Core value: developers see contracts as first-class documentation, get instant feedback on violations, and can toggle observe mode without leaving the editor.

Details

Key Value
Target Audience C++ developers using contracts (especially those working with large codebases and modules)
Core Feature Inline contract annotation viewer with jump-to-definition, violation highlights, and optional Z3-backed proof attempts on edit
Tech Stack Language Server Protocol (LSP) server using clangd/libclang, Z3 SMT solver, TypeScript/frontend for VS Code, C++ backend for CLion
Difficulty Medium
Monetization Revenue-ready: $12 per user per month (team licensing)
#### Notes
- HN users complained about contracts losing header documentation and increasing compile times (e.g., nananana9: "If I put them in the header, I have to include half the world..."); ContractLens shows contracts without needing to pull in heavy headers.
- Enables observe mode monitoring in-editor, addressing bluGill's wish to turn contracts on in workstation builds while keeping them off in embedded production.
- Could spark discussion on integrating contract-aware LSP features into clangd.

ContractSuggest: Contract Inference CLI

Summary

  • Analyzes existing C++ codebases (including unit tests and asserts) to infer likely pre/post conditions and generate contract annotations.
  • Core value: reduces manual contract authoring effort and helps teams adopt contracts gradually by leveraging existing test evidence.

Details

Key Value
Target Audience Teams adopting C++26 contracts who want to bootstrap contract coverage
Core Feature Static analysis + dynamic test observation to propose contract clauses (pre/post/invariant) that can be reviewed and inserted
Tech Stack Python/Clang AST parser, libclang, pytest/catch2 test harness, optional dataflow analysis via LLVM; output as contract attributes or comment templates
Difficulty Medium
Monetization Hobby (optional paid support/consulting)
#### Notes
- Commenters like bluGill wanted solvers to prove code correct and see where they give up; ContractSuggest gives a starting point for contracts that solvers can then try to verify.
- Addresses the pain of contracts feeling like "fancier asserts" (pg. cogman10) by providing evidence-based suggestions, making them feel less arbitrary.
- Could be integrated into CI to keep contracts up-to-date as code evolves.

ContractWatch Observability Platform

Summary

  • Lightweight runtime agent that captures contract violations in observe mode, aggregates them into a cloud service, and provides dashboards for triaging production contract breaches.
  • Core value: lets teams monitor contract health in production without crashes or performance penalty, turning contracts into a proactive quality signal.

Details

Key Value
Target Audience Production C++ services using contracts (especially embedded/high-performance systems)
Core Feature Agent library with zero-overhead when disabled, low-overhead observe mode collection, secure transmission to backend, UI for viewing violation trends and root cause
Tech Stack C++ agent (using contract violation hooks), gRPC to backend, PostgreSQL/TimescaleDB for event storage, React/Dash frontend; optional integration with OpenTelemetry
Difficulty High
Monetization Revenue-ready: usage-based pricing ($0.001 per 1K contract events)
#### Notes
- HN users such as bluGill wanted to turn contracts on in workstation but not in production due to overhead; ContractWatch's observe mode captures data without terminating, fulfilling cenamus' note: "with the 'observe' mode you can turn them on in production code right away and collect data without a failed assert terminating."
- Enables the optimization discussion: account42 wondered about using contracts for optimization when not being evaluated; ContractWatch provides data to feed back into optimization decisions.
- Provides a concrete topic for HN debate: balancing contract observability vs. privacy/overhead.

Read Later