liamamad.io

The Relationship Between Coding and Writing

Wed Jun 17 2024


I realized that, in my personal experience, writing and coding use a lot of the same cognitive processes.

Both are iterative, about structure, clarity, flow state, and soul.

The Iterative Process

Whenever I write something one or more people will see, I like to vomit a bunch of ideas (AKA rough draft), then come back and remove anything unrelated, connect the ideas, and clean it up so that it looks like I knew what I was doing the first time around. It's a process of prioritizing momentum over perfection.

Coding is very much an iterative process. A lot of times, whenever you're working on a new challenge, you don't yet have the complete idea of how you're supposed to solve the problem. So instead of sitting in decision paralysis, you just start typing away in the process of trial and error. Once you have a solution that works, you come back and remove anything unrelated, keep the essentials, and clean it up. This process is known as refactoring.

Structure and Clarity

If you can remember back to your school years, you were taught that an essay should generally have an intro paragraph, thesis statement, body paragraphs, and a conclusion. Structure is important for a number of reasons, namely for clarity, logical flow, and readability.

Having a well-defined structure in your writing allows the reader to better connect ideas because there is a clear pattern to follow. This also makes it more enjoyable because it flows better for the reader and makes it easier for them to extract value from the text.

Writing good code is all about structure and clarity. In a professional environment, you aren't the only person that is going to be going through the code you write. Writing code that is self-explanatory and separated into components with a narrow purpose makes it easier to debug, make changes, and refactor. This is known as separation of concerns.

Flow State (aka being in the zone)

I would describe flow state as a hyper-focused mental state where your mind progresses from idea to idea effortlessly. Everything else in the world disappears. Your task can feel almost trivial, and better yet, it's deeply enjoyable. I live for these moments as it makes me feel alive and at my most efficient.

Both writing and coding (and really any creative pursuit) benefit heavily from flow.

Soul

When something can be done in so many ways, it allows for self-expression. Within your writing or code is a piece of you. The ideas had to pass through you, emerging from your soul.

Back to home