DEFLATE, by hand
Open the specification that governs the inside of every ZIP archive, PNG image and gzip download — RFC 1951, published May 1996 — and the first surprise is how thin it is: about twenty pages. The algorithm that squeezes most of the world's files is two old ideas composed carefully, and writing it by hand (which is exactly how unzippr's engine works) turns out to be less wizardry than bookkeeping — bookkeeping where one flipped bit ruins everything, which is its own kind of wizardry.
Idea one: don't repeat yourself
DEFLATE reads your data hunting for phrases it saw in the last 32 kilobytes. When "the quick brown" shows up a second time, it stores not the letters but a back-reference: go back 24 bytes, copy 15. Text, code and spreadsheets are ferociously repetitive, so whole paragraphs collapse into these copy instructions. The elegant wrinkle: a reference may reach into bytes it is itself producing — ⟨back 1, copy 100⟩ writes a hundred identical characters from a single seed, the decompressor chasing its own tail on purpose. My decoder copies byte-by-byte precisely because that overlap is legal and common.
Idea two: speak briefly of common things
Everything left over — literal bytes, the copy commands themselves — is then re-spelled in Huffman codes: variable-length bit patterns where frequent symbols get two or three bits and rare ones get nine or ten. Morse code had the same insight about E and Q. The audacious part is that each compressed block may define its own dialect: it opens by describing the exact code lengths it will use — and that description is itself compressed with a third, smaller Huffman code. A tree, described by a tree. Decoding it means building the code tables from nothing but a list of lengths, exactly as section 3.2.2's little algorithm dictates, and the first time it produces readable text it feels genuinely like developing film.
Proof over pride
A hand-written decompressor earns trust one way: byte-exactness against the reference. Mine faced two hundred fuzzed buffers — random noise, pathological repetition, mixed seams — compressed by zlib at all nine levels, and reproduced every original exactly; every extraction here is additionally checked against the archive's own CRC-32 stamp, recomputed from my output. The 1996 document ends with the same quiet confidence it deserves: implemented honestly, it simply works, decade after decade, in everything.