Tiny Snippets of Code That Changed The World

· 5 min read
Tiny Snippets of Code That Changed The World
Photo by Markus Spiske / Unsplash

In 1997, Ethan Zuckerman broke the Internet — by inventing the pop-up ad.

He was working for Tripod.com, an online service that let people make little web pages for free. To make money, Tripod sold ads that ran alongside the pages. The problem was, ads would wind up running next to racy content — a user’s page devoted to anal sex, say — and advertisers did not like this.

Zuckerman’s boss asked him to figure out some solution. Wasn’t there some way to position the ads so they weren’t right next to sexytime user-generated stuff?

That’s when Zuckerman figured out a weird, hacky solution: When you visited a Tripod page, it would spawn an entirely new pop-up page with just the ad. That way the ad would not be, technically, associated with any particular user page. It’d just be floating there onscreen.

Here’s the thing, though: Zuckerman’s bit of Javascript, that created the popup ad? It was incredibly short — a single line of code:

window.open('http://tripod.com/navbar.html'
"width=200, height=400, toolbar=no, scrollbars=no, resizable=no, target=_top");

Basically, the Javascript tells the browser to open a new window that’s 200 pixels wide and 400 pixels tall, with no scrollbar or toolbar on the top, positioned on top of whatever other web pages are currently open.

Simple, but pernicious! Pretty soon, commercial websites had copied Zuckerman’s innovation, and the Internet was positively infested with pop-up ads. A coder I knew in the early 00s who worked for a download site told me that the absolute vast majority of their revenue came from porn pop-up ads.

You’ve no doubt seen pop-up ads. You no doubt hate them. With luck you use a browser that now suppresses them.

As Zuckerman put it, he had written a single line of code “that made the world a measurably worse place.”

A photo of the cover of “You Are Not Expected To Understand This”; it is blue and lying on its side, with the spine facing the viewer. The editor’s name, Torie Bosch, is in a green monospaced font; the title is in a white monospaced font

I ran across Zuckerman’s story in an essay he wrote for You Are Not Expected To Understand This: How 26 Lines of Code Changed the World. It’s an incredibly fun little collection of short essays, edited by Torie Bosch, that reflects on pieces of code that tilted the world on its axis.

What fascinated me is how brief most of these snippets are. This runs neatly counter to many pop-cultural assumptions about coding, which typically suggest that important code is massive and sprawling. Hollywood loves to depict “programmers programming” with their fingers in an absolute blur, pouring out a Niagara of code. Tales of Google’s dominance used to refer to its “2 billion lines of code”, as if that sheer heft were responsible for the firm’s success.

It’s often quite the opposite. Indeed, Google’s original innovation — the piece of code that vaulted Google above its search-engine peers, back in the 90s — was its “PageRank” algorithm, which calculated the value of web page based on how many other pages linked to it, and the quality of those linking pages. It’s not a terribly long piece of code; people have done their own versions in Python, and it’s only a few dozen lines.

Sure, Google’s overall operations — like those of any big tech firm — involve thousands of processes to keep things running. That’s why their total code base grows so huge. But some of the code with the biggest impact can be pretty pithy.

You should read the whole book (or buy it for nerds as a holiday gift), because the examples are fascinating and wide-ranging. There’s a chapter by Charlton McIlwain on the “police beat algorithm” developed in the late 1960s, which tried to predict where crime was mostly likely to occur, so law-enforcement agencies could send more police that way. This, of course, wound up creating a racist feedback loop: Since poverty-stricken Black neighborhoods were already overpoliced compared to white ones, the algorithm directed more policing there, producing more arrests, which convinced the algorithm to send yet more police; rinse and repeat.

The police-beat algorithm isn’t terribly lengthy; in You Are Not Expected To Understand This, the artist Kelly Chudler draws it out …

About 25 lines of code that includes several mathematical formula. Alas, it’s hard to redact it in plain text here, since it uses mathematical notation

And here’s another, even shorter piece of code that changed the world: The “tracking pixel”.

You probably interact with this code every day, without realizing it, as Lily Hay Newman notes in her chapter on tracking pixels. Basically, it’s a little bit of HTML that embeds a single tiny pixel inside an email, so small you won’t see it. But if someone sends me an email with that tracking code, it spies on me. It works like this: The instant I open the message, the code requires my browser to request that single-pixel image. The person who sent the email to me watches to see, hey, has Clive’s browser asked for that pixel yet? So effectively, the person who sent me the email can tell the instant I’ve opened the email.

Putting a tracking pixel into an email is incredibly easy — it’s this single line:

<img src="URL LINKING TO THE PIXEL ONLINE" width="0" height="0">

And here’s one final, older example! The book has a chapter (written by Ellen R. Stofan and Nick Partridge) on the “bailout” code for the lunar module of the Apollo 11 moon-landing mission. That “bailout” code ran on the lunar module’s tiny little on-board computer, and was designed to help prioritize things: If the computer got overloaded, it would toss aside all but the most important work.

This turned out to be incredibly important when the lunar module was approaching the moon, because sure enough, the computer got way overloaded with work. The “bailout” code jumped into action, shutting down everything that wasn’t utterly crucial to landing the module. It even shut down some of the display systems inside the lunar module, which scared the crap out of the astronauts. But it worked: The module landed safely.

Here’s that code — only 22 lines …

POODOO    INHINT
    CA  Q
    TS  ALMCADR

    TC  BANKCALL
    CADR  VAC5STOR  # STORE ERASABLES FOR DEBUGGING PURPOSES.

    INDEX  ALMCADR
    CAF  0
ABORT2    TC  BORTENT

OCT77770  OCT  77770    # DONT MOVE
    CA  V37FLBIT  # IS AVERAGE G ON
    MASK  FLAGWRD7
    CCS  A
    TC  WHIMPER -1  # YES.  DONT DO POODOO.  DO BAILOUT.

    TC  DOWNFLAG
    ADRES  STATEFLG

    TC  DOWNFLAG
    ADRES  REINTFLG

    TC  DOWNFLAG
    ADRES  NODOFLAG

    TC  BANKCALL
    CADR  MR.KLEAN
    TC  WHIMPER

This book is really quite a blast — very worth checking out!