Live data from Hacker News

I write games in C (yes, C) (2016)

jonathanwhiting.com

131–140 of 288 posts

Re: I write games in C (yes, C) (2016)

#131
post #20

I write mostly like I would in C, but use C++ features as needed. It ends up looking similar to Rust if you squint. All these "I write games in C" people complain about C++ features, and then end up reimplementing virtual interfaces manually with struct headers or massive switch statements, just to feel better about themselves. Writing games in C is not harder, you just have to implement modern language features by h…

For every person who says on the internet that you can just use a C++ subset, there's another who insists that C is the bad C++ subset. So compiling C code with a C++ compiler promotes your code from "good C code" to "bad C++ code" (most C code isn't "exception safe," for example).

It's arguably irrational to evaluate a language based on this, but you can think of "this code could be better" as a sort of mild distraction. C++ is chock full of this kind of distraction.

Re: I write games in C (yes, C) (2016)

#132
post #128

It's not unheard of, but you have to be a little crazy to do this in 2026. I developed Chrysalis entirely in C (with GLFW3 and FMOD for audio): https://store.steampowered.com/app/1594210/Chrysalis/

I've been working religiously for like 2 years on the jedi academy codebase which is c & c++. It's Ravensofts variant of the idtech3 engine and it's insane how fragile the games combat is to precision and timing changes, I can't get away with adding much without destroying the lightsaber combat qualities. There are certain spots where I can't even add an incrementing i++ counter lmao it presents just enough of a slow…

Are you working on the original codebase or the OpenJK fork?

Re: I write games in C (yes, C) (2016)

#133
post #128

Earlier quoted context omitted.

I've been working religiously for like 2 years on the jedi academy codebase which is c & c++. It's Ravensofts variant of the idtech3 engine and it's insane how fragile the games combat is to precision and timing changes, I can't get away with adding much without destroying the lightsaber combat qualities. There are certain spots where I can't even add an incrementing i++ counter lmao it presents just enough of a slow…

Are you working on the original codebase or the OpenJK fork?

original codebase

Re: I write games in C (yes, C) (2016)

#135
post #113

Earlier quoted context omitted.

I think it is simpler and "the compiler not helping" == "things are more transparent". int a = 3; foo(a); // What value has a ? There are various things one does not have to worry about when using C instead of C++. But the brain needs some time to get used to it.

I think I get what you're trying to say, but you may have picked a bad example, here: #define foo(a) a = 12

Yes, but this is more a theoretical problems while references are common in C++.

Re: I write games in C (yes, C) (2016)

#136

Has anyone got any good resources for something like this? I haven't touched C in years, and never worked on anything game-like. But it does look like a really interesting project to start something like this.

If you have patience, the first 30 or so episodes of Handmade Hero are pretty good.

https://guide.handmadehero.org/code/

Re: I write games in C (yes, C) (2016)

#138
post #126

Earlier quoted context omitted.

I agree it shouldn't really matter if there's no C++ features in play, but I suppose third party headers could bite you if they use #ifdef __cplusplus to guard optional C++ extensions on top of their basic C interface. In that case the compiler could be dealing with dramatically more complex code when you build in C++ mode.

Maybe it is similar for the same compiler (but one should check, I suspect C could still be faster), but then there are much more C compilers. For example, TCC is a lot faster than GCC.

tcc is 8x faster, twice as fast isn't doing it justice.

As for the header thing, that'd could potentially be true if the compile time was something like 450ms -> 220ms, but why bother saying it when you're only saving a few hundred milliseconds

Re: I write games in C (yes, C) (2016)

#139

Earlier quoted context omitted.

Back in what day? Quake II I would say is the best good looking thing written in pure C. id Tech 3 is partly C++. Everything after that era was pretty much C++. Even GoldSrc is partly C++. Source was pure C++.

I guess back in my day, early to mid 90s. My understanding is C became more common.

Well I guess that was my time too but it was kind of a very short period. We went from assembly to C++ pretty quickly. Like things were assembly for a very long time, and they have been C++ for a very long time, but C was dominant mostly in that Doom to Quake II window.

Re: I write games in C (yes, C) (2016)

#140

Earlier quoted context omitted.

C's string handling is so abominably terrible that sometimes all people really need is "C with std::string". Oh, and smart pointers too. And hash maps. Vectors too while we're at it. I think that's it.

When I developed D, a major priority was string handling. I was inspired by Basic, which had very straightforward, natural strings. The goal was to be as good as Basic strings. And it wasn't hard to achieve. The idea was to use length delimited strings rather than 0 terminated. This meant that slices of strings being strings is a superpower. No more did one have to constantly allocate memory for a slice, and then kee…

Just want to off-topic-nerd-out for a second and thank you for Empire.
Post reply on HN