eli5: How is C still the fastest mainstream language?

738 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

There are 2 major factors.

First is that C is about as close as you can get to assembly without writing assembly. The compiled binary is basically assembly. What you write is for the most part directly translated into assembly. You can’t really get “faster” when you don’t add anything on top of the fastest thing around. Other modern languages add bells and whistles that will add overhead to the final program. Probably one of the common ones is garbage collection.

The second is compiler level optimizations. C, because of how long it has been around, has compilers that are incredibly good at optimization. Companies like Intel and AMD have large teams dedicated to the C compiler. This is incredibly complicated and even small changes can have massive impacts on the performance of the final program. These optimizations will often transform the logic you wrote in C into a series of assembly instructions that can be very convoluted to understand. But are necessary for performance be it for the purposes of speculative code execution or L1/L2 caching or something else.

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