Ship Messy Code - and why you should feel great doing it

Ship Messy Code - and why you should feel great doing it

23
By Nolan Ashby
Engineering

I know how to write clean code.

It usually means pouring extra effort in today so the code holds up against some imagined future state of the world. That only pays off if I truly know what that future looks like. And in software, we almost never do.

In software we almost never know what comes next

‍

Uncertainty has many sources:

  • Not understanding the tech
  • Not grasping the business
  • Not knowing the users
  • Not knowing the data scale of the system
  • Not knowing how long the code will live
  • Unknown-unknowns (see 2020 for a fuller catalog of examples)

‍

When the future is uncertain, cycle time matters more than anything. A tight loop lets me pull value out of my code by learning as fast as possible, keeping the blast radius of bad or broken code small, and getting something in front of people much sooner.

Every bit of friction eats into my cycle time. That slows the rate at which I turn uncertainty into certainty, which is really just another word for learning. My greatest long-term value comes from learning as fast as I can, since it is a multiplier on every future system I build or design. To put it another way: just as writing is really rewriting, coding is

‍

My biggest long-term value comes from learning as fast as I can

‍

So here is the case for writing messy code. Or, to be exact, the case for writing a lot MORE of it.

‍

Sharpen the craft of writing code

If you want to learn to write code, the surest way to build that skill is to practice. I can read all the articles and books I want, but none of it truly sticks until my own fingers have typed the code out. This is not a craft you pick up in a single day. It is a way of thinking, a way of approaching problems. It is also a slowly gathered pile of knowledge about tools and computing environments. The only path to that knowledge is to actually use those tools and live in those environments. There is no shortcut around the reps. Each time I write code, the next time gets easier and

‍

Each round of code I write makes the next round come easier and less messy

‍

Rediscover the joy of making things

Writing messy code is really about racing to the outcome as fast as you can. It is about reaching that little jolt of success and satisfaction when something, anything, finally works. I typed my first line of code roughly three decades ago, and I still feel that same thrill every single time a fresh piece of code springs to life.

‍

See how code and systems break

Systems break. I have come to see these as the most valuable chances to learn. My biggest lessons have rarely come from some quality tradeoff I saw coming; they came from behavior or input I never once considered. When I pour myself into building something flawless, I get emotionally invested in it working. So when it does break, my first instinct is to hunt for faults outside the code I wrote.

When the code I write is scrappy, I have no emotional stake in whether it holds up. The moment it breaks, I assume it is the weakest link and dive straight into learning more about the code and the system around it. That headspace is one of pure curiosity

No code ever runs in total isolation. Every surprise failure is, by definition, something I did not understand. So each failure becomes a perfectly tailored lesson, shaped almost precisely for me and tuned to squeeze out the most learning I can possibly get.

Learn to debug well

Whenever I code, I lean on a handful of standard feedback loops. Writing messy code cranks up the frequency of every one of them. That naturally pushes me to figure out where to look, and how to look, for signals coming out of the code I am writing. Each pass teaches me a little more about my tools. Maybe I pick up a new keyboard shortcut in my editor, or maybe I script some tedious manual step in the testing flow. The point is that every time I write code I sharpen both my tools and my grasp of how they work.

Map out the design space

When I am writing code to do something unfamiliar, which is nearly all the code I write, since otherwise it would just be refactoring, I do not yet know the design space. I cannot see what is possible, because I do not even know what I do not know.

In drawing classes they sometimes hand out variation studies. You start with 5 or 10 quick sketches from some prompt, then draw 5 or 10 variations of each one. That is really an exploration of the design space. I catch myself weighing just two possible designs against each other, and that is a needless limit on what could actually exist. In truth there are probably dozens of viable designs waiting. Writing more messy code lets me glimpse far more of them. I lift my eyes from where I stand and take in the whole landscape of the possible.

‍

Writing more messy code lets me see more of what is possible

‍

‍

Lower expectations unlock more creative energy and fresh thinking

I know I have touched on this in earlier reasons, but the shift in emotional state I feel when I let go of the ego of my code being right is enormous. In place of frustration and irritation, I feel wonder, discovery, joy, and a real sense of accomplishment. Even if every other reason here turned out to be wrong, that change in my own state of mind alone is worth writing more messy code.

‍

In place of frustration or irritation, I feel wonder, discovery, and joy

‍

In closing:

Plenty of senior, seasoned people love to list all the shoulds your code is supposed to obey. Usually they are describing some far-off promised land they have never actually set foot in either. Some of those shoulds get bundled up as frameworks to help you reason through tradeoffs in system design. The best ones include an explicit escape hatch for knowing when the rules simply do not apply. In the end, they help if they guide you, and they hurt if they only slow you down.

Put another way: know where you are headed, but embrace the messiness of shipping code for today.

Subscribe to posts

Add your email if you would like a note the next time we publish something new. We post about ~1-2x per month, plus up to one message a month about company news.

Fork and deploy a hello world project onto Nimbric in less time than it took to read this page. Feel the power.

Deploy on Nimbric 🚀

Deploy on Nimbric