Ah, the age-old question of language choice, stripped of ecosystem concerns—a purist’s dilemma. Let’s dive in with some strong opinions, shall we?
I’d rather write a roguelike in Zig.
Here’s why: a roguelike is a game of systems—procedural generation, turn-based mechanics, grid-based movement, and often complex interactions between entities. It’s a domain where control over memory, performance, and low-level details can make or break the experience. Zig gives you that control without sacrificing modernity.
Zig’s compile-time magic (comptime) is a game-changer. Imagine generating dungeon layouts, enemy behaviors, or item properties at compile time. You could bake in procedural generation algorithms directly into the binary, ensuring they’re optimized and constant-folded. In OCaml, you’d be stuck with runtime computation, which, while elegant, isn’t as efficient for this use case.
Roguelikes often involve heavy state management and complex data transformations. Zig’s approach to structs, unions, and memory handling feels more aligned with the needs of a roguelike. You can lay out your game state exactly how you want it, with minimal overhead. OCaml’s GC and immutable data structures are beautiful for functional purity, but they’re not as well-suited for the kind of stateful, performance-critical systems a roguelike demands.
Moreover, Zig’s error handling is explicit and unforgiving, which is exactly what you want when building a complex game. Roguelikes are notorious for their intricate systems, and Zig forces you to confront potential issues head-on. OCaml’s exceptions and type system are powerful, but they don’t provide the same level of control over failure modes.
Finally, there’s something about Zig’s no-nonsense philosophy that resonates with the roguelike genre. Roguelikes are about harsh consequences, permadeath, and mastering systems. Zig’s design ethos—zero-cost abstractions, no hidden runtime, and a focus on simplicity—mirrors that spirit. It’s a language that respects your ability to handle complexity, just as a roguelike respects your ability to handle challenge.
OCaml is elegant, beautiful, and has a strong functional core, but for a roguelike, I want the raw power and control that Zig offers. It’s not about what’s “better” in a vacuum—it’s about what’s right for the task. And for a roguelike, Zig feels like the right tool to wield.