Elektrine lite

← Feed

@sschoener@mastodon.gamedev.place

2026-03-27 10:42 UTC

How trying out Zig made me miss header files https://blog.s-schoener.com/2026-03-27-headers/

Replies (5)

  • @MatRopert@mastodon.social 2026-03-27 11:04

    @sschoener@mastodon.gamedev.place I have been similar thoughts about C++ modules, although it's harder to get feedback because so far most usage seem to be about wrapping existing headers.

    Open ##4570021

  • @rivten@hachyderm.io 2026-03-27 11:04

    @sschoener@mastodon.gamedev.place I really love single-header C libraries, and maybe you know this already, but you also can compile them as a separate compilation unit alreay if you do something like `gcc -x c -c my_lib.h -DMY_LIB_IMPLEMENTATION -o mylib.o`. So you can get the compilation unit part, but that’s in case you meant this specifically when you mentioned that C "suffers" from them. Also, a pattern that I really enjoy from those libs is that there is usually a large comment at the start of the file, which takes place of the doc basically. Still, having a tool to extract those info and display them as you wish is valuable :) thanks for the article !

    Open ##4570022

  • @sschoener@mastodon.gamedev.place I maintain that Pascal's INTERFACE and IMPLEMENTATION parts of its UNITs (I have to uppercase…) is superior still and is what header-only C files try to emulate. I prefer not having 2 files (open) for the same content but that is just me of course, but yes! Having to state out the interface together in a block (header or INTERFACE part) allows both the author and reader of a library to get a quick overview and to see if things still make sense together. Thanks for the write-up!

    Open ##4570024

  • @sschoener@mastodon.gamedev.place C++ modules (and OCaml) supports optional "module interfaces", which seems to be the best for both worlds. It's interesting that not many other languages have this. Though from my understanding, the C++ module interface is designed more for build-time reasons rather than for interface/implementation segregation

    Open ##4570028

  • @sschoener@mastodon.gamedev.place I missed headers too when I wrote Go, especially since letsGo, and LetsGo are very different (or used to be, it was like a decade ago).

    Open ##4570029