upvote
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.

reply
Thanks for the reply!

> I quite like modern C++, so I really tried to make it work for gamedev, but I think you can't really do it.

What exactly do you mean? What parts of modern C++ did not work for you?

> You can use all the modern C++ features that are not in the standard library though!

> I just decided to not use any of the C++ standard library (I just use a few C headers)

So what do you do with C++ that C alone couldn't do?

reply
I think the standard library is good, but if you pull in ANY of it's headers you add a couple hundred milliseconds to every translation unit. So when making games (and only then), I avoid the standard library.

What I do like and use is overloading, references, templates, concepts, lambdas, enum classes, user defined literals, constexpr, operator overloading for math (!), little syntax stuff like structured binding declarations, "auto" and range based for. I also made my own little fmt (like https://riki.house/fmt). C++ is a much nicer language than C imo, even without the standard library.

reply
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
reply
Thanks for the Lua bindings suggestion!

It's just that I quite dislike using such a scripting language. It's personal preference, for sure, but here's a bit more context https://news.ycombinator.com/item?id=47220602

reply
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.
reply
> C++ is really not very amenable to this because every change to the contents of a class messes up your entire memory layout

I think even `dotnet watch` at some point nopes out when you change too much. I think they call it "rude edit" and ask you to completely restart the program in that case. So I don't expect every possible C++ edit to be manageable by hot reload. But changing a few if conditions or constants should be fine or not?

I'm more and more questioning scripting languages in games. What are the main reasons to use something like Lua? I think it's having not to rebuild the engine, no compile times, changing stuff while the game is running and being more accessible to non-programmers. But I think it's rather infuriating, all those points could be less relevant if the tooling for "real" programming languages was better. And with coding agents becoming more wide-spread I guess accessibility to non-programmers also becomes less of a point. I guess it's just my personal dislike for scripting languages in games, but really, it would be so much nicer imo if there was only need for one language that does it all. But seems like a difficult thing to achieve.

reply
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.
reply
.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++.

reply
Oh thanks, that looks very intriguing! The maintainer seems to be a Microsoft employee so there's that? I wonder though, is this a niche hidden gem or really something that more people should consider using? Also, what about compatibility with platforms like Android, iOS or consoles? That'd be very important for gamedev.
reply
[dead]
reply