Nav links

Friday, 30 March 2012

From tiny acorns...


With 2TB hard disks, 32GB SDHC cards and 8GB USB flash drives now commonplace it is easy to forget how much can be done in a small amount of code. A compressed jpeg photograph from a 6 megapixel camera might take about 2MB. So how did people cope in the 1980's when the common double-sided 5 1/4" floppy disks could only store 360kB, and what can you do with 1kB today?

As an aside, a byte, historically, is the amount of data required to store one character. Changes to encode international alphabets mean this is no longer strictly true, but it's still a good rule of thumb.

Back in the early days of the IBM PC-compatible home users did not have much digital media to store. Digital cameras did not exist, and digital music, photo and video was not common. The types of items I stored were word processing documents, source code, and games. These days documents and games can be huge, with the media assets of games filling an entire 6GB DVD. Source code is still tiny, though, which leads to some pretty impressive and surprising achievements.

All of the text up to the end of the preceding paragraph has contained 1085 characters. There is an ongoing competition called JS1K where javascript of less than 1000 bytes is written that performs interesting feats. This year I was most impressed with the JS1k Speech Synthesizer, which in only 909 bytes turns text into (mostly intelligible) speech. Annotated code is provided, but it's still be bit obtuse to me. Actually, a great benefit of javascript code is that anyone can read it, by just viewing the source in their browser. I used to expect that if the code was short then it would be understandable, but this is definitely not the case, especially when lots of minification has been done.

Seeing the JS1K demos reminded me of when I followed the PC demoscene. One of the most popular current competitions is the 4kB intro. I am particular impressed with the 2009 demo elevated. Although you can watch a YouTube version it's a lot more impressive downloading and running the proper 4kB Windows code (note that there is a Windows 7 version). Recall that a single digital photograph takes about 2MB, and then ponder how this multi-minute video, of flying over a photo-realistic landscape, with associated music can fit into just 4kB.

Finally, and slightly offtopic, Twibright Optar is interesting software which can store 200 kB on a single A4 sheet of paper. Think of it as an enlarged QR code. It might not sound that useful, but consider that paper may, when stored correctly, last many hundreds of years. Then think about your old floppy disks and how you can read them nowadays. Or do you trust The Cloud?