Monday 16 January 2017

An Affection for C



The first programming language that I worked with in a professional capacity was C.
I'd previously been taught C++ at university but never really fully grasped the methodology or gained an understanding of the nuances of software development.
Moving down a level and learning what many would consider a more basic programming language opened my eyes to what was underlying many of concepts that I'd struggled to get to grips with.
This has lead me to believe that learning a language like C is a valuable exercise for all that want to pursue a career in software engineering if only to understand how this set us on the path that has delivered all of the modern programming languages that we now know and love.
From Small Acorns
When comparing C to many modern languages it can seem that a C programmer has a smaller toolbox at his or her disposable. Quite often some of the more powerful tools available to us in modern languages can seem like magic that we don't always understand but that is making our lives easier.
Learning a language like C where you may only have basic flow control statements like if or else-if, or basic looping such as for and while not only gives you an appreciation for what can be done with these relatively humble constructs but will build your skill in applying them so as to remove your dependency on the crutch that more modern keywords can represent.
While these newer more advanced statements don't exist for no reason and have a time and place it doesn't do any harm to brush up on your skills for applying the tools that used to represent the entirety of what a programmer had available to them.
You'll be surprised how often you can find a more efficient, elegant or understandable solution by going back to basics.
Demystifying the Magic
There are certain aspects of programming that produce an unsettling feeling in many developers, one of those areas is memory management. We are more than happy to leave this minefield up to the garbage collector provided by our shiny modern runtime.
I would never suggest that anyone attempt to second guess the garbage collector or try to play a role in managing memory in a modern language but it doesn't do any harm to gain some appreciation for the challenges involved in writing such a sub-system.
With a low level language such as C where you are closer to the metal you become responsible for allocation and cleaning up of resources and you are introduced to pointers, a term that makes many a developer shudder.
Over coming this fear to understand the mechanics of when memory needs to be allocated, how it is addressed and how you know when to clean it up will undoubtedly enable you to write more efficient and memory aware software.
Understanding Your Roots
The fundamentals of writing good code haven't changed all that much across the years.
The tools available to us may have advanced and the power of the machinery we have at our disposal may have increased but the qualities that identify something as being good or bad have remained surprisingly consistent.
To this end the languages and frameworks we have developed have attempted to place these values at their heart and to make it more natural to follow them without trying.
The scares you acquire when programming in a language that gives you your head and allows you to shoot your foot off will help you gain a new appreciation for why these principles are held in such high esteem and why modern tooling has been driven in the direction it has.
With any subject or discipline its important to understand its history, C represents a seminal moment in software engineering. Its influence can be seen in many languages being described as having C style syntax and applying similar structure and form.
While C is still in wide spread use today the majority of professional developers will likely as not come into contact with it. I would urge anyone who wants to become a student of this subject to consider going back to its roots and seeing how things used to be done.

No comments:

Post a Comment