DEV Community

Cover image for Programmer humour
Ross Angus
Ross Angus

Posted on

Programmer humour

Image by David McPictures

The origin of the quote about analysing humour and frogs dying can be traced back to 1941. It's an appropriately arid paragraph by Katharine S. White and her partner:

Analysts have had their go at humo[u]r, and I have read some of this interpretative literature, but without being greatly instructed. Humo[u]r can be dissected, as a frog can, but the thing dies in the process and the innards are discouraging to any but the purely scientific mind.

I'd like to describe a programming joke I made to you. No one, most of all me, anticipates this will be amusing. I hope this article will be like lifting a rock and watching the various insects scuttle about, unaccustomed to the sunlight and noise. You might briefly enjoy the spectacle, before slamming the rock down again, allowing those disgusting creatures to live out their strange lives in peace.

(Just to be clear, I'm one of the beetles, in this metaphor)

The power of ignorance

A few years ago, I was working in a start-up where (in the memorable words of one of the founders) my job was to make my daft ideas seem possible. At that particular time, his focus had shifted to producing a website which would feature a series of recipes.

I started researching recipe sites and, despite it being a mature field, instantly felt the unearned confidence that I could do better than those who had been working in the field for decades1.

I loved this aspect of my old job - barging into a mature field and throwing together a prototype over a couple of days which looked (if you squinted slightly) like a proper product.

Recipes are a mathematical problem

Coming at this field with a programmer's brain, two things struck me:

  1. Recipes seemed pretty inflexible when it came to the number of people served
  2. Recipes seemed to be in either Imperial, Metric or Cups (whatever that means)

Both these problems seemed (from my naive perspective) mathematical in nature. I set about making an interface which would allow users to change the number of portions and the units of measurement to their heart's content.

Cooking is an art, baking is science

There's a lot of banter in the memosphere about cooking - measuring garlic with your heart, not your scales etc. This suggests that many recipes have a wide margin of error which can be abused to serve personal taste.

Notably, this is not the case for baking, where a recipe can be replicated perfectly but then fail to rise due to a difference between the atmospheric pressure in the original author's kitchen and the kitchen of the end user. This suggested that the accuracy of the converted measurements was very important.

I realised that when converting the recipes between different portion sizes and units of measurement, the values I'd end up with would have a lot of decimal places. These decimal places must be protected at all costs!

In defence of Imperialism

In some circles on the Internet, it's fashionable to bash the Imperial form of measurement. Perhaps you've seen this world map of the countries which use Imperial units of measurement in your travels:

Image description

From the article This map shows the countries officially not using the metric system

Or you've seen this diagram, like some terrible inscription used to summon a demon:

Image description

The earliest version of this image I could find was on Imgur.

But that diagram above hints at the reasoning behind the Imperial and cups systems of measurement - it's designed to work on a human scale. Imperial and cups are designed to be split into smaller amounts easily. In the terrifying diagram above, you can see 12 and 16 occur frequently. 12 has four factors: 2, 3, 4 and 6. 16 has three: 2, 4 and 8 (I'm ignoring 1 and 16 here, as neither is useful for my use case).

Ten has two useful factors: 2 and 5.

This means it tends to be easier for a human to break an Imperial recipe into smaller bits than it is to break up a metric recipe.

Obviously, things get a little more complicated when you need to do stuff like deliver a rocket to the moon or a missile into a bunker, but that's a little outside the scope of the problem I was trying to solve, luckily.

Some vulgar conversation

So I knew I'd end up with some ugly numbers like 1.2334325 after my conversion and I wanted to round these into something friendlier. And what could be friendlier than fractions?

HTML (that ancient language which is still used to this day to render most stuff you see on the web) can't display all the fractions. But it can do the following:

¼, ½, ¾, ⅐, ⅑, ⅒, ⅓, ⅔, ⅕, ⅖, ⅗, ⅘, ⅙, ⅚, ⅛, ⅜, ⅝, ⅞

Climb the tree

What my code needed to do after converting a value was to output it using largest to smallest units. So for example:

Take 3 gallons, 2 pints, 1 cup, 6 tablespoons and 1 teaspoon of milk and empty this into a mixing bowl.

For each conversion, the remainder would be passed on to the next step in the chain, where it would be applied to that unit.

Once I ran out of units, I'd break out the fractions.

Now these fractions worked well if the ingredient being converted was something small, like bicarbonate of soda. It sort of makes sense to add ⅑ of a teaspoon of bicarbonate of soda to a cookie recipe originally intended to feed a family of five, which you're making just for yourself. But of course, these fractions were just as likely to turn up in a recipe for pancake batter which you are upscaling to industrial quantities. For example:

Take 1 stone, 5 pounds, 7oz and ⅜ of a teaspoon of plain flour and put it in a bowl

And I found this idea funny, so naturally, I left it in.

The final product hasn't (yet) reached the market so there's no danger of you stumbling across a site which suggests you add 3 oz and ⅞ of a tea spoon of tomato purée to your spaghetti bolognese yet. But if you ever do stumble upon such malicious compliance, I hope it makes you smile.


  1. Recipe sites are interesting for several reasons. Recipes are not recognised by copyright law so this is why recipe sites are so famous for waffling on (no pun intended) about the lives of the bloggers before getting to the useful information - that introduction text can be copyrighted, so if someone hoovered up all the text on the page, they would be culpable of stealing content. The irony of all this is that Google supports a certain kind of markup which makes it trivial to steal all of your recipe data. Why would anyone use this? Because doing so might increase your search engine results. 

Top comments (0)