Live data from Hacker News

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

jonathanwhiting.com

141–150 of 288 posts

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

#141

Earlier quoted context omitted.

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.

You're welcome!

One of the fun things about Empire is one isn't out to save humanity, but to conquer! Hahahaha.

BTW, one of my friends is using ClodCode to generate an Empire clone by feeding it the manual. Lots of fun!

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

#142

Earlier quoted context omitted.

I measured once and to my surprise templates aren't (directly) the reason for long compile times. It's function bodies in headers, and obviously templates are in headers and they call other templated functions/classes which explodes code generation and time. But if it's only a few lines and doesn't call other templated functions it's likely fine. I wrote about it here https://bolinlang.com/wheres-my-compile-time Afte…

Your website seems to be blocking Tor

Oh? I use a boring old $5 VPS (using nginx for https). There's no cloudflare or anything else involved. I wonder why that's happening. I may look into that this week

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

#143

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/

Handmade Hero is a bad idea for anyone wanting to learn how to make a game in C or C++. Casey intentionally avoids using standard libraries and frameworks and his irrational hatred of high-level code and modern standards will lead developers astray and waste their time.

Even if you're using C you don't need to implement your own renderer or do half the things he does. Get a library like SDL3 to handle the basics, maybe use Lua/LuaJIT for scripting. Learn OpenGL or Vulkan. Stay away from HH and Casey Muratori until you're experienced enough to tell the difference between his wisdom and his bullshit.

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

#144
post #110

Earlier quoted context omitted.

why not std::string?

You can surely create a std::string-like type in C, call it "newstring", and write functions that accept and return newstrings, and re-implement the whole standard library to work with newstrings, from printf() onwards. But you'll never have the comfort of newstring literals. The nice syntax with quotes is tied to zero-terminated strings. Of course you can litter your code with preprocessor macros, but it's inelegant…

Hacker News seems not to hate antirez's sds

https://github.com/antirez/sds

https://news.ycombinator.com/item?id=45014911

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

#145

Earlier quoted context omitted.

Your website seems to be blocking Tor

Oh? I use a boring old $5 VPS (using nginx for https). There's no cloudflare or anything else involved. I wonder why that's happening. I may look into that this week

It could also just be down. I didn't try outside of Tor

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

#146
post #122

Earlier quoted context omitted.

It's a class, so it doesn't work in C.

Sure, but you can have a similar string abstraction in C. What would you miss? The overloaded operators?

Automatic memory accounting — construct/copy/destruct. You can't abstract these in C. You always have to call i_copied_the_string(&string) after copying the string and you always have to call the_string_is_out_of_scope_now(&string) just before it goes out of scope

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

#148
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…

Of course people do" virtual functions" in C, but I think this is not an argument despite C. I noticed that making virtual in C++ is sooo easy that people start abusing it. This making reading/understanding/debugging code much harder (especially if they mess this up with templates). And here C is a way - it allow but complicates "virtual". So, you will think twice before using it

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

#150

As a hardcore C programmer and zealot myself... How in the hell can you be productive like that? C is a systems programming language, not an application programming language, let alone relevant to the levels of abstraction you'd want in game development. That said, "I am dead" is a very real video game indeed... and his arguments are very sound. I also can't stand C++. I disagree with him on Java though. The core lan…

> The core language of Java is actually super simple, like C.

Not being facetious, but couldn't you say that about almost any language? What makes you say it about Java?

Post reply on HN