The biggest reason to write in C over C++ is simplicity and higher level of control over algorithms and data structures. Portability is another reason though.
The biggest reason to write in C over C++ is simplicity and higher level of control over algorithms and data structures. Portability is another reason though.
For simple functions, templates are usually always a pure win. For example, C qsort is horrible. Function pointer to a otherwise so inlinable small sort function is always going to get beaten by C++ template based sort.
But if each iteration of loop needs to fetch 10 kB of instructions because of specialized separately compiled templated forms, suddenly pointers win again. It can also invalidate TLB, branch predictor, etc. caches.
But most cases templates are a win. Just remember microbenchmarking can really mislead here, if the program as whole has an icache bottleneck as a consequence.