Project ideas from Hacker News discussions.

C++26: Standard Library Hardening Experiments

📝 Discussion Summary (Click to expand)

1. Contracts as a pragmatic alternative to exceptions for precondition checks
Many commenters see contracts as a cleaner way to express and enforce expectations like “the widget must be Gonzo,” with selectable enforcement modes (quick‑enforce, enforce, observe, ignore).

“With Contracts you write a contract for the function with a pre‑condition that the Widget is Gonzo. Your users … can pick: If they fail a contract the program exits immediately reporting a violation …” – tialaramex

2. Contracts are fundamentally runtime features; compile‑time checking is limited and would need whole‑program analysis
While some hope for static contract verification, most agree that current contracts are enforced at runtime, and compile‑time checking would require extensive analysis that isn’t feasible today.

“C++ contracts are not a compile‑time construct, they're a runtime construct.” – steveklabnik
“…most contracts realistically need whole program analysis to diagnose and no compiler can do that …” – bluGill

3. The inclusion of contracts in C++26 is controversial, reflecting broader tensions in the standards process
Opinions split sharply; some view contracts as a useful compromise, while others (including influential figures like Bjarne Stroustrup) argue they are premature and threaten to veto the standard over their inclusion.

“The current contracts are not good enough for anybody who wants them … but it is good enough that they can start figuring out the details of making all the different factions happy.” – bluGill
“Bjarne is threatening to get a national body to veto the proposal so that there is no C++26 at all.” – whateverboat
“Contracts has the problem that everybody has a slightly different idea of what they want from the feature… there are few people who are vehemently against the current compromise.” – jcranmer


🚀 Project Ideas

ContractLint

Summary

  • A static analysis tool that performs whole-program analysis to check C++ contracts at compile time.
  • Provides IDE squiggles and CLI reports to catch contract violations early, turning contracts into a compile‑time safety net.

Details

Key Value
Target Audience C++ developers using contracts (C++26 draft) who want early detection of violations
Core Feature Whole‑program interprocedural analysis of pre/postconditions and invariants
Tech Stack LLVM/Clang, libclang, clang‑tidy plugin, SQLite for summary storage
Difficulty High
Monetization Revenue-ready: SaaS subscription tiered by CI usage and dashboard access

Notes

  • HN users noted: "Contracts are written such that the compiler can diagnose a detected violation if it wants to. However most contracts realistically need whole program analysis to diagnose and no compiler can do that - you want a separate static analysis for that." – bluGill
  • Also: "Need tooling which gives you a yellow squiggly line because your code violates a contract requirement" – tialaramex
  • Potential to become the de‑facto contract checker, sparking discussion on contract design and adoption in large codebases.

ContractToConcept

Summary

  • Source‑to‑source transformer that converts contract annotations into equivalent C++20 concepts where possible.
  • Enables compile‑time contract checking and devirtualization, fulfilling the desire for compile‑time polymorphism.

Details

Key Value
Target Audience Library authors and performance‑conscious C++ devs seeking compile‑time contract enforcement
Core Feature Transforms pre/postconditions into concept constraints on function templates
Tech Stack LibTooling (Clang AST), Boost.Wave for preprocessing, outputs C++20
Difficulty Medium
Monetization Hobby

Notes

  • HN users highlighted: "Compile-time contracts, or compile-time abstract base class would enable compile-time resolution of virtuals … superxpro12"
  • Also: "jayd16: How do you handle I/O type exceptions with contracts?" – shows interest in contract alternatives
  • Could bridge the gap between contracts and concepts, fostering discussion on unifying compile‑time contracts with generic programming.

ContractGuard

Summary

  • Runtime contract enforcement framework with configurable modes (quick enforce, observe, ignore) and rich diagnostics.
  • Integrates with build/CI to fail on violations and provides a dashboard for tracking contract health across projects.

Details

Key Value
Target Audience Teams adopting C++ contracts who need flexible enforcement and observability
Core Feature Library providing contract checking with modes, plus CLI/CI plugin and web dashboard
Tech Stack C++20 header‑only library, Python/Flask dashboard, GitHub Actions plugin
Difficulty Medium
Monetization Revenue-ready: SaaS dashboard with per‑seat pricing

Notes

  • HN users described: "With Contracts you write a contract for the function … users can pick: If they fail a contract the program exits immediately reporting a violation ('quick enforce'), it reports the violation via a global contract handler and then exits ('enforce') or it just reports to the handler but doesn't exit ('observe') or finally, they ignore it entirely ('ignore')" – tialaramex
  • Also: "bluGill: Contracts are written such that the compiler can diagnose a detected violation if it wants to. However most contracts realistically need whole program analysis to diagnose and no compiler can do that - you want a separate static analysis for that."
  • Supplies the missing runtime enforcement modes and observability, likely to ignite discussion on contract semantics and tooling maturity.

Read Later