logoalt Hacker News

dxuhyesterday at 11:49 AM1 replyview on HN

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.


Replies

roflcopter69yesterday at 12:02 PM

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?

show 1 reply