Retry Logic

The story of a programmer going back in time and fixing all the things.

Programmer's log: star date: I've never been on a date.

Chapter 1: Initialization

I have been chosen to participate in a government time travel program. It sounded like a scam to me too. I got a letter about joining a research experiment. The letter itself was pretty flimsy and most government departments don't have good reputations for official looking logos and signatures. I responded, hoping to waste some scammer's time, maybe get a TED talk out of it.

They responded, double-checking my interest in participating. The very next day a Homeland Security official showed up to my office and escorted me out. That was so embarrassing. I got so panicked in front of everyone. He didn't even give me a chance to push my code. More worrisome, he wasn't discreet at all. You'd think secret government programs would do the witness protection kidnap or disappearance thing. Not this guy.

He took me to his home office. Again, they asked if I was interested. Now it was more serious so I hesitated. Governments tend to screw over people recruited into secret programs. However, there is a project at work coming up I'd very much like to skip. Participating sounded much better than that. They had me sign some non-disclosure agreements and such.

They explained the program. Basically, the government finally figured out how to time travel and needs people willing to go back in time and test it out. A sub-goal of this project is to also gather information on how to alter history to make a better world. They aren't looking for much, even slightly better would be great they say.

My mentor explained to me they initially had much higher hopes. The "go back in time and kill Hitler" change didn't yield the results they were looking for. Altering the course of history on such a large scale is a fickle thing. They began recruiting people like me for smaller missions after a few dozen failed attempts. They admitted it was hard to find volunteers.

From what I understand the time travel itself is pretty cool. At least the rules are pretty straight forward. I pick a start time between now and 1945, they fork our universe in a simulator, and I get to live out a life in that universe until I "die" or end the simulation. Honestly, the fork our universe bit is the more interesting part to me, but time travel is cool too.

It was hard to pick my first mission. My mentor recommended starting with something really, really small that I was also passionate about. I thought about going back in time and getting all of my favorite cancelled TV shows resurrected. There were some real cliffhangers I got screwed on. Even that my mentor said would probably be too big a change for my first time.

My mentor's "theme" for his missions is interesting. He goes back to prevent car defects. He has gone back and scrubbed up a lot of manufacturing and software negligence. It is impactful, saves lives, and is prevented so early in the process that it rarely has negative side-effects. Sure, he does save some mass murdering children by saving their parents, but overall we are better off so it fits the quota of "slightly better."

He worked in car manufacturing so having prior experience in the history you're correcting may be the key for me too. The only thing I'm really knowledgeable about is programming. This will be my theme for now. I shall go back in time and rid the world of programmer suffering and mistakes, making my job when I get back easier to boot. Sounds like a plan, let's get started!

Chapter 2: Typeof null

I've done quite a bit of front-end development so there's a clear thing to fix: JavaScript. There is a lot of cruft and just plain stupid things in that language worth eradicating. I posted a question to StackOverflow: "How are far back in time would I have to go to fix JavaScript?" The question was closed for being too broad. I didn't feel ready to take on the whole language. I would chip away at it and I knew just where to start.

In JavaScript, the type of null is "object" which is confusing because null is most often the absence of an object and otherwise a primitive type. This means in practice the variable being checked needs to be checked for both not being null and being of type object. Making the typeof null be "null" would probably make things "slightly better."

I submitted my mission brief and it was approved. The next step was making my plan of attack. I had originally thought it was a typo in the ECMAScript specification that everyone just rolled with. I researched how this bug actually crept in and like most things it was Brendan Eich's fault.

The creator of JavaScript had only a week to make the first implementation, so these things happened. The typeof bug can be traced back to the initial project called Mocha. The issue was each value in the language was tagged with its type. Objects were stored in memory ending with 000, integers ended with 1, strings ended with 100, and so on. Null was represented as an object type 000 and its value being the C null pointer 0x00. The typeof operator only checked the type, not whether it was also a null pointer, so it returned "object".

I needed to make the check for the null pointer. This would be only a couple line changes in Mocha.

When to travel to was less clear. Searching I could only find reference to "10 days in May 1995" but no exact days. The destination was Mountain View, California in the Netscape Communications office. I did not have an exact address but figured I could use the phone books from that time to find it once I got there.

I was beginning to realize I was going to be dropping into a focal point of the history of the internet. Despite picking something I thought was simple, JavaScript easily could end up even worse than it is now. Luckily I had room to experiment.

The scientist assigned to help me loaded up a simulation for the beginning of May 1995 to be sure I didn't overshoot it. I would be dropped onto what is modern day Castro Street in Mountain View and begin my quest. I would also start out with a couple hundred dollars to make it through my time.

My first mission began. Not wasting any time I went to the nearest coffee shop and asked for a phone book to look up the Netscape office. It wasn't there. Netscape had only started a year prior so this wasn't surprising. I wasn't about to walk through the street asking people. I gave up and pulled out of the simulation.

I dug deeper into Netscape and found their home office address and phone number in their IPO filing. 501 East Middlefield Road is the place, now filled by Symantec. It's good I found the address as it saves me an hour walk from Castro. I was ready to retry my mission.

I walked into the office and asked to speak with Brendan Eich. The front desk phoned him and he came to greet me. We walked back to his desk. I read a bit about Scheme, his favorite language, beforehand so we could have something to talk about before I got into the real stuff. Once we sat I asked, "So how's Mocha going?"

Brendan responded, "What's Mocha?" My heart sank. He hadn't gotten started at all this early in the month. Flapping butterfly wings flashed before my eyes. I knew I had already screwed this timeline. Naming is a big deal to programmers and so is wanting to be original. Now that I had thrown Mocha out there he was going to call it something different like Frappe or Cappuccino. It was downhill from here.

I powered through and told him a story about a time where I forgot to handle the type reflection for the null pointer in my language. I explained the bug he would eventually write as if I had made the same mistake. I knew roughly how he implemented it using a discriminated union in C so I described it the same way.

The whole conversation was very confusing for Brendan. A random weirdo showing up talking about language implementations only happens at meet ups. I put him at ease early on by saying I was a friend of Marc, one of Netscape's founders. I hoped that would imply to Brenden I was in the know about his upcoming work for the Netscape browser.

We exchanged parting pleasantries and I left the office. I walked a few blocks, making sure I wasn't being watched and left the simulation.

It takes awhile for the simulation to play out and process. My scientist pinged me a few hours later to share the results. She had some good and bad news for me.

The good news I was right about the naming. While in the end it became "JavaScript" all the same, Brendan called Mocha "Expresso" instead. Honestly that made more sense as JavaScript was supposed to be for easier scripts than Java, so Expresso, express, quick, fast, etc.

The bad news was nothing else changed. I had described the exact bug he would make no more than two weeks later and he still made it regardless. I thought I had ruined everything but my presence actually didn't make a difference. I had mixed emotions, but was mostly bitter he completely ignored my warning. I had to change up my approach.

He didn't begin working on Mocha at the beginning of May. The month of May has 31 days so I decided to binary search May for the opportune day to call out the bug. At least getting access to Brendan at his office each time would be easy.

I went back to the office in the middle of month and told him my exact same story. He had begun work on Mocha at this point and said he was making good progress. Once I finished my story, he told me about how he was modeling his language's variables in the same way and he showed me some of the code. Trying to hit the jackpot I asked if he had written the type reflection yet. He had just taken his first stab at it. This was awesome, I would be able to pair program this bug out of existence.

We got into the typeof code and I was quick to point out he was never returning "null" for the null case. He read the code and said, "Ah, yes. This is by design. Nulls indicate an empty reference to an object." My heart sank, my face went pale, and then I punched him in the face and ended the simulation.

That was an overreaction, but things made sense now. Brendan considered it to be a feature, not a bug, so my original warning fell on deaf ears. He also wasn't categorically wrong. Languages with pointers worked this way, a pointer pointed at something or it didn't. But Brendan also didn't know what the fallout of this decision would be. He couldn't anticipate all the butt hurt comments in r/javascript, questions on StackOverflow, and downstream bugs that this decision would create.

Now I had to convince Brendan it was a bad idea. I couldn't just tell him what happens in the future because that would screw up the timeline in some way. I didn't know of an exemplar language to speak to that existed in 1995. Nowadays it is much easier to discuss language design. To win arguments, you just say, "That's not how Rust does it, dumb dumb." Back then pointers and null were where it was at. It seemed that to complete this mission I would have to buff up on programming language design in the context of 1995 to make a compelling case.

Before I began researching my scientist interjected, "You know you can possess people in these simulations, right?" No one told me that was a thing I could do.

We set the simulation to start that same day in the middle of May when Brendan was working at this desk. I dropped in as him, opened the typeof code, made the change, and got out in under a minute. No grand debate that devolves into bickering needed. Mocha was such a rush job he wouldn't go back and notice.

I waited eagerly for the results. The scientist pinged me within the hour. The simulation didn't complete. She explained that the simulations process much faster when they don't reach present day. Making that typeof change caused a world extinction event somewhere down the line. She complimented me. "This was your first time ending the world and in record time," she joked.

I was fed up. The Internet of Things was going to be the death of us. This tiny change was the lynchpin. It is only a matter of time before something else causes IoT to kill us all. Truly our world is built on top of foundations made from C4.

"Fuck it," I said. We went home for the day.