eli5: How is C still the fastest mainstream language?

756 views

I’ve heard that lots of languages come close, but how has a faster language not been created for over 50 years?

Excluding assembly.

In: 2072

19 Answers

Anonymous 0 Comments

You can’t get faster than assembly, because that’s what the CPU interprets natively.

C is basically “portable assembly”. Most of the time you can get probably 95%+ of the performance of writing things in architecture-specific assembly. And often anything large is going to end up better than humans write, because it’s very hard to write optimal assembly. So there isn’t (usually) a lot of room to improve performance. And you can easily embed ASM code right into a C program when you need to.

You could probably improve on C in various ways, but it has a HUGE amount of inertia. There are huge projects like the Linux kernel and tons of embedded systems code written in C, lots of available tooling (basically every platform ever has a C compiler), and almost every OS providing a C API to their services. And almost every programming language has a way of interfacing with C libraries, because so many things are standardized on that for interoperability. And C itself has gotten a bunch of improvements over the last 40 years. So you’d have to create something that is *so much better* than C that you’d convince everyone (or at least a large chunk of the people currently using C) to abandon a ubiquitous standard that they know works for your unproven new thing. Nobody has managed to do that. Rust is the latest contender and may actually start cutting into the systems programming niche. But we’ll see.

You are viewing 1 out of 19 answers, click here to view all answers.