Project ideas from Hacker News discussions.

Type Safe Generic Data Structures in C (2025)

📝 Discussion Summary (Click to expand)

Theme 1 – Desire for compile‑time/generic features in C
Many commenters admire David Priver’s work on C templates, reflection, and _Generic tricks, and they wish for more compile‑time capabilities.
- rramadass: “Also see Templates in C by David Priver … He also has other interesting C techniques, namely; Adding reflection to C … Generic for Type Reification in C … I really like his style of writing and presentation; concise and precise.”
- warmwaffles: “I do wish to see comptime stuff in C some day. Or at a minimum your defblock implemented.”
- uecker: points to a proposal for #def / #enddef as a way to add block‑level macros.

Theme 2 – C macro hacks vs. C++/other languages for generic data structures
The thread debates whether macro‑based solutions in C are preferable to using C++ (or newer languages) for type‑safe containers.
- pornel: “It's not worth it… Users of C either like it exactly the way it is, or have to use a specific C version due to a vendor dependency or compliance. An upgraded C not approved by the standards body gives you yet another niche language that is not C, but is still burdened with its old flaws.”
- jstimpfle: “C++ containers are designed for average demands… For anything more demanding it's horrifically bloated and bad… It's better than messing with macros in pure C.”
- ActorNightly: “you can just write a library for all the stuff you need… This stuff is just syntactic sugar.”

Theme 3 – Compatibility and the risk of straying from standard C
Several participants stress that C’s strength lies in its stability, wide compiler support, and familiar semantics; breaking compatibility creates a niche language that loses those advantages.
- pornel (again): “As soon as you change anything in a breaking way… you end up losing the things that keep C alive.”
- accelbred: “At the point you clean up the syntax, you're not really C with extensions anymore.”
- FullGarden_S: “C3 might be it because C3 has full C ABI compatibility … unlike most modern C‑like alternatives, it checks out.”

These three themes capture the core of the discussion: enthusiasm for advanced compile‑time features in C, the trade‑off between C macro tricks and higher‑level languages for generic programming, and the importance of preserving C’s compatibility and simplicity.


🚀 Project Ideas

C Reflection Library (Header‑Only)

Summary

  • Provides compile‑time reflection for C structs using simple macros, enabling automatic serialization, deep copy, field iteration, and generic algorithms without leaving C.
  • Core value: Gives C programmers the power of RTTI/generics (like C++ templates) while staying fully compatible with existing C compilers and toolchains.

Details

Key Value
Target Audience C developers who need type‑safe generic containers, serialization, or meta‑programming but prefer to stay in pure C
Core Feature REFLECT_STRUCT(MyStruct) macro generates a type descriptor; API includes reflect_get_field, reflect_set_field, reflect_to_json, reflect_deep_copy
Tech Stack C11/C23, uses _Generic, offsetof, variadic macros; optional Clang‑based build script for validation
Difficulty Medium
Monetization Hobby

Notes

  • HN users praised David Priver’s “Adding Reflection to C” and wished for a usable library: “I do wish to see comptime stuff in C some day…” (warmwaffles) and “I also posted your 'Adding Reflection to C'…hope HN picks up on it” (rramadass).
  • Would spark discussion on extending C with zero‑overhead reflection and could become a de‑facto standard for C meta‑programming.

Macro‑Based Generic Container Generator

Summary

  • A CLI tool that takes a concise description (e.g., vector<int> or hashmap<string, Widget>) and emits type‑safe C container header/source files using macros, eliminating boilerplate and macro‑hack fatigue.
  • Core value: One‑line generation of reliable, debuggable generic‑like containers while keeping the final code pure C and easy to audit.

Details

Key Value
Target Audience C programmers frustrated with manual macro containers (e.g., uecker’s noplate) who want ergonomic, type‑safe data structures
Core Feature Input spec → generated .h/.c with API like vec_push, vec_get, hm_insert, hm_lookup; includes unit‑test skeletons
Tech Stack Generator written in Rust (or Python); output plain C using _Static_assert and macros for compile‑time type checks
Difficulty Medium
Monetization Hobby

Notes

  • Commenters noted the pain of macro hacks: “I do wish to see comptime stuff in C… I am so tired of having to escape new lines.” (warmwaffles) and “I’ve tried doing this for a few years and it just sucks ass. Just use c++ and templates… ” (nice_byte). A generator would give the benefits of templates without leaving C.
  • Could foster a shared repository of community‑generated containers, reducing duplicated effort.

Interactive C REPL with C2y/C29 Features

Summary

  • An interactive REPL (like DrC) that accepts C2y/C29 syntax, shows macro expansions, provides on‑the‑fly type reflection, and can JIT‑execute snippets for rapid experimentation.
  • Core value: Lowers the barrier to try advanced C features (reflection, generics, flexible array members) and instantly see results, encouraging learning and prototyping.

Details

Key Value
Target Audience C learners, experts exploring C2y/C29 proposals, and developers wanting to test macro‑based generics or reflection ideas
Core Feature REPL prompt that parses input via clang/libclang, executes via LLVM JIT (or TCC), and offers commands like :reflect MyStruct, :macroexpand, :showtypes
Tech Stack LLVM/Clang for parsing/JIT, optional TinyCC fallback; front‑end in Rust or C++; terminal UI with line‑editing (e.g., rustyline)
Difficulty High
Monetization Hobby

Notes

  • Many users expressed desire for a REPL: “I also posted your 'DrC' compiler/interpreter; usecase, scope, techniques used etc.” (rramadass) and “I do wish to see comptime stuff in C…” (warmwaffles).
  • Would stimulate discussion on upcoming C standards and serve as a playground for proposing new features, directly addressing the HN thread’s interest in DrC and C2y.

Read Later