edo subtle subtitle

Why I prefer C over any other programming language.

We can all acknowledge that the C programming language (meant as C89, here and in the rest of this text) has been successful and influential. The C89 standard is more than 30 years old (while the first occurrence of C dates back more than 50 years ago, in 1972), yet people still use it to write programs and libraries to this day.

Most command-line utilities shipped with Unix-like operating systems are usually written in C. Not only those, but most operating system kernels and high-performance libraries as well, including math and machine learning libraries such as Torch (and consequently PyTorch), Pandas, and NumPy. Even the implementation of some of the most commonly used low-level interfaces, such as OpenCL, OpenGL, and Vulkan, are written in C. And if that wasn't enough to impress you, C is often used to write database servers as well, like Microsoft SQL Server, MariaDB, SQLite, PostgreSQL, IBM Db2, and Oracle Database.

C has its downsides, like every other language. Many people and companies around the world tried to solve those flaws and created new programming languages, but none of those attempts has completely replaced C yet. If those flaws are so bad, there must be a reason why C is still around. To refresh your memory, here is a list of the downsides I'm talking about.

With so many issues, you may think that writing programs or libraries is impossible. Or maybe it is possible but the effort put into it exceeds the result. If you considered learning C before reading this article, now you may feel like it's not worth it. Yet you see a lot of people who know C and use it like any other programming language. So you ask yourself, "What are the advantages?". There are many.

So not only you do learn more about how your hardware works, but you also have more control over the execution of your programs, especially how much memory they allocate and how they use it. In addition, your programs generally take less space on disk and run faster, because they only contain what they strictly need and nothing more.

Every language has its use case, as some readers might say. For example, in C it is easy to communicate with low-level interfaces and write efficient code, but it's arguably awful when it comes to web programming. It's also true that C programs usually require more time and effort to be developed and they end up being longer than the same programs written in most other languages. Not only that, but they expose low-level details which often distract programmers from the core logic of the program. Despite all that, I still enjoy writing C, because all those issues are the result of its simplicity-based philosophy, and trying to fix them results in either less control over your code or more syntax elements and rules, which often lead to other issues.

Not everybody knows but C has dialects outside of its standards. One of them is the Plan 9 C dialect (it does not have an official name, so everybody calls it that way), which has improved the C89 standard in many ways. The greatest improvement is a bigger, more comprehensive standard library which also simplifies some tasks and functions that were a headache to work with, networking for example. The language and system libraries are so blended and work so well together that it is not possible to tell where the language ends and the system begins. However, Plan 9 is a topic that needs a separate article to be properly discussed.

Overall, although writing C code requires some attention for low-level details and it's easy to generate segmentation faults, it offers a lot of freedom and it's a very flexible programming language. Along with those, C also provides incredible efficiency and just enough abstraction over Assembly. For serious projects, I would not exchange C with any other programming language.


Last change: Apr 22 2024 (time in GMT, if present)