There are many similarities between programming and writing, but there are many many differences as well. My intention is to explore some of the common things from my perspective.
When it comes to clarity, both programming and writing share the same goals. They need to make it clear what the code/article is about to say.
A programmer's job is to write code that a machine can understand so that, when executed, the code does specific things as instructed. A good programmer will write code that other people (including their future-self) can understand and maintain.
A writer's job is similar. A writer must put together words so that others (including their future-self) can follow along and understand its meaning.
Both writing and programming follow a structure that allows the reader to follow and understand what is being said.
At a low-level, we can compare Functions with Paragraphs. The job of a useful Function is to do one specific thing. We may pass information into the Function. We may expect data to be returned from the Function.
A paragraph can be broken down similarly. For example, a paragraph should be relatively short and focused on one thing. When we write a paragraph, we may be passing information from a previous paragraph. Then we explain more and conclude with the idea that would potentially be used in the text that follows.
We can also look at this from a higher level. When programming, we group related functions together into a Class. When writing an article, we have a collection of Paragraphs that are all connected, each having a specific purpose.
Both developers and writers go through a process of refactoring/editing before their work should be published.
In both cases, this involves reviewing the content, breaking it down into smaller, reusable components, then making sure it is straightforward and easy to follow. We also need to ensure it is as consistent as possible. In our code, we would name our Variables and Functions consistently. When writing, we want to structure our paragraphs so they are uniform.
In both cases, when we omit the refactoring, the quality of the end product suffers. When we release code that has not been refactored, we may accumulate Technical Debt that we must pay for later. When writing, if we do not spend time editing, the quality may suffer and we may not effectively convey the message to the reader.
4) Break it down
When code becomes too long, it is best practice to break it up into smaller components. This is the same with writing. We want to break up our text into smaller pieces to make it easier to consume.
Creating smaller sections allows the developer/reader to skim through and find the part they're most interested in. It also gives them a reference so they can quickly refer back to something.
5) Input = Output
Both programmers and writers need to consume information to create results.
Programmers and Writers both need to determine what their intended output will be. This may start from customer requirements, documentation, or even just personal interests. In any case, there needs to be an end objective in mind.
Both also need to consume information to learn. A Programmer needs to learn languages and better ways to effectively write and maintain their code. This allows them to solve the problems they face while completing customer requirements.
A writer consumes information to learn, form ideas, and create connections. The results are a unique perspective that can be shared with others.
If your code is not well structured and simple, it may get the job done, but it can be challenging to read and maintain. Writing could be the same way. Sloppy writing can get the point across but can be challenging to follow and abstract meaning from.