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 replaced the game’s roughly 100,000 lines of Zig with C3, mainly to make hot-reload iteration practical on Windows. A warm Zig rebuild after a small change took more than 15 seconds, while C3 compiles the whole game without caching in about three seconds. C3 also met the project’s needs: explicit memory management without garbage collection or RAII, WebAssembly support for mods, good performance, and syntax likely to be approachable to future modders. Because C3 and Zig share many concepts, the port was largely mechanical. The developer also cites Zig’s breaking changes and weak Windows debugging experience as reasons for moving.

The rewrite enabled SL3, a restricted subset of C3 designed for game logic that can run as bytecode in a register-based virtual machine during development or be compiled into native code for release. This lets particle effects be edited and tested quickly without sacrificing optimized runtime performance; the current VM runs the project’s effects at 60 frames per second with little noticeable difference from native execution. SL3 code can also be bundled into one DLL, and its restrictions help sandbox scripts. It currently powers particle effects, but could grow into a general scripting language or generate GPU compute shaders. The developer considers GPU particle simulation a likely next step, while noting that compile speed alone would not have justified the full rewrite.

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

Personal Computing

Personal Computing

Cory Doctorow recalls Vernor Vinge’s visionary novel *Rainbows End* and the friendship and encouragement he shared with its author. He connects its vision of personal computing to vibe coding, while asking who will build and maintain the free and open-source software it depends on. (pluralistic.net)

The daily digest

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