hn.today

So, I rewrote my game in C3

madrigalgames.com3 points0 comments
Screenshot of So, I rewrote my game in C3

Traction Point’s developer has replaced the game’s Zig code with C3, chiefly because rapid hot-reloading has become central to development. On Windows, rebuilding the roughly 100,000-line Zig debug build takes about 24 seconds, and even a one-line change takes more than 15 seconds with a warm cache; C3 compiles the full game in roughly three seconds without caching. C3 also fits the project’s needs: it has no garbage collector or automatic resource-management system, supports WebAssembly for modding, runs quickly, and uses familiar C-style syntax that may be approachable to future modders. Because C3 and Zig share many concepts, much of the port was a near-mechanical translation. The game uses C3 annotations to identify engine components and editor-exposed fields, while explicit lifetime management and `defer` preserve familiar patterns.

The rewrite also enabled SL3, a restricted subset of C3 designed for fast iteration without sacrificing shipped performance. SL3 logic can run as bytecode in a register-based virtual machine during development, then be compiled into a native DLL; multiple modules can be bundled into one library. Sandboxing limits the code’s memory access, and advanced C3 features are not yet supported. SL3 currently powers particle effects: its virtual machine runs the existing effects at 60 frames per second, with little noticeable difference from native execution in a demo mission. The developer sees potential to expand SL3 into a general scripting language or generate GPU shader code from it. A C3-based modding SDK is planned for the next playtest release.

Read on madrigalgames.com0 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

The daily digest

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