The act of writing and coding share some remarkable similarities and differences. By understanding the how they resemble and differ from each other, we might be able to transfer our skills between the two disciplines, and improve as developers and writers.
On the surface, writing and coding appear quite foreign to each other because their contents are radically different. A writing might contain arguments, or explanations. A software often contain procedures for solving a problem.
However, on a deeper level, writings and software are quite alike in that they are both encodings of thought processes according to a set of well defined grammar. From this observation, we can start discovering some intriguing similarities and differences between writing and coding.
Encapsulation of Thoughts
First of all, good writing and good code both encapsulate core thoughts into modules. A code is easy to understand and maintain when its parts are well modularized according to their responsibilities. A writing is easier to follow if it divvies up ideas into coherent groups.
For instance, developers often come up with a pipeline of modules to solve problems such as optical character recognition (OCR). OCR solves a complex machine learning problem of recognizing texts from a picture. It would be hard to develop a solution without a pipeline of clearly separate modules.
OCR will recognize texts such as “Lula B’s Antique Mall” from the picture
Three modules might be at play in a typical photo OCR pipeline. There might be one to detect the area in which texts appear, one to segment the texts into characters, and one to recognize the individual characters. They have different responsibilities and interact with one another to solve a problem.
Paragraphs in a good writing are similar to the modules in a machine learning pipeline. Each paragraph encapsulates a central idea, usually represented by a topic sentence. Readers are able to understand the thought process of the writer by following paragraphs with clear, and well-encapsulated arguments.
Just as modules in a machine learning pipeline work together to solve a problem, paragraphs work together to represent a certain thought process. When put together by a skillful wordsmith, paragraphs form an idea more complex than the sum of the individual ideas they each encapsulate.
At the conclusion of a writing, an author’s ideas often end up becoming more complicated than they used to be. Likewise, a program become more complex in structure as developers add more features and refactor the code.
Both writings and programs tend to grow more abstract because, as we previously observed, their modularized parts collaborate with one another to achieve a shared goal. When modules work together, they can result in thoughts more complex than those represented individually by the modules themselves.
For instance, an idea in writings can take a leap from one paragraph to the next to assume a more complex form. Similarly, when modules in a program hide away low level implementation details, developers can produce more complex solutions by reasoning on a higher level.
Yet, abstraction is also a source of major difference between writing and coding. The benefits of abstraction are not the same for both of them. Abstraction of thoughts is almost always beneficial for writings but not always so for programs.
In a program, abstraction actually comes at a cost of increased mental overhead of developers. A deep abstraction stack makes it all the more difficult to reason about a program, let alone iterate on it. As Sandi Metz argued, “duplication is far cheaper than the wrong abstraction”.
On the other hand, the power of writing lies in the evolution of ideas into more abstract and complex forms. In other words, abstraction of ideas is the bread and butter of writings. A good writing can influence the minds of many, and I suspect that writing owes such power to the kind of abstraction that we find in software.
For instance, Thoreau’s ideas in Civil Disobedience have influenced many leaders including Gandhi and MLK. Thoreau must have captured his core arguments using encapsulations and developed them using abstractions. After all these years, his writing still resonates profoundly with the readers.
Software and writings are more similar and different than we might think. Both encapsulate core ideas into coherent groups, and have a propensity to grow more abstract as those modules work together. Such tendency toward abstractions is beneficial for writings but might be harmful for software.
It is interesting that both software and writings encode our thought processes, but abstraction can be harmful for one, and infinitely powerful for another. It seems that the wild evolution of ideas make pen stronger than swords, but not software.
Writing a good essay is quite akin to developing a good software. The only major difference is that, as writers, we can let our inner bandit to freely shape our ideas in the most unpredictable, and mischievous ways. But as developers, we need to ignore him at times.