Is It Worth Learning C?

Learning C Programming Language3.jpg

Having finished the C programming portion of CS50 (HarvardX’s intro to CS course) I thought it would be a good time to reflect on what I learned and if it was worth the time.

To get the big reveal out of the way: I think getting to grips with C as a new learner in computer science / programming is a great idea! However if someone is looking to take the first step on their path to learn coding I would not recommend they start with C. As great as the language is, it can also easily become a deep pit of nitty-gritty problems where coding passion goes to die.

My recommendation for someone looking to get their start with coding would be to begin with a more forgiving language like Python. One which abstracts away a lot of the difficulties that come with C (looking at you memory allocation).

C Programming Slaps Meme.png

Having already spent quite a bit of time learning Python, C was a lot less daunting. One thing you realise when you start learning a second programming language is just how many transferable concepts there are. For instance I remember when I first came across nested for loops in Python I really struggled to get my head around them. Having never done any prior coding these loops were an alien concept to me! Of course now that I chuck them into my scripts like confetti at a wedding they don’t seem so hard. However I do think learning these types of core concepts in Python first will lead to a much easier time when it comes to coding in C. There is so much else to get grips with when it comes to C that understanding essential programming ideas prior to learning it is really going to help. It will give you a great foundation to go into C with an eye for the differences and pick up on the reasons they are necessary within the language.


Will C Teach You Anything Useful?

“I’m never going to use C so why do I need to learn it?” This is a question I definitely had going into CS50’s C focused weeks. Luckily I actually came out with my answer: C will teach you about computers on a lower level and help you to understand the why of coding not just the how to.

Coding in C will give you a greater understanding of how computers store memory, what actually happens when you assign variables, manipulating data structures and how to write fast clean code. Just like concepts you learn in Python will make C easier to understand, concepts learned in C will level up your knowledge about other programming languages and make you a better coder.

For instance I remember learning about Lists and Tuples in Python, the main difference between the two being that Tuples are like Lists but immutable (they can’t be altered once created) and therefore Tuples are more efficient. At the time I took the “Tuples are more efficient” fact at face value as I came across it somewhat often but it was never accompanied by an explanation. It wasn’t until I started learning about data structures in C that I realised just why that is the case.

When you create a Tuple the program knows that the data within the Tuple is immutable. Nothing can be changed or appended to the Tuple. Therefore the Tuple can be stored in memory as one long chunk. It doesn’t matter if there is different data stored either side of this Tuple chunk because the Tuple will never require any more or less memory space. A List on the other hand will need to take into account that something may be appended or removed and so it cannot be stored as one finite chunk of memory in the computer. As such Lists will require more memory to store and because of this in Python they take longer to create (as more memory has to be assigned) making them both slower and less memory efficient than Tuples. In C you learn all about this when you start dealing with data structures.

Don’t just learn how. Know why.

Don’t just learn how. Know why.

This is just one example of many that have helped me gain a greater understanding and appreciation of what is going on under the hood when I code in Python. C forces you to think efficiently and requires you understand what your code will do on a lower level. This thought process and understanding will make you a better coder when you move back to a language with more abstraction and less lower level thinking.

I am actually very glad for the time I spent learning C. It has made me a better coder overall and the knowledge it gives you is transferable to so many areas. I think as I continue on this journey to pursue a career in DevOps the value of my time spent learning C will only become more apparent.

Previous
Previous

Automation at Work: Windows File Sorting

Next
Next

Zero to DevOps: The Road Ahead