How ethanol can make you a better programmer

Mon May 11 22:00:00 2009

Digg! submit to reddit Delicious RSS Feed Readers

Hacking While Drunk

The other day I was hanging out on IRC late at night and got chatting to a Shadowcat client about various things - we operate a channel per project and try to get the whole team from both sides into them so we have a complete greppable log of the project discussions. It also affords the opportunity to kick back and relax as a team after a long day pushing towards a deadline, which makes for a better understanding of each other's personalities and is bloody useful when you work remote for teams around the world ... but anyway, Shadowcat's obsession with IRC is probably worth a post of itself, so I'll move on.

So, the conversation bounced from topic to topic, and I was talking about the fact that I don't drive because when I'm way from the UK public transport system it's usually to drink anyway, and then we were talking about hacking while traveling and I think maybe he got his wires crossed slightly because then he asked:

<amiri > Hacking while drunk. Best practices?

... and it's actually quite an interesting question. Or at least, one of the possible answers is. The first and most important answer is make a branch and remember it's a versioned repository - but that's the first thing to remember for any hacking, of course. The second answer is pick things to hack on where you're stuck because you can't work out the perfect solution. And that's where it starts to get interesting.

Perfectionism and Creativity

People often claim that a couple of drinks (or indeed a couple of joints) make them more creative. I'm not sure I've ever considered this to be true, but something I have observed a lot of times is that the biggest blocker to us getting stuff done is our own perfectionism.

The whole "must not ship until there are no bugs left" thing is bad enough - as the Microsoft guys are oft fond of repeating, SHIPPING IS A FEATURE and honestly, on a project of any real scale the difference between a bug you don't have time to fix and an edge case you don't have time to solve are pretty similar. More importantly, the bugs that were really, really important to fix are the ones that you don't find until x.0 ships because, well, nobody[0] ever tests the dev releases.

So, anyway, back to the point. We're programmers. We're perfectionists. We want to make the absolute perfect solution to the problem. And sometimes that just isn't what the world needs. Sometimes there's a solution that's almost as good, that you know will fail on a few edge cases, but would be so much fucking better than anything that currently exists that you should just write the damn thing anyway. And sometimes, a couple of drinks is just what you need to loosen yourself up enough to realise that and just write it.

Here's my confession: Some of my best[1], my most insane[2], my most beautiful[3] perl, has been written while not entirely sober. Often on all nighters where I had a strong cup of coffee and a glass of vodka every hour to keep myself slightly un-sober and still awake and hacking. And it's often been on projects where I'd been trying for weeks to work out what the hell to do about a particular feature, and after a couple beers got over myself and realised that the 98% (or even the 80%[4]) solution was way better than what we already had and went and build it - and in several cases I still haven't hit the remaining however many percent in production and could've saved myself those wasted weeks entirely. Better still, knowing that you're not at your best really encourages you to write as many tests as possible for the[5] code so if it turns out you basically just vomited high ethanol carrot chunks into your codebase then you should have a pretty firm basis to refactor from before pushing the branch.

So next time you're stuck on a hard problem, maybe it's just that you're being more perfectionist than the problem really needs - so pick up a beer, or $narcotic_of_choice, or whatever, make yourself a branch, and remember it's a versioned repository.

Happy hacking.


No, this blog doesn't have a comments system. Yes, lack of comments sucks. Yes, we should publish the damn codebase this site runs on so people can add it for us or something. No, I don't have time to do that yet. So, here's the compromise - mail mst-comments at with your comment, including the URL of the post you're commenting on in the subject, and your comment as either plain text, or as HTML inlined in the body of a plain text email (because I use mutt and I delete anything HTML only that doesn't come from a client :), and I'll add them to the bottom of the post by hand until it gets annoying enough to do something more sensible.

[0] For values of nobody meaning "lots of people, but for some reason never most of the ones who're going to uncover really interesting bugs and then blame you for not fixing them before release"

[1] the recursor in Catalyst::DispatchType::Chained springs to mind

[2] DBIx::Class::ResultSet's _collapse_result method

[3] Er. Hmm. Ask me next year when I haven't since decided it's all ugly and I hate it ...

[4] UNIX, anyone? :)

[5] And the pink elephants the tequila's making you hallucinate really help you to not be bored while doing it, too