Tier 2
If
Tier 1 is about establishing the scantest familiarity with a subject – hoping
to avoid looking glassy-eyed whenever it’s mentioned – then Tier 2 is about
beginning to understand the topic; perhaps a cursory interest has been kindled
and/or you’d like to be able to do a bit more than just identify the subject by
sight.
To
that end, one of the first questions I like answered when getting to grips with
a new topic is “why does this thing exist?”. I’m going to begin to attempt to
answer this question for base64 encoding by giving a disingenuous, rather
long-winded, somewhat tortured analogy. I promise I’ll make amends in later tiers.
Imagine
a strange parallel universe in which inter-computer communication has never
happened. The parallel universe’s computers work in the same manner as ours,
just no one ever bothered to invent the technologies which allow computers to
communicate: no Internet, Bluetooth, portable digital devices – no floppy
discs, CDs, DVDs, USB drives, etc. Essentially, each computer is a lonely
digital island.
In
this reality, if I create a super-cool bitmap image in the alternative
universe’s version of MS Paint, you’d physically have to come over to my house
and look at it on my screen; I have no digital means by which to transmit the
data to you. To add to my misery, you live on the other side of the country and,
despite my enthusiasm and entreatment for you to come visit, you’re not going
decamp for the sake of one bitmap image.
So,
scratching my head, I begin to think about the problem and in a fit of pique I
come up with my first – and worst – solution to this problem: I’m going to
write the binary code out on pieces of paper and send the code in the post to
you. Every single one and zero. And then when you receive the paper full of
bits you can key them all in at your end and recreate the image. Perfect!
However,
I soon find, even if I only wanted to send the small 10 x 10 pixel image from
Tier 1 it’s ~1000 bytes. And given there are 8 bits in a byte that’s ~8000 ones
and zeros I’ll have to transcribe! I’m not so keen on this and imagine you’re
even less keen about having to key 8000 binary digits in at your end. We need a
shortcut.
I’m
convinced the part about mailing you the code still has merit but I’m also certain
that raw ones and zeros aren’t the answer. What I need is some sort of
shorthand way of representing the same raw binary data; I need to encode it.
This
is the essence of the problem base64 encoding looks to solve: how can a
text-based medium, in our case pieces of paper, be re-purposed to effectively transmit
binary data.