R.I.P. Margaret Hamilton, whose code saved the Apollo 11 Moon landing

Hamilton also coined the term “software engineering” and founded two successful software companies.

Margaret Hamilton, who coined the term “software engineering” and led the development of on-board flight software for NASA’s Apollo program in the 1960s, died last week at the age of 90. A recipient of the Presidential Medal of Freedom in 2016, Hamilton was also immortalized as a LEGO minifig the following year—part of the “Women of NASA” set that also included astronauts Mae Jemison and Sally Ride.

“To say Margaret Hamilton was a pioneer—to say she was ahead of her time—would be a dramatic understatement. She was a software engineer at a time when that field was in its infancy, and she not only developed advanced code herself but also led a team in using that nascent technology to develop one of the most complex systems humanity had ever achieved,” said Olivier de Weck, interim head of the MIT Department of Aeronautics and Astronautics. “The Apollo program still stands as one of our greatest testaments to the power of collaboration, ingenuity, and engineering, and Hamilton was a fundamental contributor to that program’s success.”

Born in 1936 in Paoli, Indiana, Hamilton graduated from Earlham College in 1958 with a degree in mathematics and a minor in philosophy—the latter a nod to her father (a poet) and grandfather (a headmaster). She married her first husband, James Cox Hamilton, that same year. The plan was for her to work until he finished his law degree, after which he would support her through graduate school to earn a PhD in mathematics.

She ended up working for Edward Lorenz, the MIT mathematician who set out to construct a mathematical model of the weather using a set of differential equations representing changes in temperature, pressure, wind velocity, and the like. You’ve probably heard the famous story of how Lorenz kept a continuous simulation running on his LGP-30 computer, and of that fateful 1961 day when he realized that even small differences in starting values could lead to very different outcomes—a sensitivity to initial conditions that is a hallmark of chaos theory, along with strange attractors. You might not have known that it was Hamilton who was responsible for programming the LGP-30.

Computers were still a novelty at the time, and neither Lorenz nor Hamilton had any programming knowledge; they taught themselves. Per a 2019 Quanta article, Lorenz was amused by her unusual methods: for instance, she once bypassed the “clunky debugging process” by rolling out the paper tape down the hallway and editing the binary code by hand with a pencil. “I’d poke holes for ones, and I’d cover up with Scotch tape the others,” she recalled. Hamilton moved to another project in 1961, but not before training her replacement: a recent math graduate from Mount Holyoke named Ellen Fetter. Lorenz acknowledged the contributions of both women in his papers.

To the Moon

Hamilton in 1969, standing next to listings of the Apollo guidance software she and her MIT team produced.
Hamilton’s official photo for NASA, 1989
Margaret Hamilton holds a LEGO minfig of herself in 2017.
Hamilton’s official photo for NASA, 1989
Margaret Hamilton holds a LEGO minfig of herself in 2017.

In 1961 Hamilton moved to the SAGE project at MIT, writing software for a prototype XD-1 computer to aid the US Air Force in searching for possible enemy aircraft. Her first challenge: deciphering a program nobody had managed to get to work, perhaps because the author’s notes were written in Latin and Greek. Hamilton succeeded, noting with amusement that the program even printed out its answers in Greek and Latin. It was during this period that she became interested in the issue of software reliability.

By 1965, Hamilton was all set to go to graduate school as planned when her husband spotted a newspaper ad saying that MIT’s Instrumentation Lab needed people to develop onboard guidance computer software for NASA’s Apollo program. She was the first programmer hired, and the first woman, working on six lunar landing missions from 1969 to 1972. At the time, binary code was stored using copper wires wound around cores. A “1” was a wire passing through a core, and a “0” was a wire bypassing the core. New England textile workers were hired to weave them together into long ropes, earning Hamilton the moniker “rope mother,” since she was responsible for those ropes.

Hamilton would often bring her 4-year-old daughter, Lauren, to the lab on nights and weekends. The child loved pretending to be an astronaut in the simulators, and one day all her random button-pressing caused the system to inexplicably crash. Apparently Lauren had typed “P01,” a pre-launch sequence, in the middle of the mission. Hamilton asked NASA if she could add a safeguard to prevent this from happening on an actual mission, but the higher-ups didn’t take it seriously. Then astronaut Jim Lovell actually made that error during the Apollo 8 manned mission to orbit the Moon, causing the navigational data to vanish. Hamilton was called in to retrieve the data, jokingly referring to this as the “Lauren bug.”

By 1968 Hamilton was assistant director in charge of the Command and Service Module team. Hamilton had the idea to incorporate a failsafe into the system software’s “priority display” interface routines, should the onboard guidance computer become overloaded with more tasks than it could handle in real time.

That’s exactly what happened on the historic Apollo 11 mission in 1969. As the Eagle lunar module approached the Moon, Buzz Aldrin entered the codes to display altitude and other relevant data on the screen. The onboard computer started flashing alarms, forcing Mission Control to consider aborting the landing. Hamilton’s failsafe meant that the computer was prioritizing essential tasks and cancelling nonessential ones, and the alarm was to let astronauts know that this was happening. Thanks to Hamilton’s foresight, Eagle still safely landed on the Sea of Tranquility.

As Hamilton herself later recalled in a 1971 letter:

The computer (or rather the software in it) was smart enough to recognize that it was being asked to perform more tasks than it should be performing. It then sent out an alarm, which meant to the astronaut, “I’m overloaded with more tasks than I should be doing at this time and I’m going to keep only the more important tasks”; i.e., the ones needed for landing … Actually, the computer was programmed to do more than recognize error conditions. A complete set of recovery programs was incorporated into the software. The software’s action, in this case, was to eliminate lower priority tasks and re-establish the more important ones … If the computer hadn’t recognized this problem and taken recovery action, I doubt if Apollo 11 would have been the successful Moon landing it was.

The Apollo software she helped develop was added to GitHub in 2015. In 2019, Google marked the 50th anniversary of the Moon landing—and Hamilton’s crucial contribution—by training over 100,000 mirrors at its Mojave Desert solar power farm to create a massive portrait of Hamilton in reflected moonlight.

After the Apollo program ended, the Instrumentation Lab became the independent Draper Laboratory. Hamilton worked there until 1976, when she founded Higher Order Software, based on her work on error prevention and fault tolerance. In 1985 she left the company to found Hamilton Technologies. Its main product is the Universal Systems Language (USL) for developing complex software systems that prioritized error prevention and defensive programming.

Hamilton is survived by her daughter, Lauren Hamilton; her son-in-law, Richard Selesnick; two grandsons; four great-grandchildren; and her siblings John, David, and Kathryn.

Original source R.I.P. Margaret Hamilton, whose code saved the Apollo 11 Moon landing

Back to home