I write games in C (yes, C)
Source: Hacker News
Why I Write Games in C (yes, C)
I am an unusual beast. All my solo‑project games I’ve been making recently have been written in vanilla C. Nobody does this, so I think it might be interesting to explain why I do.
Dry programming language opinions incoming, you have been warned.
What I need from a language
There are some non‑negotiable requirements.
- Reliability – I can’t afford to spend my time dealing with bugs I didn’t cause myself. A lot of my games were written for Flash, and now Flash is dying. I do not want to spend my time porting old games to new platforms; I want to make new games. I need a platform that I am confident will be around for a while.
- Portability – I want to avoid tying myself to a particular OS, and ideally I’d like to have the option of developing for consoles. So it’s important that my programming language is portable and that it has good portable library support.
What I want from a language
The strongest thing on my desired (but not required) list is simplicity. I find looking up language features and quirky “clever” APIs incredibly tiring. The ideal language would be one I can memorize and then never have to look things up.
- Strict typing & static analysis – fewer bugs, strong warning messages, and static code analysis.
- Good debugging tools – dynamic analysis and debuggers that make bugs easier to find.
- Performance – I’m not after high‑def realism, but I care about having enough cycles to broaden what I can do, especially on modern, powerful computers.
- Fast compilation – waiting 10+ seconds breaks my flow; a quick compile keeps me productive.
- Data‑centric approach – I’m not an OOP convert. I prefer handling data as data and writing code that fits the situation rather than forcing everything into classes.
The Alternatives
- C++ – still the most common language for writing games, and not without reason. I do almost all of my contract work in it, but I dislike it intensely. It covers my needs but fails my wants badly. It is desperately complicated, and despite decent tooling it’s easy to create insidious bugs. It also compiles slower than C.
- C# and Java – both are verbose and complex beasts. They railroad programmers into a strongly OOP style that I am opposed to, and they tend to hide complexity in ways that don’t actually prevent it from biting you.
- Go – I like it a lot; in many ways it is C revisited, taking into account what has been learned since C’s release. However, stop‑the‑world garbage collection is a big pain for games, and library support for games is poor. Wrapping C libraries adds busy work, and I worry about its long‑term relevance.
- Web‑focused options – JavaScript feels too loose for my taste, and the web ecosystem moves terrifyingly fast, especially after Flash’s death. Haxe shows promise with decent library support, but its relative youth makes me wonder about longevity.
- Creating my own language – I admire the idea and sometimes toy with it, but throwing away existing library support and taking full responsibility for future compatibility feels like too much work. I’d rather be making games than programming languages.
Why C is still my best fit
- C is dangerous, but it is reliable—a very sharp knife that can cut fingers as well as veg, yet simple enough to learn to use carefully.
- It is fast, and when it comes to compilation I can’t think of anything faster.
- It can be made to run on just about anything, usually with relatively easy effort. It’s hard to imagine a time when this won’t be the case.
- The library and tooling support is strong and ongoing.
I say this with some sadness, but it is still the language for me.
I absolutely do not mean to say “hey, you should use C too.” Preferences are pretty specific and unusual. I have also already written more “vanilla” C code than most, and that certainly is part of my comfort.
So yeah, that’s it. :-)