Question for people who know C++

Godot Version

4.7.1 mono

Question

I’m nearing the completion of the base systems of my games (in c#). And I’m wondering if it would be worth it to convert this code to C++.

My base systems so far (basically a chunking system):

It takes one number, chunkRadius, and produces map chunks that are hexagonal shaped hex grids (which is a surprisingly deep rabbit hole). There’s a lot of little parts and pieces, I’ve spent a long time building this thing, but that’s pretty much it. Arithmetic and flat arrays.

-I am using C#'s array pool to bypass the garbage collector

-I optimized all the chunk data arrays to be as small as possible using shorts and bytes

-I’ve been very careful about what I’m passing by value vs reference

-my hot loops are pretty tight. Small arrays, simple arithmetic

-minimal contact with godot’s node API.

I need someone give me the nudge to take the dive into C++ or to tell me it’s a terrible idea. I am not planning to build the whole game and c++, but possibly the base systems.

(I don’t know how to write C++)

Profile first, it may help performance and managing peculiarities but it is harder to debug. I’d say it’s better to get into a C++ GDExtension if you have a reference already built, only converting code.

Use C++ only as a last resort. If you don’t already know the language, best to avoid it here. Profile, determine bottlenecks and optimize them. There’s a lot you can do before needing to reach for C++ (better algorithms, threads, Godot’s servers, compute shaders…). You also don’t want GDExtension api to be your first encounter with that language.

I’m learning C but C++ have somewhat similar basics, i’d say it’s bad idea because C++ don’t have many things higher languages have, and have ton of lower level concepts like memory management (in short nightmare difficulty) and file structure or even slighty different rules can make it tedious, it’s better if you tried some algorithms as @normalized said

also note - if you don’t have full game or player feedback and your game isn’t terribly slow you should focus more on gameplay and completion than at optimizing something you might never need

Im going to stick with C#. from what I gather, I might be able to gain ~%20 speedup over well optimized c# but at a (most likely large) cost of time, setup, and maintenance