UHG
Search
Close this search box.

You See, C is Still the King in the Sea of Languages

Despite the drawbacks, the world still benefits from C even though higher-level languages are more commonly used

Share

In a recent experiment, TalentNeuron’s machine learning lead, Andriy Burkov, optimised a Python-based text processing task by rewriting it in C. With the help of AI assistant Claude, the Python implementation took 63 minutes, while the C version completed the task in just 2.3 minutes, showcasing a significant performance boost.

With all the new “modern” languages out today, how is C still believed to be the fastest and “closest to the machine”? 

C Over Python

While Python is renowned for its simplicity and ease of use, it is also known for its slower execution times. C, on the other hand, is renowned for its speed. This is primarily because it can be compiled straight into assembly or machine code before being executed.

C programs execute quickly primarily because they are translated into machine code prior to execution. Since machine code is the language that computers comprehend directly, no additional translation is required when the program is operating. 

Pre-translation prevents the needless extra steps that can impede the speed of programs written in other languages that may require real-time translation into machine code. C programs can operate substantially more quickly by omitting this translation stage during execution.

Thanks to its portability and effectiveness, “C is frequently used to implement compilers, libraries, and interpreters for other programming languages”.  The main implementations of interpreted languages, such as PHP, Python, and Ruby, are written in C. 

Another factor that distinguishes C from other languages is it is a smaller, simpler language. In a discussion on Reddit, a developer named Blargh said, “It hasn’t changed very much in 30 years. Its limitations are usually tolerable for the problem domain it was designed for.”

There isn’t Much That’s Special About C

Having said that, many developers believe speed is natural to C and not a unique thing. In a Stack Overflow discussion, developer 

Sebastian Karlsson pointed out that C lacks features like garbage collection, dynamic typing and other facilities. 

“Newer languages have all these, hence there is additional processing overhead which will degrade the performance of the application,” he added.

If anything, that is actually a minus point for C. “These require programmers to manually manage memory allocation and deal with static typing,” said Karlsson.

In another Reddit discussion, a developer pointed out the same problem. “If you don’t mind that a program might behave unpredictably when given bad inputs, a C program might run faster because it doesn’t always check for things like whether you’re accessing an array outside its bounds. This lack of checks can make C code run faster than code in other languages that do include these safety checks.”

However, if you need your program to be very secure and free from exploits like arbitrary code execution, you would need to add extra safety checks in C, making it cumbersome.

For some, Rust presents a compelling alternative to C, particularly for projects that prioritise safety and maintainability without sacrificing performance. So much so that Microsoft CTO Mark Russinovich said, “It’s time to halt starting any new projects in C/C++ and use Rust for those scenarios where a non-GC language is required. For the sake of security and reliability, the industry should declare those languages as deprecated.”

C is Still the King

Despite the drawbacks, the world still benefits from C even though higher-level languages are more commonly used. A majority of the work on Microsoft’s Windows kernel is done in C, however some are done in assembly languages. 

With almost 85% of the market share, the most popular operating system in the world has been running on a C-written kernel for many years. 

Additionally, Linux is primarily written in C, with some assembly code. The Linux kernel is used by roughly 97% of the 500 most potent supercomputers in the world. 
The kernels for iOS, Android, and Windows Phone are also written in C. These are merely versions of the current Windows, Linux, and macOS kernels for mobile devices. Thus, the C kernel powers the devices you use on a daily basis.

📣 Want to advertise in AIM? Book here

Picture of Anshul Vipat

Anshul Vipat

Anshul Vipat is a tech aficionado, enthusiastic about the latest innovations in the digital world. He also holds keen interest in traveling, exploring and cooking
Related Posts
19th - 23rd Aug 2024
Generative AI Crash Course for Non-Techies
Upcoming Large format Conference
Sep 25-27, 2024 | 📍 Bangalore, India
Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

Flagship Events

Rising 2024 | DE&I in Tech Summit
April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore
Data Engineering Summit 2024
May 30 and 31, 2024 | 📍 Bangalore, India
MachineCon USA 2024
26 July 2024 | 583 Park Avenue, New York
MachineCon GCC Summit 2024
June 28 2024 | 📍Bangalore, India
Cypher USA 2024
Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA
Cypher India 2024
September 25-27, 2024 | 📍Bangalore, India
discord-icon
AI Forum for India
Our Discord Community for AI Ecosystem, In collaboration with NVIDIA.