Live data from Hacker News

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

jonathanwhiting.com

281–288 of 288 posts

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

#281
post #279

Earlier quoted context omitted.

Your example is disingenuous. What you are stating is the obvious trivial way of doing something when your objective is actually quite different. You can get exactly what you are asking for in C++ using techniques of static polymorphism and CRTP pattern ( https://en.wikipedia.org/wiki/Curiously_recurring_template_p... and https://en.wikipedia.org/wiki/Barton%E2%80%93Nackman_trick ) along with traits and dynamic dispa…

What you're describing is needing to use specific verbose patterns to opt out of the defaults that do more complex things under the hood, whereas they're describing how C and Rust do not do those things by default and instead let you opt into them. It's not disingenuous to point that out.

Not quite.

What i am pointing out are neither complex nor any magic under-the-hood. They are simply techniques in the C++ repertoire well-known since the early 90's and used in all high-performance C++ libraries.

tialaramex made a big deal out of overheads in C++ dynamic dispatch (which incidentally are pretty minimal) using a trivial example, when performance focused (both time and size) C++ programmers do not use it that way at all. Modeling in C++ can be done in any number of ways and is driven by specific perspectives of the end goal.

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

#283
post #91

I've been writing a good chunk of C lately for some stuff that has some relatively high memory constraints (lower than I could squeeze out of GraalVM). I know I could do C++, and you could argue that's better, but I find C++ to be exceptionally irritating to use. Every time I've used C++ I get people telling me I'm using it "wrong", sometimes in contradictory ways. Sometimes I should use a "friend" function, sometime…

> I know I could do C++, and you could argue that's better, but I find C++ to be exceptionally irritating to use. Every time I've used C++ I get people telling me I'm using it "wrong", sometimes in contradictory ways. Sometimes I should use a "friend" function, sometimes "friend functions are evil". Sometimes multiple inheritance is fine, sometimes it should be avoided like the plague. Sometimes you should "obviously" use operator overloading, sometimes you should avoid it because it's confusing because you don't know which functions are being called.

That is because you are looking at Design in C++ wrong. Language features and low-level abstractions are just mechanisms. You have to put them into a coherent framework for modeling a problem domain via commonality & variability analysis (aka domain engineering) onto a solution domain consisting of language features, idioms and patterns.

For a very good explanation, see the classic book, Multi-Paradigm Design for C++ by James Coplien.

The above can also be found in his PhD thesis Multi-Paradigm Design available in pdf form here - https://tobeagile.com/wp-content/uploads/2011/12/CoplienThes...

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

#285

Earlier quoted context omitted.

Yes, I know Go's structs are similar to C in terms of syntax, but does the Go compiler guarantee the same bitwise layout for its data structures? Most GC languages add metadata to the data structures to track GC status, and this changes both the memory layout and the word alignment, which then sometimes forces the language to add extra padding to maintain alignment. And this nests as you put one struct inside another…

> does the Go compiler guarantee the same bitwise layout for its data structures It probably won't be fully 1:1 with C, but it's good enough that you can write code like this and it works: https://github.com/fsnotify/fsnotify/blob/main/backend_inoti... (unix.InotifyEvent is just a Go struct: https://pkg.go.dev/golang.org/x/sys/unix#InotifyEvent ) > Now you have "fat arrays" and "fat structs", so instead of grabbing a…

> Go GC uses a separate memory region to track GC metadata. It does not embed this information into structs, arrays, etc, directly.

I didn't know this, thank you. That's a solid approach.

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

#286
post #202

Earlier quoted context omitted.

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

Most operating systems written in C have it all over the place. Drivers, and extension points for userspace.

yes, but not soo much as my production C++. I know that that's our choice, but I underline the difference between C and C++ here

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

#287
post #282
post #133

Earlier quoted context omitted.

original codebase

If I may ask, how did you end up getting access to the code base? And what are you doing with it?

ravensoft open sourced it in 2013 ish and promptly removed it because they accidentally included a bundled lib but i believe it was then re-added. theres quite a few repos that have it cloned. https://github.com/jedis/jediacademy

what am i up to with it? creating hardened vanilla base servers (no mods) and ensuring it gets compiled in a way that doesnt impact lightsaber combat. everyone has failed to do this for 22+ years because there's lots of subfactions in this game who fail to prioritize this as they have other priorities. tons of people who enjoy the prospect of modding the game or making it something different but the tiny remaining competitive player base has only ever needed the base game and what shipped by ravensoft in 2003. generally the guys who are competitive players arent.. coders. the game is ultra sensitive to mathematical FPU differences and virtually all recompiles of the game in the past decades completely failed to guard this, so every game mod and attempt at creating something better hasn't stuck for competitive players _except_ for something called ybeproxy which was an attempt to hook the original game engine binary and add some security/anticheat layer.. this was the best attempt to date but it still negatively impacts the fragile lightsaber mechanics.

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

#288
post #287
post #282

Earlier quoted context omitted.

If I may ask, how did you end up getting access to the code base? And what are you doing with it?

ravensoft open sourced it in 2013 ish and promptly removed it because they accidentally included a bundled lib but i believe it was then re-added. theres quite a few repos that have it cloned. https://github.com/jedis/jediacademy what am i up to with it? creating hardened vanilla base servers (no mods) and ensuring it gets compiled in a way that doesnt impact lightsaber combat. everyone has failed to do this for 22+…

That's so cool! I didn't know they open sourced it. Is your work also open? And how do you check that the frames don't change?

I love seeing people try to revive old games and improve them for players. I've made a couple of contributions to VCMI, an open source implementation of heroes of might and magic 3 that I used to play as a kid and it's so rewarding seeing people use those.

Post reply on HN