diff --git a/c_vs_cpp.md b/c_vs_cpp.md index 66588da..f77a262 100644 --- a/c_vs_cpp.md +++ b/c_vs_cpp.md @@ -8,22 +8,27 @@ There are good reasons for using both languages: ✅ relatively low-level language ✅ much simpler language (no classes, templates, ...) ✅ portable to a wide variety of systems +✅ only does what you say +✅ easy to mix with other languages ## Reasons To Use C++ ?inline ✅ lots of helpful abstractions (classes, templates, ...) ✅ feature-rich language (function overloads, `constexpr`, ...) ✅ extensive standard library +✅ stricter syntax +✅ RAII prevents resource leaks ## 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. +C++ mostly benefits from its robust standard library, reducing naïve DIY algorithms and +boilerplate significantly. It also uses an *exponentially* more efficient string representation +than C. +However, C++ can also hide slow tasks (e.g. allocations, large copies, exceptions, and RTTI +lookups) behind seemingly innocent code, all of which would be obvious in C. ## Conclusion Both languages can be equally fast, choose the right language for your job, and the language you enjoy working in. \ No newline at end of file