| ▲ | roflcopter69 11 hours ago | ||||||||||||||||
I see `dotnet watch` being mentioned for code hot reload which is such a great feature for quickly iterating on a game. Not having to restart the whole game just because one has changed a few if statements and values really helps staying in the flow. But I'm still not too enthusiastic about having GC in C# which is why ideally I'd like to start making a small 2D game just with SDL3 and C++ but how could I get this nice hot reload workflow there? I don't have the money to pay for expensive proprietary tools like https://liveplusplus.tech so what can I do? I guess there's the "game as dynamic library" trick from Handmade Hero (see https://www.youtube.com/shorts/seWAIURXxH0) so maybe that would work good enough? Maybe https://github.com/fungos/cr would do most of what's needed here? Also, how does one even do modern C++ these days? Is it possible to have big C++ code bases that still compile fast these days? Is CMake 4 good™ now? Are modules really there yet? I rely on clangd as LSP for working with C++ but I read that clangd still fundamentally struggles with C++ modules https://chuanqixu9.github.io/c++/2025/12/03/Clangd-support-f... and it's so bad that there has even been some effort going into making a new C++ LSP https://github.com/clice-io/clice | |||||||||||||||||
| ▲ | dxuh 11 hours ago | parent | next [-] | ||||||||||||||||
I quite like modern C++, so I really tried to make it work for gamedev, but I think you can't really do it. You can use all the modern C++ features that are not in the standard library though! I am working on a little game the last few months and after a while I just decided to not use any of the C++ standard library (I just use a few C headers) and make my own Vector, Array, Span, String, FlatMap. And using those the game compiles really fast. If I touch a header that is included almost everywhere (the big game state struct), I can compile and link (mold) in ~300ms. If I touch player.cpp I compile in 250ms. That is mostly good enough for me, but I am thinking about the "game code as dynamic library" thing myself. I always thought CMake was good enough. I use FetchContent for all external dependencies and git submodules + add_directory for all internal dependencies. It took me a while to figure out that this was the simplest thing that works reliably though. I have used vcpkg and conan extensively and have completely given up on them. I don't use C++ modules, because afaik they are still mostly broken. Without modules clangd works wonderfully and has been working wonderfully for a few years. I really, really like it. I think it can be done! I am missing reflection though, but if I would really want to use it, I'd probably just use clang -ast-dump instead of the new reflection functionality. | |||||||||||||||||
| |||||||||||||||||
| ▲ | spacechild1 4 hours ago | parent | prev | next [-] | ||||||||||||||||
If you implement the actual game logic in a scripting language like Lua, hot reloading becomes trivial. sol2 is a really awesome Lua binding library for C++: https://github.com/ThePhD/sol2 | |||||||||||||||||
| |||||||||||||||||
| ▲ | pjc50 9 hours ago | parent | prev | next [-] | ||||||||||||||||
C++ is really not very amenable to this because every change to the contents of a class messes up your entire memory layout. "game as DLL" is definitely a viable solution to that, but so is "game in scripting engine": many games delegate a lot of their mechanics to e.g. Lua precisely because it's so easy to tweak in-engine if you just want to change a bonus from 5% to 10% and so on. | |||||||||||||||||
| |||||||||||||||||
| ▲ | Anonyneko 8 hours ago | parent | prev | next [-] | ||||||||||||||||
You could also offload potentially GC-heavy parts to C++ and write the rest in C#. Depends on the game, but usually most of the game logic that you'll be constantly tinkering with doesn't require all that much memory in the first place. | |||||||||||||||||
| ▲ | neonsunset 11 hours ago | parent | prev [-] | ||||||||||||||||
.NET also now has an (amazing) alternate low-pause/effectively pauseless GC: https://github.com/VSadov/Satori Builds: https://github.com/hez2010/Satori/releases how to use? do self-contained publish (but not single file), replace 3 files in the folder with the one from Satori release you can check if it's in use with GC.GetConfigurationVariables().ContainsKey("SatoriGC") It is a far, far superior experience to touching anything C++. | |||||||||||||||||
| |||||||||||||||||