News for hackers. Stuff that matters.
Re:Why I Write Games in C (yes, C) by slacka on Saturday September 21, 2019 @12:59PM (#21036450)
Writing game engines in C++ without using any OOP features, makes perfect sense to me. Other than the author likes C, he failed to show me why his approach is better than yours. I found it very light on details.
Re:Why I Write Games in C (yes, C) by ncmncm on Sunday September 22, 2019 @04:36AM (#21040312)
Writing game engines in C++ without using destructors is just foolish.

If by OOP you mean virtual functions? Nobody uses that stuff much anymore, except Java refugees. (They use shared pointers, too.) But, anyplace you would use a function pointer in C, it's cleaner with a virtual function, and often faster.

Re:Why I Write Games in C (yes, C) by skohan on Sunday September 22, 2019 @05:17AM (#21040408)
> Writing game engines in C++ without using destructors is just foolish.

Why? My understanding is that in modern game dev you're mostly traversing large arenas of structured memory, and you avoid freeing individual objects like the plague.

Re:Why I Write Games in C (yes, C) by Const-me on Sunday September 22, 2019 @03:59PM (#21043566)
Memory is just one kind of resources. Games do tons of I/O, often gigabytes/second. To illustrate, any PC game has a lot of places which call GPU driver like this:

    D3D11_MAPPED_SUBRESOURCE mapped;
    context->Map( buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped );
    // Write memory address pointed by mapped.pData
    context->Unmap( buffer, 0 );
With C++ RAII, you can do something like that instead:

    MappedBuffer mapped{ buffer }
    // Write memory address pointed by mapped.pData.
    // No need to do anything else, the destructor of MappedBuffer will unmap.
Re:Why I Write Games in C (yes, C) by ncmncm on Sunday September 22, 2019 @11:16PM (#21045665)
This. Freeing memory is the least important job for destructors.