Compared to a writer, programmers have double the amount of trouble. We have to follow the rules of a machine and use perfect syntax, and at the same time satisfy the fickle needs of humans with conflicting preferences. The latter is almost impossible, because everybody hates to read other people’s code. The human side of programming is to write code like an author, by realising that you have something to say and that you have to communicate this in an understandable way to your reader.
Code = communication
Think of how you feel when you read other people’s code. I often hear people reduced to swearing as a form of self-medication when that happens. Frustration, anger and arrogance are all common reactions. Sometimes it even leads to rewriting everything . The thought of mixing your own skilfully crafted code with someone else’s is unbearable, and the lust for new and better code becomes irresistible. When it comes down to it, reading other people’s code is not a popular sport.
A good explanation of why programmers dislike reading other people’s code is conflicting preferences. There are a myriad of decisions to be made: which structures in the language to use, selecting the right functionality from the language’s libraries, which pattern to go for in the current top-ten list of buzzwords, and so on. But regardless of any choices that you may have to make, communicating with your next reader which decisions you made and why you made them is essential. If your reader understands the basis of your decisions on the first read through of your code – true, they might still disagree with you, but they will know why you made that choice and be capable of making an informed further decision on your code as a result.
To communicate in code you need to use the tools you have available. Variables, commit messages, comments: whenever you write words that are meant for human eyes, you have to become an author and start sharing information. It is tempting to be lazy, because “the law of least effort” is strong , and means you really want to write “bugfix” as a commit message and be on your merry way to fix the world’s next problem. The price of this is paid for by your readers, but you have it in you to be more considerate of your reader. There are two things on this spinning ball of dirt we call the earth that is unique to humans: we cook our food and we have theory of mind . Theory of mind is the ability to understand other people’s intentions just by looking at them. Evolutionary speaking, this happened so that we can outsmart our opponents, but also to work together. Theory of mind is what makes us evil, but it also gives us empathy. Use this empathy to resist the law of least effort. Future and wiser you will thank you, because more times than we’d like to admit that we are the reader.
THIS IS A PREVIEW. DOWNLOAD ISSUE 8 TO READ THE FULL ARTICLE.