We have heard programmers around us talk about C being fast, so in this article, I’ll be attempting to explain the "why".
C is fast because... it has no special features. It was designed to be as close to Machine level as possible. The only benefit being that it was readable (I know, I know, just try to imagine assembly devs using C for the first time back then).
Due to how close it is to machine language, the speed of a C program is loosely determined by the number of statements being executed.
From this, we can begin to see that C is not fast per se... other languages are just slow!
And that is because they have a higher level of abstraction to machine language than C does. That is not necessarily a bad thing since higher-level languages (like Python) provide:
- Safety checks
- Added complexity
- Error handling
- Memory management
- Automatic garbage collection
The only tradeoff being speed... or is it?
Short answer, Not really. Long answer, it is only fast when the programmer writes optimal code. And even then, there are instances where virtual machine-based languages (like Java) run faster than C. Plus, Assembly is a language too and it's faster than C.
Thanks for reading!