February 20, 2026
Off-by-one? Off-by-drama!
Index, Count, Offset, Size
A simple naming guide ignites a nerd brawl over words we thought we knew
TLDR: A dev proposed a naming rule—use “count” for items, “index” for position, “size” for bytes, and “offset” for byte position—to cut mistakes. Comments split over what “length” and “offset” should mean, whether to use half‑open ranges, and if names should be short or super explicit
A TigerBeetle engineer tried to end a classic coding headache—off‑by‑one mistakes—by laying down a simple naming rule: use count for “how many items,” index for “which item,” size for “how many bytes,” and offset as the byte‑based index. Also, ban the slippery word length because it means different things in different languages. Sounds tidy, right? The comments immediately turned it into a naming civil war.
The top joke landed first: the page itself was misaligned, and one commenter deadpanned, “best viewed in Lynx,” roasting the site’s own offset while everyone debated offsets. Then the pedants pounced. One camp argued Rust’s use of “length” for byte size is “just confusing,” while others countered that ambiguity is exactly why the rule exists. A standards nerd dropped receipts with an ISO C link showing countof once nearly shipped as lengthof—proof that even committees can’t agree. Meanwhile, a separate skirmish broke out over Dijkstra’s half‑open ranges (start is included, end isn’t). One commenter warned the index < count safety rule only holds if you follow that style, drawing howls from the “inclusive range” crowd.
Finally, the naming maximalists rolled in: forget brevity—just use sizeInBytes, byteOffset, elementOffset because “IDEs and AI make long names painless.” Minimalists clapped back that laser‑simple words catch mistakes faster. It’s not just code—it’s a vibe war over the dictionary.
Key Points
- •TigerBeetle uses a naming convention: “count” for number of elements and “index” for element position, enforcing the invariant index < count.
- •For byte-level operations, “size” denotes byte count and “offset” is the bytewise counterpart to index; size = @sizeOf(T) * count.
- •The term “length” is avoided due to ambiguity across languages (e.g., Rust str::len is byte-size vs. Python len(str) as code-point count).
- •When not performing index arithmetic, techniques like the newtype pattern and the “Gankra trick” help prevent cross-domain index misuse.
- •An example from TigerBeetle’s NodePool shows the convention applied in practice, aiming to reduce off-by-one and indexing errors.