Photo Of The Day

code

Margaret Hamilton

The Woman Who Put The Man on the Moon

The volumes were filled with handwritten code for NASA, the very same code that was responsible for safely landing people on the moon.

Neil Armstrong might not have taken his moon walk on July 20, 1969 were it not for a former high school teacher named Margaret Hamilton.

Three minutes before the Apollo 11 lunar lander Eagle reached the surface of the moon, computer alarms went off. The landing would have been aborted had Hamilton not anticipated the problem and created software to solve it.

Margaret Heafiled Hamilton; was 33 when she wrote the code for NASA in 1969. At the time, she was also the Director of the Software Engineering Division of the MIT Instrumentation Laboratory. NASA, anxious to win the space race, called on her to create “the onboard flight software needed to land on the moon.” She was selected as team leader and tasked with making the Apollo missions successful.

This wasn’t just a cool job placement for a woman. In 1969, Software Engineering didn’t exist — she actually coined the term while making it a reality. Hamilton raised the bar even higher by helping her team create ultra-reliable software. She developed priority displays that allowed the software to interrupt astronauts in an emergency so that “they could reconfigure in real-time.” Hamilton debugged and tested every aspect of her work prior to assembly. Before signing off on the code, she “simulated every conceivable situation at the systems level to identify potential problems.”

“There was no second chance. We all knew that,” Hamilton said. “We took our work very seriously, but we were young, many of us in our 20s. Coming up with new ideas was an adventure. Dedication and commitment were a given. Mutual respect was across the board. Because software was a mystery, a black box, upper management gave us total freedom and trust. We had to find a way and we did. Looking back, we were the luckiest people in the world; there was no choice but to be pioneers; no time to be beginners.”

On July 20, 1969, Hamilton’s ultra-reliable software prevented a command from a faulty script from interrupting — and possibly ruining — the Apollo 11 mission. Three minutes before the Eagle landed, her dedication to programming, testing and simulating possible scenarios paved the way for Neil Armstrong and Buzz Aldrin to settle safely on the moon. Behind every great man is a damn good software engineer…

It wasn’t until 2003 — mind you, after she started her own software company, Hamilton Technologies, Inc., in 1986 — that NASA finally and formally recognized her work. She was nominated by Dr. Paul Curto, senior technologist for NASA’s Inventions and Contributions Board, who was also unhappy with the lackluster response to her work. He “was surprised to discover that she was never formally recognized for her groundbreaking work. Her concepts of asynchronous software, priority scheduling, end-to-end testing and man-in-the-loop decision capability, such as priority displays, became the foundation for ultra-reliable software design.”

Margaret Hamilton, the lead Apollo flight software designer, in a mockup of the Apollo Command Module. The Apollo flight software was one of the earliest successful and most significant developments of flight software as we know it today. It was a pioneering effort which performed exceptionally forApollo. Photo MIT.

Margaret Hamilton, the lead Apollo flight software designer, in a mockup of the Apollo Command Module. The Apollo flight software was one of the earliest successful and most significant developments of flight software as we know it today. It was a pioneering effort which performed exceptionally forApollo. Photo MIT.

MIT computer scientist Margaret Hamilton wrote critical flight software.

MIT computer scientist Margaret Hamilton wrote critical flight software.

Hamilton, far left, sits with some of her staff in the Scama room at MIT, while supporting the Apollo 8 mission. Photo: Margaret Hamilton.

Hamilton, far left, sits with some of her staff in the Scama room at MIT, while supporting the Apollo 8 mission. Photo: Margaret Hamilton.

Hamilton with one of her former colleagues on April 19, 1962. Hamilton was developing software on the first AN/FSQ-7 computer at Lincoln Labs. Hamilton’s software program was a radar registration surveillance program used for detecting potential enemy planes. Photo Margaret Hamilton.

Hamilton with one of her former colleagues on April 19, 1962. Hamilton was developing software on the first AN/FSQ-7 computer at Lincoln Labs. Hamilton’s software program was a radar registration surveillance program used for detecting potential enemy planes. Photo Margaret Hamilton.

Close-up view of Raytheon copper wires. JACK POUNDSTONE/RAYTHEON.

Close-up view of Raytheon copper wires. JACK POUNDSTONE/RAYTHEON.

A Raytheon worker weaving copper wires through magnetic rings. JACK POUNDSTONE/RAYTHEON

A Raytheon worker weaving copper wires through magnetic rings. JACK POUNDSTONE/RAYTHEON

“Little Old Ladies” of Raytheon. JACK POUNDSTONE/RAYTHEON

“Little Old Ladies” of Raytheon. JACK POUNDSTONE/RAYTHEON

Margaret Hamilton wasn’t supposed to invent the modern concept of software and land men on the moon. It was 1960, not a time when women were encouraged to seek out high-powered technical work. Hamilton, a 24-year-old with an undergrad degree in mathematics, had gotten a job as a programmer at MIT, and the plan was for her to support her husband through his three-year stint at Harvard Law. After that, it would be her turn—she wanted a graduate degree in math.

But the Apollo space program came along. And Hamilton stayed in the lab to lead an epic feat of engineering that would help change the future of what was humanly—and digitally—possible.

As a working mother in the 1960s, Hamilton was unusual; but as a spaceship programmer, Hamilton was positively radical. Hamilton would bring her daughter Lauren by the lab on weekends and evenings. While 4-year-old Lauren slept on the floor of the office overlooking the Charles River, her mother programmed away, creating routines that would ultimately be added to the Apollo’s command module computer.

“People used to say to me, ‘How can you leave your daughter? How can you do this?’” Hamilton remembers. But she loved the arcane novelty of her job. She liked the camaraderie—the after-work drinks at the MIT faculty club; the geek jokes, like saying she was “going to branch left minus” around the hallway. Outsiders didn’t have a clue. But at the lab, she says, “I was one of the guys.”

Then, as now, “the guys” dominated tech and engineering. Like female coders in today’s diversity-challenged tech industry, Hamilton was an outlier. It might surprise today’s software makers that one of the founding fathers of their boys’ club was, in fact, a mother—and that should give them pause as they consider why the gender inequality of the Mad Men era persists to this day.

As Hamilton’s career got under way, the software world was on the verge of a giant leap, thanks to the Apollo program launched by John F. Kennedy in 1961. At the MIT Instrumentation Lab where Hamilton worked, she and her colleagues were inventing core ideas in computer programming as they wrote the code for the world’s first portable computer. She became an expert in systems programming and won important technical arguments. “When I first got into it, nobody knew what it was that we were doing. It was like the Wild West. There was no course in it. They didn’t teach it,” Hamilton says.

This was a decade before Microsoft and nearly 50 years before Marc Andreessen would observe that software is, in fact, “eating the world.” The world didn’t think much at all about software back in the early Apollo days. The original document laying out the engineering requirements of the Apollo mission didn’t even mention the word software, MIT aeronautics professor David Mindell writes in his bookDigital Apollo. “Software was not included in the schedule, and it was not included in the budget.” Not at first, anyhow.

But as the Apollo project unfolded, the centrality of software in accomplishing the mission started to become clear. In 1965, Hamilton became responsible for the onboard flight software on the Apollo computers. It was an exciting time, and the US was depending on the work that she was doing. But sometimes the pressure kept Hamilton up at night. Once, after a late-night party, she rushed back to the computer lab to correct a piece of code she’d suddenly realized was flawed. “I was always imagining headlines in the newspapers, and they would point back to how it happened, and it would point back to me.”

By mid-1968, more than 400 people were working on Apollo’s software, because software was how the US was going to win the race to the moon. As it turned out, of course, software was going to help the world do so much more. As Hamilton and her colleagues were programming the Apollo spacecraft, they were also hatching what would become a $400 billion industry.

For Hamilton, programming meant punching holes in stacks of punch cards, which would be processed overnight in batches on a giant Honeywell mainframe computer that simulated the Apollo lander’s work. “We had to simulate everything before it flew,” Hamilton remembers. Once the code was solid, it would be shipped off to a nearby Raytheon facility where a group of women, expert seamstresses known to the Apollo program as the “Little Old Ladies,” threaded copper wires through magnetic rings (a wire going through a core was a 1; a wire going around the core was a 0). Forget about RAM or disk drives; on Apollo, memory was literally hardwired and very nearly indestructible.

Apollo flights carried two near-identical machines: one used in the lunar module—the Eagle that landed on the moon—and the other for the command module that carried the astronauts to and from Earth. These 70-pound Apollo computers were portable computers unlike any other. Conceived by MIT engineers such as Hal Laning and Hamilton’s boss, Dick Batton, it was one of the first important computers to use integrated circuits rather than transistors. As Mindell tells the story, it was the first computerized onboard navigation system designed to be operated by humans but with “fly-by-wire” autopilot technology—a precursor to the computerized navigation systems that are now standard on jetliners.

The system stored more than 12,000 “words” in its permanent memory—the copper “ropes” threaded by the Raytheon workers—and had 1,024 words in its temporary, erasable memory. “It was the first time that an important computer had been in a spacecraft and given a lot of responsibility for the mission,” says Don Eyles, who worked on the lunar module code while at MIT’s IL. “We showed that that could be done. We did it in what today seems an incredibly small amount of memory and very slow computation speed.” Without it, Neil Armstrong wouldn’t have made it to the moon. And without the software written by Hamilton, Eyles, and the team of MIT engineers, the computer would have been a dud.

This became clear on July 20, 1969, just minutes before Apollo 11 touched down on the Sea of Tranquility. Because of what Apollo software engineer Don Eyles has termed a“documentation error,” the Apollo computer started spitting out worrying error messages during this critical phase of the mission. But here’s where the technical arguments won by Hamilton and others saved the day. The error messages were popping up because the computer was being overwhelmed, tasked with doing a series of unnecessary calculations when, in fact, it was most needed to land the module on the surface of the moon. Back in Houston, engineers knew that because of Apollo’s unique asynchronous processing, the computer would focus on the task at hand—landing the Eagle on the Sea of Tranquility. When the software realized it didn’t have enough room to do all the functions it was supposed to be doing, it went through its error detection process and focused on the highest priority job, Hamilton says.

One day, Lauren was playing with the MIT command module simulator’s display-and-keyboard unit, nicknamed the DSKY (dis-key). As she toyed with the keyboard, an error message popped up. Lauren had crashed the simulator by somehow launching a prelaunch program called P01 while the simulator was in midflight. There was no reason an astronaut would ever do this, but nonetheless, Hamilton wanted to add code to prevent the crash. That idea was overruled by NASA. “We had been told many times that astronauts would not make any mistakes,” she says. “They were trained to be perfect.” So instead, Hamilton created a program note—an add-on to the program’s documentation that would be available to NASA engineers and the astronauts: “Do not select P01 during flight,” it said. Hamilton wanted to add error-checking code to the Apollo system that would prevent this from messing up the systems. But that seemed excessive to her higher-ups. “Everyone said, ‘That would never happen,’” Hamilton remembers.

But it did. Right around Christmas 1968—five days into the historic Apollo 8 flight, which brought astronauts to the moon for the first-ever manned orbit—the astronaut Jim Lovell inadvertently selected P01 during flight. Hamilton was in the second-floor conference room at the Instrumentation Laboratory when the call came in from Houston. Launching the P01 program had wiped out all the navigation data Lovell had been collecting. That was a problem. Without that data, the Apollo computer wouldn’t be able to figure out how to get the astronauts home. Hamilton and the MIT coders needed to come up with a fix; and it needed to be perfect. After spending nine hours poring through the 8-inch-thick program listing on the table in front of them, they had a plan. Houston would upload new navigational data. Everything was going to be OK. Thanks to Hamilton—and Lauren—the Apollo astronauts came home.

Also thanks to Hamilton and the work she led, notions of what humanity could do, and be, changed not just beyond the stratosphere but also here on the ground. Software engineering, a concept Hamilton pioneered, has found its way from the moon landing to nearly every human endeavor. By the 1970s, Hamilton had moved on from NASA and the Apollo program. She went on to found and lead multiple software companies. Today her company, Hamilton Technologies, is just a few blocks away from MIT, where her career began—a hub of the code revolution that’s still looking toward the stars.

Margaret Hamilton at the MIT Museum in Cambridge, MA. Photo: HARRY GOULD HARVEY IV.

Margaret Hamilton at the MIT Museum in Cambridge, MA. Photo: HARRY GOULD HARVEY IV.

How many lines of code went into the Lunar Lander?

It’s difficult to understand how to get a feel of how complex the programming of the lander was, but “lines of code” is a terribly poor measurement of anything. You can’t compare it, you can’t judge anything by it, and it doesn’t really say anything at all (other than how many lines there were in some files).

In any case — the 1960 code wasn’t typed on computers as much as punched on cards. It was, of course, typed on typing machines for keeping, because the protocols dictated that rather than writing it by hand. Hence the photo showing Margaret Hamilton next to print-outs of the Apollo Guidance Computer source code.

It’s important to understand that nobody went and typed all that code into anything that looked like your Lenovo.

And the language in which it was written (AGC Assembly Code) meant that even the simplest things took a lot of lines to write. Things that today take one line in a high-level language might’ve taken two pounds of punched cards, back in the day.

It’s also important to understand that most of the code written on Earth isn’t like the Apollo code. Nowadays, code is considered fine if it covers about 80-90% of all possible situations, because it’s a lot cheaper to leave out the very improbable. Back then, they wrote backups literally for everything. And well they did, as Margaret herself says:

Due to an error in the checklist manual, the rendezvous radar switch was placed in the wrong position. This caused it to send erroneous signals to the computer. The result was that the computer was being asked to perform all of its normal functions for landing while receiving an extra load of spurious data which used up 15% of its time. 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.

Margaret Hamilton, Director of Apollo Flight Computer Programming MIT Draper Laboratory, Cambridge, Massachusetts, “Computer Got Loaded”, Letter to Datamation, March 1, 1971

Margaret Hamilton, the Engineer Who Took the Apollo to the Moon …

Margaret Hamilton, the Woman Who Put the Man on the Moon – New …

Meet Margaret Hamilton, the badass ’60s programmer who saved the …

Remembering the Apollo 11 Moon Landing With the Woman Who …

Apollo 11 mission’s 40th Anniversary – The official Google Code blog

Apollo 11: The computers that put man on the moon

Latest: How Code Has Changed Since The Apollo 11 Moon Landing

 


THANK YOU for being a subscriber. Because of you Whaleoil is going from strength to strength. It is a little known fact that Whaleoil subscribers are better in bed, good looking and highly intelligent. Sometimes all at once! Please Click Here Now to subscribe to an ad-free Whaleoil.

  • Nermal

    Not all heroes wear capes. An amazing achievement considering how far computing has come since then.

  • Andy

    Gosh it makes me feel old to admit that I started programming on punched cards and paper tapes. We did have a better discipline then, because errors took so long to correct.

  • Wasapilot

    No sign of any glass ceilings, being held back due to gender etc here. The best person for the job, so obviously.

    A great story, thanks Lux.

  • Paul Marsden

    Brilliant woman. Great story. Thank you.

22%