I don’t know whether this is good or bad, but it’s an interesting trick.

Some folx on the Codea forum were playing with Wordle kinds of games. The ubiquitous Dave1707 produced a thing that seemed truly odd to me, a list of 16000 5-letter words that looked like this greyish mottled rectangle:


I was boggled. How did there get to be words in there? Dave had shown some code, but I confess that in my wonderment I didn’t even read it. Had I done so, I’d have known what I know now, which is that to unpack the file, Dave read in the image and looped over each graphics point in it, unpacking the RGB values and converting them to characters.

OK, that’s some combination of clever and evil, packing three characters into every point of an image, disguised as a color. Even then, I couldn’t see how he created the file.

What I was missing was two things I didn’t know, and one that I forgot. I wasn’t aware that Lua has string.byte and string.char functions. The first converts a string to a series of integer values, the character encoding of the string. The second does the reverse. I wasn’t aware that Lua even had those, having never needed them and passing over them in any scans I may have made of the string functions.

And I had forgotten that Codea has a pair of functions saveImage and readImage that, well, save and read an image. (You can write an image to memory rather than to the screen. I actually mostly knew that.)

Now, as some readers may be aware, I am old. I am so old that characters in the computer only required six bits. I am so old that the 65536 36-bit words on the first computer I used were double what was usually available. I am no stranger to packing information into small spaces: I’ve done a lot of it.

However … my current smallest-possible laptop has 16GB of main memory and 1TB of solid-state file storage. The phone I carry in my pocket has 256GB of storage. My watch has only 16GB of storage, over two hundred thousand times more memory than the massively-upgraded room-filling IBM 7094 I first programmed.

Perhaps I can be forgiven by not having packing ideas right at the top of my bag of tricks: it has been a very long time since I had to worry much about saving memory1.

Now, I just wanted to write about this because I think it’s an interesting trick2, and I think it’s possibly interesting that despite having a lot of experience packing things in my past, I was rather boggled by just seeing a grey image and being told it had 16000 words in it. These days, I’d expect a 16000 word file to look like a 800000 byte string, maybe with newlines in it.

My mind was simply not at a place where an image could be anything but a picture. And, boggled as I was, and perhaps since I was just browsing anyway, I didn’t dig through Dave’s code to see how he unpacked the file. Had I done so, it would also have been clear how he must have packed it. As it stands, I asked two questions about how he did it that surely did not show how clever and understanding I am.


I am of a mind to draw lessons from this odd thing. I’ll offer these:

  1. My current level of attention may cause me not to understand something that I could easily understand in a different state of mind.
  2. Being away from some set of ideas may mean that they won’t spring right to mind, even when they’re just the right ones.
  3. When in doubt, read the code!
  4. When still in doubt, read it again.
  5. Don’t be afraid to ask a “stupid” question. The only stupid thing is stay ignorant.
  6. Feel free to laugh at myself for not seeing something.
  7. It’s rude to laugh at other folx. Probably don’t do that.
  8. When something is clever, appreciate it.
  9. Do “clever” things only when I must. Clarity is better than cleverness, most times.

Your lessons, if any, may vary. These are mine, and they seem pretty consistent with my general outlook.

  1. OK, there was the time maybe five years ago when I packed a vector into an integer, but that was in another world. 

  2. The grey image of a few thousand words may remind you of “steganography”, the practice of hiding a secret message inside something that isn’t secret, a physical object or digital one. If we were to use, not the whole color space of each point, but only a bit or two from the low end of each color, we could hide a message in a picture of a cat or a car or the rolling fields of Microsoft Windows. The picture would look just fine, but the recipient of our message would know how to extract the message by masking and assembling the bits.