Stories · 12 min read

The Pro­gram­mer Who Sent Humans to the Moon

The woman in the photo is Dr. Margaret Hamilton, head of the team that built the software that carried Apollo 11 to our night luminary, the mission that took the first humans to the Moon in 1969. And that stack of binders? It's the software Margaret and her team wrote. What were the biggest challenges back when the profession of software engineer didn't even exist yet?

Translated from the Bulgarian original →
Margaret Hamilton

This photo is iconic, and in my opinion it should be a mandatory part of every software engineering course. It should also be shown to every programmer who complains that their job is hard. In the picture is Dr. Margaret Hamilton, head of the team that created the software that carried Apollo 11 to our night luminary. The mission would take the first humans to the Moon in 1969.

And what is that enormous pile of paper? That is precisely the computer code written by Margaret and her team. With the primitive technology of the day, they managed to foresee which problem could stop “one giant leap for mankind,” and they prevented it.

There's more. The girl in the photo is also widely credited with coining the term “software engineering.”

What must it be like to be responsible for the software of archaic computers on which, nevertheless, the survival of the first people ever to set foot on Earth's satellite depends?

Margaret Hamilton

A Flower from the Moon

Today the life of the rank-and-file programmer is light-years easier. We have huge platforms ready-made, and on top of them libraries on whose backs we can climb.

For the young Mrs. Hamilton, things looked quite different. Born in 1936, she fell for mathematics as a child and graduated from the University of Michigan in 1958. Her father was a philosopher and poet, her grandfather a writer, teacher and senior Protestant minister, and she names the two of them as her inspirations.

For a short while she taught math and French at a high school while waiting for her husband, whom she had met in high school, to finish his degree. Soon he had a diploma too, and the two of them had a little daughter named Lauren.

They moved to Boston, where he found a job. Margaret had gone with the idea of continuing on to a doctorate, but… it would have to wait. She needed to start working to help the family budget, something quite unusual for a young mother in those days.

She worked briefly on a meteorology program at MIT, then moved on to an Air Force project whose goal was to identify enemy aircraft.

The Moon Is Asleep

“I had to find a job, and that's how I ended up in the lab run by Prof. Edward Lorenz, the father of chaos theory. I worked on a weather prediction system. He was looking for mathematicians who would learn software development. That's where I learned what a computer is and how software is made,” she recalls.

It was right then, in 1963, as she was planning to return to her doctorate, that she saw an ad: computer specialists were wanted at another MIT lab, which would be working on the project to send the first humans to the Moon. It would create the software for the upcoming Apollo missions.

Margaret decided there was no way she could pass up such a chance.

She immediately called the number in the ad and within a few hours had set up meetings with two of the managers, whom she knew from her previous job. Both offered her the position on the same day. Not wanting to turn either of them down, she suggested they flip a coin to decide where she would go. The one in charge of software won, and she started work the very next day.

Margaret Hamilton

Moonlight Sonata

Margaret was the first programmer on the team and the first woman there. By that time a large number of computer specialists and mathematicians were already working on the project, but all of them were responsible for the hardware. Soon Margaret's team had about 100 software engineers (who didn't even know yet that this was what their profession was called). She officially took the helm in 1965.

“Back then software was a complete mystery, a black box to management. So they gave us their full faith and trust. We were incredibly lucky to be in the right place at the right time,” she recalls.

“There was nowhere to learn from. We were working in a field that was only just emerging. We had no choice but to be pioneers. But the bigger the challenge, the more fun we had, as is only natural for kids in their twenties.”

“Our software had to be ultra-reliable, able to detect errors and recover from them at any moment of the mission,” she recalls.

One of the most important things to plan for was making sure the computer would not be overloaded in the critical moments before landing. Today our browser “eats” RAM like a hungry dragon, and that RAM is measured in tens of gigabytes, while the space computer of the day had at its disposal… 72 kilobytes in its version of a “hard drive” and barely 10 or so kilobytes of working memory.

Margaret Hamilton

Lunatics

July 20, 1969. The lunar module Eagle separates from the command module, Columbia, and sets off on its one and only mission.

Just before the crucial stage of the landing begins, dozens of different commands fly toward the computer controlling the module. The situation is critical. If the software isn't prepared to prioritize them, the machine could stop following instructions and the landing would become impossible.

But our heroine and her team had foreseen this risk.

The software was built to recognize when it was being asked to perform more operations than it could handle. In that situation, it would signal to the astronauts that something was wrong and it was overloaded.

And that's not all. The team of software engineers who didn't yet know they were software engineers had created a self-recovering program. In that mode the computer would drop the unimportant tasks and keep running only the essential ones. That is exactly what happened shortly before Eagle touched down. Ground control and the astronauts trusted its judgment.

“The software was designed not just to report that there was a hardware-related problem, but to try to overcome it,” says Margaret. “Fortunately, they trusted it, and just 30 seconds later we heard Neil Armstrong say: ‘The Eagle has landed.’”

Margaret Hamilton

Moonstruck

At that point Margaret was leading the team, working in a profession that didn't exist yet. And she was only 32.

After Apollo, part of the code was used to launch Skylab, the first American orbital station, and later in the Space Shuttles.

So what did software look like in those days?

Writing code began on large sheets of paper. A person called a keypunch operator then used what had been written to create punch cards: sheets of cardboard with holes in specific places.

Once everything had been checked and found correct, the code was sent to a factory, where it was transformed into the form used by those proto-computers. Copper wires and magnetic cores were threaded onto long wire that “remembered” the zeros and ones in a rather primitive way: passing through a strong magnet, they were sorted according to their polarization.

The Apollo code
Part of the computer code created by Margaret and her team.

Oh, Moon, Oh Moon

One of the most serious challenges was preparing the software for every possible problem. Much time would pass before testing specialists appeared on the stage of the software industry, but in this case the role was filled by Margaret's daughter.

She often took Lauren with her when she had to work evenings and weekends.

“One day she was with me again, and I had just launched the simulation of the flight to the Moon. She loved to imitate me by playing astronaut. She started pressing random buttons, and the simulator came on. Then she pressed a few more and everything crashed. She had started the program that is supposed to run before launch, while the rocket was supposedly already on its way to the Moon. The computer's entire memory was taken up by the current task, and it froze.

I thought: ‘My God, what if this happens during a real mission!’ I immediately suggested to the team that we make it so programs could be run only in the exact stage they were intended for.”

Her bosses replied that this was utter nonsense, because the hand-picked, meticulously trained astronauts could never make such a mistake. Meanwhile, on the very next mission, Apollo 8, exactly that happened. “It caused a big mess, we had to change a lot of things on the fly, and only then did they let me make the change.”

The Apollo computer
This is what one of the computers on the Apollo mission looked like.

The Bright Moon Is Rising

“The first languages I programmed in were hexadecimal and binary,” says Margaret. “You write code out of zeros and ones. I came across good teachers and learned how to give optimal commands that way, so that the hardware of the time could perform as well as possible. With my teachers' help I created something that today might be called a ‘mini operating system.’”

“The computers my colleagues and I worked with before Apollo ranged in size from huge, as big as a room, to as big as an entire warehouse,” Margaret says. When she joined the lunar mission, however, she had to prepare the program for two considerably smaller, nearly identical computers. Practically laptops, weighing a mere 30 kilograms or so each.

Apollo 11 had two computers on board, almost identical. One was in Columbia, the other in Eagle.

Between Two Moons

“While I was working on the program for detecting enemy aircraft, I first became interested in the subject of software reliability. When the computer simply stops in the middle of running your code, there's no way to hide it. Lights flash, alarms scream from every direction. That made me try to anticipate where a problem might crop up,” says Margaret.

Debugging was a genuine adventure. “The only information the computer gave the programmer was the register, which pointed you to the part of memory where the program had stalled.”

“The other option was simply to listen. When the program was running normally, the computer sounded like the surf on a beautiful beach. That's what we called it, ‘the sound of the surf.’ Sometimes one of the operators would call me in the middle of the night to tell me something wasn't right, because ‘I can't hear the surf anymore.’ And so another debugging method was born.”

Margaret Hamilton

The Dark Side of the Moon

So what's the truth about the famous photo with the “huge binders of software”? Well, today we would partly call it PR. Yes, of course, that is not exactly the code used on Apollo 11.

For the picture, the MIT photographer came to Margaret's lab and had her gather all the working binders she could find. Then, right after the successful Moon landing, the shot was sent out to the media with an appropriate caption. The real code used by the two Apollo computers was about one-tenth the “height” of the stack in the photo.

Each of the individual binders in the photo contains code prepared for the onboard machines of one of the Apollo missions. One such binder “fed” commands to the computer in the lunar module, another to the one in the command module.

Margaret Hamilton
Margaret in 1995.

Little Moons

Is Margaret Hamilton really the author of the term “software engineering”? It's hard to say, but she certainly did a great deal to make it a reality.

At the time, engineering was considered a serious science, while software was still more of a fantasy, something of a joke to the “serious engineers.”

When she started working with software, there was still no term to describe the profession, nor was it taught anywhere. Very soon, in the 1970s, that would change dramatically.

In the early days of the project, software really wasn't taken very seriously compared with the other engineering disciplines. “We were working with very complex systems, but nobody thought what we were doing was serious science and a key task. Out of desperation, one day I went to the other leading hardware specialists and told them: ‘Hey, we're engineers too!’

For a long time afterward they repeated it back to me as a joke. Until one day, at a meeting of the whole team, one of the biggest hardware gurus on the team explained in front of everyone that he actually agreed with me completely. The process of building software should also be recognized as an engineering discipline, just like hardware. It was a truly memorable moment!” Margaret recalls.

So it turns out the claim is evidently no exaggeration, and she is the person who introduced the term programmers proudly wear today.

Margaret Hamilton
Margaret Hamilton receives the presidential award from Barack Obama in 2016.

Lunokhod, Onward

What is the most important piece of advice Dr. Hamilton gives young programmers today? Not to limit themselves to just “learning” code. “I believe it is just as important to study and be exposed to things like music, art, philosophy, linguistics. And, of course, mathematics and logic. I think each of these fields can help build an excellent programmer and a person skilled at solving all kinds of problems.”

Many researchers have noted that for many years Margaret and the software team were barely mentioned in the memoirs and historical records of the mission. Over the years she worked on various software projects and founded her own company, Hamilton Technologies, which works on projects in systems engineering. She finally got to her doctorate as well. She published more than 130 scientific papers and took part in projects and conferences. Still, she achieved no dazzling successes in this field that would draw the attention of the media and the public.

The girl next to the mountain of code burst into the spotlight with a bang and full force in 2016, when Barack Obama awarded her the Presidential Medal of Freedom, which has not been presented to anyone since. She became so popular that a year later Lego devoted a set to her in its special collection honoring women in science, and Google paid tribute to her by using the 100,000 mirrors of a solar facility in the Mojave Desert to draw her portrait.

And the sight really is impressive:

A Presidential Moon

Yes, quite a few experts believe her contribution has been exaggerated in recent years. It has been pushed to the forefront and put to use precisely as ideas of gender equality came into fashion. And thanks to her famous photo, she makes a fitting media product for grabbing attention.

And yet, wherever the truth lies… the mountain of code that did its job at exactly the right moment is beyond doubt. And, especially if you work with software professionally, it's certainly worth remembering it the next time you get stuck on some problem and feel like settling scores with your computer physically…

Margaret Hamilton
A Lego set was also created in Margaret's honor
Almost there…
If you liked the story, support the project. The site has no ads.
Support

Next story

All stories →