Saturday, March 12, 2016

Drunk Monkeys

By day, I am a mild mannered programmer enjoying my work. Sometimes I get a chance to develop new stuff, but most days I delve into the arcane world of existing code. Existing code could have been written by me just yesterday, or it could be an artifact from an errant interpretation of a 1930s scholarly work. In any event, I take the same approach to untangling the myriad of obfuscations: I assume that it was written by drunk monkeys.

Background...

A while back (the 1913, I believe), there was a learned man (Borel) that conjectured that if a million monkeys typed ten hours a day, it was extremely unlikely that their output would exactly equal all the books of the richest libraries of the world; and yet, in comparison, it was even more unlikely that the laws of statistical mechanics would ever be violated, even briefly (See eoht). Now, these were sober monkeys targeting archival manuscripts. 

What if...

Imagine that some of those million monkeys had a celebration and amply imbibed in hard liquor during it. A moment before last call, they were whisked away into the room with the typewriters. From that time until dawn, they typed code and checked it into the repository. Miraculously, it passed QA testing the ensuing day and went to production where I work. Eventually, a corner case not covered by testing appears in production and is exposed as a bug. To eradicate the offender, I crack open the source code only to uncover the nonsensical debris previously saved by - yes, drunk monkeys.