There is one feature of C99 that's absent from C++ and that potentially gives significant speed gains in heavy number-crunching code, and that is keyword restrict
. If you can use a C++ compiler that supports it, then you have an extra tool in the kit when it comes to optimizing. It's only a potential gain, though: sufficient inlining can allow the same optimizations as restrict
and more. It also has nothing to do with memory allocation.
If the author of the code can demonstrate a performance difference between C and C++ code allocating a 4-16GB array, then (a) I'm surprised, but OK, there's a difference, and (b) how many times is the program going to allocate such large arrays? Is your program actually going to spend a significant amount of its time allocating memory, or is it spending most of its time accessing memory and doing computations? It takes a long time to actually do anything with a 4GB array, compared with the time it took to allocate, and that means you should be worried about the performance of "anything", not the performance of allocation. Sprinters care a lot how quickly they get off the blocks. Marathon runners, not so much.
You also have to be careful how you benchmark. You should be comparing for example malloc(size)
against new char[size]
. If you test malloc(size)
against new char[size]()
then it's an unfair comparison since the latter sets the memory to 0 and the former doesn't. Compare against calloc
instead, but also note that malloc
and calloc
are both available from C++ in the (unlikely) event that they do prove measurably faster.
Ultimately, though, if the author "owns" or started the project, and prefers to write in C rather than C++, then he shouldn't justify that decision with probably-spurious performance claims, he should justify it by saying "I prefer C, and that's what I'm using". Usually when someone makes a claim like this about language performance, and it turns out on testing not to be true, you discover that performance is not the real reason for the language preference. Proving the claim false will not actually cause the author of this project to suddenly start liking C++.