Let's Copy Each Other

02 Feb 2017

How We Learn

I learned at a young age how to translate my thoughts into speech and written language. But how did I learn to do such a thing? As much as I can ascertain, no one can reach into my consciousness and help me articulate what I am thinking into words. The answer is really quite simple. I copied the writing style and speech patterns of books and people around me until I could do it on my own. Through practice and a healthy amount of plagiarism, I began to develop my own writing style and, more importantly, how I should organize my own thoughts.

Spoiler alert, this is how everyone learns how to read and write.

Back in high school, I had to read more challenging books and plays. Things like Shakespearean plays, The Odyssey, and A Clockwork Orange. But, why was it that these books were hard for me to understand? I realize now that they were only challenging because their styles of writing so violently clashed with my own writing style. Had I learned to talk and think and write in verses like a 16th century Englishman, understanding Shakesphere’s plays would be like watching Netflix.

When we learn how to code in our first programming language, we develop using the same techniques of copying others and molding our style through practice. If learned in the absence of an external “syntax coach”, everyone’s unguided style of coding is unique to themselves. Now, take a second and ask yourself, is this a good thing? Is it a good thing that everyone has their own style of writing code? No, it is most certainly not. For the same reasons I struggled to understand Shakesphere’s works, trying to pull meaning through someone else’s coding style makes understanding code harder than it needs to be.

Coding Standards

This is where coding standards can help. Coding standards are a set of rules that help coders write similarly to other coders. By using coding standards, teams of programmers don’t have to fret with trying to learn everyone’s slightly different coding styles. This makes code more predictable in terms of its functionality, reliability, and the location of bugs. That being said, it seems like coding standards take out the creativity of coding by forcing programmers into one way of coding. Freedom is lost as programmers adhere to these standards to maintain the same coding style. Is programming an art, or is it a rigid, procedural task that requires such standards?

Coding: Art or Process?

In nearly all cases, coding is a well-defined, mechanical process that necessitates the “correct” solution. While there are many ways to solve any given problem, there will be a few solutions that stand out for their effectiveness and/or efficiency. From an engineering standpoint, effectiveness, robustness, and maintainability are top priorities in the implementation of a programming solution.

In general, a program is more correct in comparison to other solutions when it can achieve the desired result with less memory demands and/or within a shorter time frame. Take for example a simple problem that requires the sorting of one million elements. There are many sorting algorithms that a programmer could use to solve this, but some algorithms will be better in terms of their time complexity. While using bubble sort (n^2) can achieve the same result as merge sort or quick sort (n log n), the result can be achieved much faster by using the latter algorithms. For this example, if every element check took one microsecond, bubble sort would finish in roughly 10 days whereas merge and quick sort would finish in under 20 seconds. This example shows that while there may be multiple ways to solve a programming problem, some solutions are considered better than others based on their effectiveness.

The Verdict

Everyone should learn how to code by closely adhering to established coding standards. It’s one of those things that you can learn correctly the first time and never need to re-learn. The coding standard will become your natural, default programming style. If you ever need to update or change your style, doing so can be done systematically and should be minimal.

Having already learned C with no adherence to a coding style, I admit my code can get a bit messy and inconsistent. From now on I intend to stick to one style of coding to be consistent with my own work and to practice writing presentable code.