Shitty First Code

I got my degree in English Literature, and there have been a few brief periods in my adult life when I made attempts at “being a writer” (a phrase that’s as nebulous to me as “when I grow up”). To that end, I’ve read a couple of books by a couple of writers that have more or less stuck with me. The first, which I recommend to anyone who writes in any capacity, is Stephen King’s On Writing. The second, Bird By Bird by Anne Lamott, contains a particular chapter that I may never forget. It’s called “Shitty First Drafts.” (You can read the excerpt in PDF format online here, if you’re so inclined – it’s about a 5ish minute read, and it’s rather funny.)

I revisited Ms. Lamott’s advice on writing such first drafts tonight after I had worked through some coding problems on a new website I just discovered called Codewars – if you’re interested, you can sign up here. It’s fun, it’s free, and I’m finding it to be a great way to flex my mental muscles! I made it through the first several problems before getting stuck on one (which is why I’m taking a break to write this post now).

One of the truly great features about this website is that, after you submit your answer, it shows you some of the more optimal and clever submissions by other users – in most cases using obscure code or tricks I’d never even thought possible. It’s a great way to learn, certainly, but for someone as competitive as I am, it’s also daunting in a way. Part of me always wants to be the best at what I’m doing, to excel, and so it’s easy for my inner critic to convince me that, even though I came up with an answer, it just wasn’t good enough. Why hadn’t I thought of that? I’m a smart guy, is the most basic solution all I’m really good for?

In my particular case, I’m solving the problems using JavaScript (though, if time permits, I’d like to revisit them using at least one other language). I’ve been casually familiar with JavaScript for years, but I am not yet an expert and have still only barely scratched the surface of what is possible with this language. I should really be proud that I’m coming up with solutions, period. And so I started thinking about that when I stepped away from my apartment to take the dogs out. I need to be okay with shitty first code.

According to Lamott, “[a]lmost all good writing begins with terrible first efforts.” I believe this is true, and I believe that it extends beyond writing fiction/nonfiction to writing computer code, as well. I think if I intend to get anywhere with a career in development, I need to start by accepting that my first efforts are going to be imperfect and suboptimal. Accepting shitty code doesn’t mean settling for being a shitty coder; it means understanding that my first attempts will likely be laughable to a more seasoned developer, but also knowing that I will eventually hone my skills and improve my knowledge of what can be done within the constraints of the language. The most important thing at this point is actually doing it without giving up, so that I can come to an understanding of the fundamental algorithm for the problem I’m trying to solve. As I progress, I’ll take note of what others have done, and I’ll admire and appreciate their ingenuity, but I’ll also do my best not to let the superiority of their methods intimidate me. I’ll see their more optimal code as an opportunity to learn. Instead of beating myself up, I will slowly start to build myself up instead.

So here’s to shitty code.


One thought on “Shitty First Code

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s