Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 1.05 KB

c_vs_cpp.md

File metadata and controls

29 lines (23 loc) · 1.05 KB

C vs. C++: Which Is Better, Faster, ...?

Neither language is better, neither language is faster. There are good reasons for using both languages:

Reasons To Use C

?inline ✅ relatively low-level language ✅ much simpler language (no classes, templates, ...)
✅ portable to a wide variety of systems

Reasons To Use C++

?inline ✅ lots of helpful abstractions (classes, templates, ...)
✅ feature-rich language (function overloads, constexpr, ...)
✅ extensive standard library

Which Is Faster?

Neither language is inherently faster than the other. In modern compilers, the exact same optimizer is used for both languages. Certain high-level C++ features can make it easy to inadvertently write inefficient code (e.g. innocent looking code performing large copies).

One notable difference between the two languages is their standard libraries' string representation: C strings, while simple, are highly inefficient.

Conclusion

Both languages can be equally fast, choose the right language for your job, and the language you enjoy working in.