A generic dynamic array in C that stores no capacity and needs no struct

C coders are fighting over a tiny trick that some call genius and others call pure chaos

TLDR: A programmer showed off a way to make growable lists in C using just two pointers and no wrapper object. Commenters instantly split between calling it brilliant minimalism and clownishly over-clever code that trades readability and flexibility for a neat trick.

A tiny coding trick just turned into big comment-section theater. The idea is simple-ish: instead of wrapping a growing list in a neat little box with labels, the author uses two plain pointers—one secretly holding the item count, the other pointing at the actual data. No custom container name, no extra wrapper, no stored spare room number. In regular-human terms, it’s like stuffing the inventory count into a place people usually expect to find an address, then calling that elegance. Naturally, the internet had thoughts.

The loudest reaction was a split between “wow, clever” and “please never do this at work.” One commenter practically gave it a standing ovation, calling the no-stored-capacity idea a revelation after decades of C. Another gave the classic backhanded compliment: “pretty clever code. Too clever for my tastes.” And that line basically became the mood of the room. Fans saw minimalist wizardry; critics saw a maintenance nightmare waiting to ruin someone’s weekend.

The snark was especially strong around the article’s brag that it needs no struct—basically, no tidy labeled bundle for the data. One commenter mocked the whole premise, joking about the “pleasure” of not having field names when you later need to change things. Another went fully blunt with “This is just silly,” pointing out that you lose an easy way to pre-allocate room, which matters if you care about performance. The vibe? Half the crowd was admiring a magic trick, and the other half was yelling that magic tricks are a terrible foundation for plumbing.

Key Points

  • The article proposes a generic dynamic array in C implemented as an array of two pointers rather than a struct.
  • In the design, the first pointer encodes the array length as a uintptr_t and the second pointer points to the data buffer.
  • A `vec_push` macro appends elements and returns true on success.
  • The implementation is described as C23 code that also uses GNU C statement expressions.
  • Capacity is not stored; it is computed when length is zero or a power of two, with growth handled by realloc to the next power of two.

Hottest takes

"Enjoy the pleasure of not using a struct" — t-3
"Brilliant insight" — userbinator
"Too clever for my tastes" — Akronymus
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.