Wednesday, October 14, 2020

The Similarities Between Writing and Coding

In the past, our ancestors had to communicate knowledge face-to-face, and the quality of information passed through oral communication was uneven, depending on the skills of both the sender and the receiver. Spoken communication is also constrained by time and space. However, with the invention of writing and paper, the transmission of knowledge exploded. “Speaking” is instant and inexpensive to produce, but writing forces a deeper consideration of how to express the information. While speaking doesn’t require deep reflection, writing often makes us pause and think more carefully, possibly due to the lasting nature of writing compared to the fleeting nature of speech. From both a production and consumption standpoint, written communication has the advantage that we can reflect on it multiple times before it’s absorbed, unlike spoken words which often fade away quickly.

Today, the world has changed significantly. With the rise of platforms like YouTube, an enormous amount of information is available in video form. I, too, have learned a lot through videos, especially those that visualize a series of topics, giving me a comprehensive understanding of things I hadn’t encountered before. Still, I prefer reading. Reading allows me to quickly find the exact points I need and helps me solidify the structure of knowledge in my mind. Writing also helps me organize complex thoughts. Since high school, I’ve consistently written about what I see and think in daily life. Although I’m not a particularly great writer, I’ve been writing for many years. Recently, as my life has centered around software development, I’ve found that writing and coding have some interesting similarities.

The More You Write or Code, the Better You Get

The most certain and perhaps only way to get better at something is to do it repeatedly. Whether it’s coding or writing, the more you do it, the better you become. It’s easy to ask, "If I've been writing for so long, why is my writing still not great?" But even with my own case, and after observing colleagues over the years, I can confirm that consistent practice leads to improvement. Of course, simple repetition helps, but paying attention to improving the quality of what you do makes a significant difference in progress.

Long Sentences are Hard to Read

Long sentences or paragraphs can tire out the reader. Usually, a paragraph maintains its coherence until its conclusion, but as the paragraph gets longer, it becomes harder to hold the context in our minds. Initially, the brain can handle the cognitive load, but as it increases, mental energy depletes, reducing concentration and causing fatigue. The same applies to coding. If a function spans too many lines, it becomes hard to follow. Unlike writing, where you can look back to clarify meaning, coding often requires navigating through multiple functions, which can be mentally exhausting.

It Becomes Cleaner When You Show It to Others

When writing just for yourself, you may not pay much attention to perfection. However, when others are going to read it, you naturally refine it multiple times. The same happens in coding. You clean up your code when preparing it for review. In the process of preparing for a code review, the code often becomes much more organized, and this preparation is akin to editing in writing. Code reviews provide an opportunity for feedback and improve code quality, but the act of preparing for one also enhances the code.

The Overall Structure of Writing is Important

While choosing the right words, crafting good sentences, and organizing well-structured paragraphs are essential, the overall structure of a piece is critical too. No matter how beautiful a short phrase is, if the overall organization is lacking, it becomes unpleasant to read. The same goes for coding: each line of code may be well written, but if the overall structure is disorganized, the code becomes hard to follow. A well-organized codebase, just like a well-organized article, helps guide everyone involved in the project without needing additional instructions.

Readable Writing is Better

Some experts mistakenly believe that the more knowledge they have, the more complex their language needs to be. I’ve encountered this in the legal field, where legal documents often feel intentionally difficult to understand. When I studied law in college, I felt that these legal writings were designed in such a way that they were not meant to be easily understood. After all, law is something everyone is supposed to follow, so why make it so hard to understand? Fortunately, there are ongoing efforts to simplify legal language. I believe this trend should extend to all fields. In fact, the more specialized a field is, the more important it is to make the information accessible to everyone. If you can’t explain something simply, you’re not a true expert. The same applies to coding: knowing a lot but writing unreadable code doesn’t make you a good programmer. Both writing and coding aim to communicate clearly and effectively with humans.

The Key Similarity Between Writing and Coding

In both writing and coding, the most important thing is to consider how your content will be used. Whether you are writing or coding, your work needs to serve its intended purpose and be clear to the reader or user. The key to improving both is consistent practice, clarity, and understanding how your work fits into a broader context.