News for hackers. Stuff that matters.
Re:Why I Write Games in C (yes, C) by h0l0cube on Saturday September 21, 2019 @06:45PM (#21038358)
I worked as a games programmer for 8 years in C/C++, and spent an accumulated 2 years just doing optimisation, during the time of 6th and 7th generation consoles. Freeing resources in a deterministic manner is important for the following reasons:

FRAME RATE: having a GC collect at random frames makes for jerky rendering

SPEED: Object pools allow reuse of objects without allocing/deallocing, and can be a cache-aligned array-of-structs. Structs-of-arrays can be used for batch processing large volumes of primitives. https://en.wikipedia.org/wiki/AoS_and_SoA

RELIABILITY: This is probably applicable to the embedded realm too, but if you can't rely on virtual memory (because the console's OS/CPU doesn't support it, or once again you don't want the speed impact) then you need to be sure that allocations always succeed from a fixed pool of memory. Pre-allocated object pools, memory arenas, ring buffers etc. are a few of ways to ensure this.

There's probably a lot more, but those are the reasons that jump out at me.

Re:Why I Write Games in C (yes, C) by zemo on Saturday September 21, 2019 @06:50PM (#21038382)
you can turn off the gc in Go and run it manually. you can also write cache-aligned arrays of structs in Go if you want to. you can allocate a slab and pull from it if you want to. the existence of a GC doesn't preclude these possibilities.
Re:Why I Write Games in C (yes, C) by gameswithgo on Saturday September 21, 2019 @09:30PM (#21039054)
The existence of a GC, even when it can be turned off, does preclude a great many other possibilities, in practice. One issue which is nearly universe, and extra bad in Go, is the extra cost of FFI with C libs, which is necessary in games to talk to opengl, or sdl2, or similar.

If you aren't going to use the GC, then you open up a lot of other performance opportunities by just using a language that didn't have one in the first place.

Re:Why I Write Games in C (yes, C) by h0l0cube on Saturday September 21, 2019 @07:00PM (#21038440)
>you can turn off the gc in Go and run it manually

And if you run the GC manually, you really don't know how long it will take - read: determinism.

> you can also write cache-aligned arrays of structs in Go if you want to

Wasn't this thread about why people don't use GC, not about go? I don't remember.

If you're using an object pool, you're dodging garbage collection, as you don't need to deallocate from that pool, you could just maintain a free-list.

> you can allocate a slab and pull from it if you want to. the existence of a GC doesn't preclude these possibilities

To take it further, you could just allocate one large chunk of memory from a garbage collected allocator and use a custom allocator - you can do this with any language. But you're not using the GC then.

Re:Why I Write Games in C (yes, C) by inimino on Saturday September 21, 2019 @06:53PM (#21038398)
Why pick a language that has a feature you need to immediately turn off? Some people probably want to, but ... why?
Re:Why I Write Games in C (yes, C) by vnorilo on Saturday September 21, 2019 @10:47PM (#21039322)
Many programmers are very emotional about their language of choice, especially if it is their only one.
Re:Why I Write Games in C (yes, C) by fileeditview on Sunday September 22, 2019 @03:48AM (#21040177)
I guess you use every feature (insert any language here) offers for every program you write with it?

The answer to your question is probably: because they like the language, are productive in it, know the libraries and the feature can be turned off so it's an option.

Re:Why I Write Games in C (yes, C) by inimino on Monday September 23, 2019 @12:18AM (#21045883)
If I consistently don't use all the features, I pretty quickly start looking at simpler languages.