There were no guidebooks for Margaret Hamilton to work with. So, she wrote her own. 

Source: MIT Museum

We've all been there. You've got a high-profile presentation or demonstration of whatever thing you've been working on for days, weeks, or even months, and there's a long anxious moment where you know the thing could break or go sideways.

You can see that moment coming at you like a freight train with only the hope that you did your job properly giving you any assurance that you're not about to get run over.

We might all have been in a situation where we had to put our trust in our work to hold up and do what it needed to do, but Margaret Hamilton's work was particularly important – it was responsible for putting Neil Armstrong and Buzz Aldrin on the moon in July 1969.

When warning lights started going off in the middle of the Eagle module's descent towards the lunar surface, Nasa faced a tough decision: continue with the landing or abort. 

As the lead programmer for the Apollo program's guidance computer, though, Hamilton knew that she and her team had planned for this and they had written code to handle this exact kind of problem. 

"It quickly became clear that the software was not only informing everyone that there was a hardware-related problem, but that the software was compensating for it," Hamilton said on the 40th anniversary of the Apollo 11 landing. "With only minutes to spare, the decision was made to go for the landing."

Even though Hamilton was just 32 years old at the time, Nasa's mission control staff trusted her software, too. They gave Armstrong and Aldrin the go-ahead to land on the moon, and Hamilton's error-correcting code saw to it that they were successful.

Early life and career

Source: Makers/YouTube

Landing men on the moon with just a little more than 32,000 bits of Random Access Memory (that's 0.004 megabytes!) probably wasn't the kind of high-wire act that Margaret Heafield Hamilton imagined for herself growing up in the Midwest. Born on August 17, 1936, in the town of Paoli, Indiana, her family soon moved to Michigan where, after graduating high school, she attended the University of Michigan, Ann Arbor, for a time. 

She soon transferred to Earlham College, back in her birth state of Indiana, though, graduating with a bachelor's degree in mathematics, with a minor in philosophy. Hamilton credits the head of the college's science department, Florence Long, for inspiring her to pursue a career in abstract maths.

While at Earlham, Hamilton also met her first husband, James Cox Hamilton, who was a senior at the college, studying chemistry. They married on June 15, 1958, and after her husband graduated from Earlham and the couple moved to Boston. There, they had a daughter, Lauren, in 1959, and Hamilton was all set to enrol in a graduate mathematics programme at Brandeis University when fate took a fortuitous turn.

Moving to MIT

Source: MIT Museum

Margaret Hamilton began working with Edward Lorenz, the father of Chaos Theory, in MIT's meteorology department. As part of her work there, Hamilton learned how to program using the PDP-1 and LGP-30 computers to create predictive models for weather forecasting.

Since computer science and programming weren't yet established fields that you could study in their own right, early programmers like Hamilton more or less had to learn on the job. "Computer science and software engineering were not yet disciplines;" Hamilton told The Guardian in 2019, "instead, programmers learned on the job. Lorenz’s love for software experimentation was contagious, and I caught the bug."

Soon, in 1961, Hamilton would move onto the SAGE project at MIT's Lincoln Lab, a project for the US Air Force to help identify potential enemy aircraft. Here, she continued to develop her skills as a programmer, and soon others were taking notice of her work.

"What they used to do when you came into this organisation as a beginner, was to assign you this program which nobody was able to ever figure out or get to run. When I was the beginner they gave it to me as well," Hamilton recalled in 2001.

"And what had happened was it was tricky programming, and the person who wrote it took delight in the fact that all of his comments were in Greek and Latin. So I was assigned this program and I actually got it to work. It even printed out its answers in Latin and Greek. I was the first one to get it to work."

Before long, her work got her noticed and she started being considered as a candidate for the lead software developer role for Nasa's upcoming Apollo missions, and eventually became the director of the software division of the MIT Instrumentation Laboratory, later renamed to the Charles Stark Draper Laboratory, which was hard at work putting together the Apollo program's guidance computer.

While she had planned to begin a graduate degree in abstract math at Brandeis University, the US space program 'won her heart'. Thanks to the success of her work at SAGE, she was the first programmer hired for the Apollo project at MIT.

The Apollo program and the work of a lifetime

Margaret Hamilton with mission support engineers for Apollo 8 | Source: Draper Laboratory

While originally brought in to Draper as a programmer, Hamilton quickly moved up in the lab until she was eventually put in charge of all of the software development for the Apollo command module's guidance computer, and later on, for the Apollo lunar lander guidance computer as well.

"Many of the things I was intrigued by had to do with how to make the mission software safe and reliable," said Hamilton. "And one of the things I remember trying very hard to do was to get permission to be able to put more error detection and recovery into the software."

That additional code meant more for the programmers at Draper to have to debug, so there was initially some resistance to this during the early Apollo missions, but eventually, Hamilton got her way.

Hamilton's doggedness for tracking down errors in the Apollo guidance computer's code also inspired a much more rigorous approach to programming than existed at the time. 

Source: MIT Museum

"We began to analyse all of the errors that had taken place on the flight software when we were actually in validation and verification mode," said Hamilton. "When each of many of the error reports came in asking for 'reason for error,' the engineers would fill in a response and they would just say 'bug' and that wasn't enough.

"So we got very interested in how we wrote errors up, so that if we understood the error, then we could maybe prevent it on the next mission. We did a thorough analysis of the on-board flight software, including the errors themselves, and began to categorise those errors. For example, one category is if you took certain steps, it would have been eliminated. Another category, if you took certain steps, it would have been eliminated."

This more systematised approach to software programming inspired Hamilton to start calling it software engineering, and the term has stuck ever since.

How Hamilton's code saved the Apollo 11 Moon landing

 

One of the repeated problems that Hamilton and her team would run up against were the astronauts themselves. 

"So one of the things that we were really worried about is what if the astronaut made a mistake – we were also told that the astronauts would never make any mistakes, because they were trained never to make mistakes," recalled Hamilton.

One such mistake came at a critical moment in the Apollo 11 mission. About three minutes before the lander was set to touch down on the lunar surface, warning lights started flashing, indicating that the Apollo guidance computer's CPU was overloaded.

What had actually happened was that the checklist that the Apollo 11 astronauts were using during the descent told them to toggle a switch for the rendezvous radar incorrectly, which ended up flooding the CPU with extraneous data that it didn't need for the landing.

While it's almost impossible for Hamilton and her team to have predicted something like this, they didn't need to. Because Hamilton anticipated an overloaded CPU, she programmed the CPU to dump low-priority jobs in the CPU's queue and flush the memory and restart them, while reserving resources for high-priority jobs – like landing the lunar module.

Her software worked exactly as it should, keeping the Apollo 11's Eagle lander on track until it touched down on the moon's surface. Had her code not done its job, Armstrong as mission commander would have had no choice but to call off the landing, which – given their fuel consumption – would have led to the mission failing then and there.

Later work

After the Apollo program, Hamilton continued to work on space missions for Nasa, helping program Skylab, Nasa's first space station, as well as working on the early stages of Nasa's Space Shuttle program developing software studies for operating systems, distributed processing, redundant management, error detection and recovery, and more.

In 1976, Hamilton left Draper Laboratory and co-founded a company called Higher Order Software, which focused on error prevention in software, inspired largely by her experience working on the Apollo program.

She remained the CEO of Higher Order Software until 1986, when she left to found her own company called Hamilton Technologies, focused on promoting the Development Before the Fact software design paradigm. 

Legacy 

Margaret Hamilton receiving the Presidential Medal of Freedom in 2016 | Source: The White House/Wikimedia Commons

There's no question that Margaret Hamilton is a computer science icon, and her work has earned her numerous awards from academic institutions and computer science organisations over the years. She was even awarded the Presidential Medal of Freedom by President Obama in 2016.

More importantly, though, she is undoubtedly an inspiration for young girls around the world. 

"What I think about when I think about Margaret Hamilton is her quote that 'there was no choice but to be pioneers,' because I think that really embodies who she was and her significance in this program,” Teasel Muir-Harmony, a curator at the Air and Space Museum and author of the book Apollo to the Moon: A History in 50 Objectstold Smithsonian Magazine in 2019.

“She was a pioneer when it came to development of software engineering and . . . a pioneer as a woman in the workplace contributing to this type of program, taking on this type of role.”