Why Writing Code in C Will Make You A Better Programmer

Amongst programmers, it is common knowledge that there are stark differences between languages. However, it is less commonly known that these distinctions between languages can actually affect one’s coding performance. Furthermore, there are specific languages, such as C, that simply encourage you to write better code. Many new developers seem to prefer Java and Python since these languages seemingly have the shallowest learning curves. However, beyond picking up the basic principles of computer science, these languages can actually be a hinderance for developers.

There are a few reasons why this is the case. The first, and most notable, is bloat. Bloat is where a language provides the developer an excess of resources at the price of program performance. For instance, Java and Python have a built in tool that is referred to as the “garbage collector.” This prevents developers from ever really having to worry about how memory intensive their code is, except for extreme cases. In general, any memory that was allocated to assist with the execution of a program will be whisked away by the garbage collector, preventing your code from filling your system’s memory.

To many, this likely sounds like an asset instead of a hinderance. However, preventing developers from concerning themselves with memory allocation and consumption leads to unimaginative code. Essentially, the garbage collector gives Python and Java developers the ability to write worse code at no cost. C is a language that requires precise and efficient use of memory, requiring developers to free all of their allocated memory at the end of a program’s execution. This forces C developers to manage their limited resources more wisely, ultimately leading to craftier, leaner, more efficient solutions.

Another instance of bloat in languages like Java and Python is the wealth of assets at one’s disposal. With Python especially, it seems like any problem a developer may have, there is already a library to solve it. This limits the amount of problem solving a developer has to do to reach a solution. Another effect of this is what programmers refer to as “dependency hell.” According to Wikipedia, this is where one’s coding project requires software packages which have dependencies on specific versions of other software packages. Navigating out of dependency hell can be time consuming and monotonous, and in no way encourages critical thinking or good programming practices.

C’s lack of bloat is one of the reasons it is one of the fastest programming languages in existence. Developers working on small projects may not notice the performance difference due to the lack of operations required to execute their code. However, Medium author named Peter Xie found that C runs 45x faster than Python. When working on a large-scale system, this performance boost is certainly noticeable.

Furthermore, Java and Python do not encourage developers to familiarize themselves with their machines. This is because Python, and kind-of Java, are what is called interpreted languages. Interpreted languages are languages where one’s code is not compiled into machine code locally. Rather, code written in these languages are read and executed by a virtual machine.

It is worth noting that both Java and Python have their places in the coding industry. For example, there are many web applications that were built with a Java backend, and many statistical models that are powered by Python. C is not a language that is exceptionally good at either of these tasks. Rather, C is arguably the best language for writing low-level software, such as device drivers and operating systems.

I believe it is this distinction that prevents many new developers from learning C. From general observation of my peers, not many computer science students are very eager to develop device drivers. C is not a flashy language and is not frequently used in the most desired tech jobs, such as data science. However, C is integral to the history of computer science and is still an incredibly prevalent language, even roughly 50 years after its creation.

Writing code in C is hard. However, this is what makes it so rewarding. It is a language that encourages the developer to think outside the box, learn more about his/her computer, and ultimately produce better code. While it is not the ideal language for everyone, I strongly encourage all new developers to attempt building something in C. Doing so will teach you about how memory is stored in a system, how strings are stored, and much more. Upon completing a project in C, I can guarantee that you will be a much more knowledgable, efficient programmer.

Here are some cool project ideas for new C developers:

  • A password manager that encrypts your passwords

For more advanced developers, I highly suggest trying these projects:

  • A gameboy emulator

I hope this helps inspire some of you to check out C. Happy hacking!

Programmer | Investor | Student | Reader

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store