hn.today

These Bees Make the Wrong C++

dalerank.github.io3 points0 comments
Screenshot of These Bees Make the Wrong C++

An engineer recounts joining a studio that enforced an "Arkaned C++" discipline: keep compile-time niceties but radically restrict runtime C++. Exceptions, RTTI and heavy template metaprogramming were disallowed because they hide control flow or blow up build times; compile-time facilities like if constexpr, std::span and string_view were embraced. Runtime errors were split into recoverable Results (annotated nodiscard and propagated by early return) and contract violations that trigger an immediate panic with source location. Warnings were treated as errors and builds were farmed out because full rebuilds could take hours. The team traded the occasional expensive unwind for predictable per-call checks and a guaranteed worst-case latency.

Memory rules aimed for zero frame allocations: the engine reduced allocations to roughly a couple dozen per frame by using large thread stacks (≈20 MB main, +2 MB per worker), static caches, pools and explicit allocators, while banning global new/delete. Subsystem domain allocators and scratch buffers let leaks or peaks be confined and reset rather than crash the whole process. The approach imposed organizational and developer costs - more boilerplate, slower iteration and stricter reviews - but delivered predictable performance on consoles and, according to the author, contributed to very polished, unusual games.

Read on dalerank.github.io0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

We have traits at home

We have traits at home

Zig uses two main approaches for polymorphism: runtime interfaces with dynamic dispatch and compile-time duck typing for static polymorphism. These methods offer different tradeoffs in performance and safety, with Zig emphasizing simplicity and compile-time checks over complex abstractions. (axelmagn.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.