News for hackers. Stuff that matters.
Re:Why I Write Games in C by hellofunk on Saturday January 09, 2016 @09:54AM (#10871417)
>Recompiling and reloading parts of your game at run-time is quite easy in C.

This is cool to hear. I've never done anything like this, but it almost sounds like REPL-driven development is a possibility in C?

Re:Why I Write Games in C by adrusi on Saturday January 09, 2016 @10:10AM (#10871462)
Check out the first few episodes of Casey Muratori's Handmade Hero series where he implements an extremely simple hot code reloading system in C (actually C++, but he doesn't use almost any C++ features, certainly not vtables).
Re:Why I Write Games in C by chii on Saturday January 09, 2016 @10:59AM (#10871662)
if you don't want to watch the video, here is a basic overview tldw; of the technique:

on every run of the game loop(usually every frame), reload a dynamically linked module (dll for windows, .so for linux), which contains the actual code you want to run every frame. The function you then invoke from the module must be passed the entire block of memory allocated for the game state. You then just recompile the dll/so module when you make a change, and the game would execute the new code on the next frame. Adding new data structures is OK as long as you don't mangle an existing data structure...but because a game can expect to work with a constant block of pre-allocated memory, this actually works fine most of the time...

Re:Why I Write Games in C by hellofunk on Saturday January 09, 2016 @11:06AM (#10871696)
I assume you'd be using techniques discussed here?

http://stackoverflow.com/questions/384121/creating-a-module-...

Re:Why I Write Games in C by chii on Saturday January 09, 2016 @11:27AM (#10871772)
yes - but different OS have different ways to load dynamically linked modules, and the casey video only showed the windows method. But it's basically the same, just library calls differently named.
Re:Why I Write Games in C by je42 on Saturday January 09, 2016 @11:11AM (#10871711)
Really great feature. But it doesn't tell anything about the quality of the code.

Through out his complete series haven't seen any unittests for example.

So I my book. No unittests => crappy code.

His use of vtables is completely unrelated to the feature.

Re:Why I Write Games in C by crafn on Saturday January 09, 2016 @10:13AM (#10871475)
It's quite restricted still. For example changing datatypes during recompilation is problematic, at least if you don't destroy the instances before reloading, and re-instantiate afterwards. I don't bother to do that, because I see most of the value in things like tweaking game object logic repeatedly, which fits the restrictions nicely.