Coder’s block

Dec 17, 2020

In a recent conversation, I made a comment that came out of me unconsciously. Or so I’d like to believe because it almost certainly was not a well-thought-out remark.

I said, “I dont want to think when I’m writing code”. It has been more than a day since I said it and I’ve been thinking about this remark all throughout. Why did I say it? What did I really mean? etc.

When I think as I write code, the whole process of writing some logic and making it work feels tedious. Almost like drudgery. Things go wrong in oh-so-many ways and it’s more like fighting against a machine with an almost unconquerable will than writing logical instructions to a machine that is ready to do your bidding.

The opposite of this is when I know what needs to be written and I just write it. Sure, it breaks in a few ways but these are tiny annoyances that are remedied almost immediately - or with a slight pause - and then the almost-smooth-sailing resumes.

So the trick (to happier code-writing experiences) seems to be to know in advance what’s going to be written. This completely avoids the “thinking while writing code” problem and - perhaps, as a result of that - gives a great code-writing experience.

But of course, I’m no genius so I can’t really know what I’m going to write. There’s always a trial and error even when I’m fairly confident of the kind of logic I’m going to implement for a specific feature/problem. But fighting through that trial and error is easier than doing that thinking while also writing code.

I didn’t know it at the time and only realized it now while thinking about this that I had the same problem with writing (in general). If I had spent my days marinating in thoughts about something and, more importantly, forming the structure of the thing I’m thinking about, my writing on that would almost flow. If instead I fired up the editor with just the crux of a topic, I could go weeks with nothing to show except feeling battered. The coder’s block is the same as the writer’s block.

These lessons always sound blatantly obvious in hindsight. These are lessons we’ve read about, heard about, seen about in various forms. Visualizing the thing you are about to produce gives you a fair upper-hand in skirting the problem of a writer’s, coder’s and creator’s block.

I am pretty certain I’d forget this lesson four weeks down the line and stare at stray pieces of code I’m completely unhappy about unless I re-read this multiple times a month. But there is one interesting meta-application here: I spent a better part of the day thinking about this whole write-up as well and that has paid dividends.