On the 20th of July 1969, Apollo II landed successfully on the Moon. It is now a familiar picture in all the science and history books, how Neil Armstrong and Buzz Aldrin, the two astronauts clad in their trademark white spacesuit, stepped out of the capsule and took their first tentative steps upon the surface of the moon. And of course, Armstrong’s epigrammatic pronouncement: “One small step for man, is one giant leap for mankind” immortalized the euphoria and the ecstasy of that moment for generations to come. It was indeed a scientifically momentous victory for mankind when man landed on the moon. Since the time Copernicus and Kepler reinstated the Sun as the center of the solar system, and Newton worked out the forces of gravity, it has been man’s abiding quest to lift himself out of Earth’s orbit, not just above the fluffy clouds, but to soar beyond it, to the distant satellites and planets, especially the fascinating and tantalizing moon, which has been part of human culture from the dawn of civilization. We have always wondered at the mystery of the moon, its waxing and waning, its silhouetted brilliance, and secretly longed to set foot on it. It took three centuries of scientific enterprise to make the trip to the moon, and when we did it, it was literally was “the” dream come true.
But not many know that Apollo II’s mission was nearly aborted before it landed on the moon. Three minutes before landing, the display screens in the spacecraft changed to show alarming messages, triggered by something that the astronauts had done or not done. For a few minutes, It looked like, Apollo couldn’t, after all, land. But thankfully, the miracle of the underlying software system kicked in. The system that drove the sequence of tasks, quickly registered those alarms, re-prioritized the tasks, and ensuring the execution required for landing was normalized and flawless. What could have been a disaster, turned out to be a minor glitch that fixed itself, and nothing more. The software that performed this extraordinary feat was the effort of a young lady working at NASA – Margaret Hamilton, a software programmer, who along with her team, conceived, developed, and deployed the complex multitasking code that powered the spacecraft.
The lunar landing was one of the first attempts to entrust software with such a mission-critical, real-time task. Though software was used in radars and weaponry in the Second World War, the precision those systems required were nothing compared to that of landing a spacecraft on the moon. In Apollo’s case, not only should anything fail, but everything about the execution had to be mathematically accurate to the last decimal point. Even the slightest deviation could abort and jeopardize the mission. Add to this, the constraints on the kind of chip, the size, and the weight of the computer that could be used in a spacecraft. Would you believe that Apollo 11 had only 64 KB memory in total, and that was all the memory the underlying software had for use during the entire trip—from take-off to landing on the moon? Such a task is daunting, even with unlimited resources at hand! A modern-day programmer would shudder to even attempt what Margaret and her team so audaciously did. It is inconceivable at the distance to imagine the degree of rigor, coding discipline, and precision that would have been necessary to write such code. Thankfully, Margaret was ripe for such an effort. She was an exceptionally good mathematician and programmer; she knew what was needed to develop such a system. For her contributions to the art and science of coding, she was awarded the Augusta Ada Lovelace (Lady Ada was the first known software programmer in the history of computer science) Award by the Association of Women in Computing in 1986.
In 2016, President Obama conferred the highest civilian honor of the Presidential Medal of Freedom to Margaret for her seminal role in landing Apollo on the moon. In 2003, NASA had already felicitated her for her exceptional contribution to space travel. Along with Lieutenant Grace Hopper, another important and pioneering female software programmer, Margaret, established the rudiments of what today is considered the discipline of Software engineering. In fact, the term “engineering” was applied to software for the first time by Margaret while she was working on the Apollo 11 project. She established the principle that creating software was not just about writing code, but also, equally, about the application of core engineering principles to the outcomes required. Until her time, software was considered an esoteric hobby, a magical diversion, an uncharted territory. But after Margaret’s committed effort in MIT labs to bring together the hardware and software practices to create the in-flight software to run Apollo, the elusive art and study of software programming began to metamorphose into a disciplined engineering discipline, occupying a prime spot alongside other established branches of engineering. That will be Margaret’s lasting legacy, alongside successfully landing Apollo on the moon.
Margaret Elaine Heafield was born in Paoli, Indiana on August 17, 1936. As a child, Margaret was precocious, and deeply interested in mathematics, the foundation of all sciences. She graduated in mathematics from the University of Michigan along with a minor in philosophy—an interest that was passed on to her by her poet father and her grandfather, who believed in a liberal arts education as a means to develop holistically and out of the box thinking. However, it was Margaret’s years at MIT, under the tutelage of Dr. Edward D Lorenz, when she blossomed into a full-fledged mathematician. Dr. Lorenz worked in the meteorology department of MIT. He was an acclaimed mathematician himself, and widely known in the scientific community for his Chaos theory and coined the term the “Butterfly effect” to indicate the rippling effects that can be caused by an insignificance chain of causation. Margaret’s first experience with software happened under Dr. Lorenz.
When NASA offered MIT the project to build software for the Apollo space mission, she applied and got the job. Legend has it that the managerial team tossed a coin to decide whose group she would join. The story may be apocryphal, but the good news was she was chosen to work with the group that developed software. Margaret later explained that gender didn’t play too much a part in her selection. Though software programming, at that time, was mostly the prerogative of the Male fraternity, Margaret adapted well and quickly became part of the core group, working with multiple teams, across the project. She learned to work with computers as big as a warehouse and also learned to write software programs in hexadecimal and binary instructions—the low-level assembly code required to run the spacecraft. Under Dr. Lorenz’s scrutinizing eyes, she also contributed to the development of operating systems, an effort that played a crucial role in controlling and prioritizing the hardware of the spacecraft.
Interestingly, the most important contribution of Margaret to the field of software engineering is her insistence on error handling, which proved to be invaluable for the command control systems in Apollo. In any mission-critical system, one should know when things can go bad, and more importantly, factor those errors in the software so that it can gracefully recover and carry on. There is a wonderful anecdote that illustrates Margaret’s approach to identifying problems and fixing them. During the days when Margaret spent most of her time at the MIT instrumentation lab working on the Apollo code, she would bring her daughter Lauren in as well, as many working mothers do even today. Lauren loved playing the role of the Astronaut using the simulator in which the code was tested. It so happened, one day, the little girl inadvertently hit a button that triggered off the pre-launch routine of the spacecraft when the simulation was running and in a mid-flight state. The code wasn’t programmed to handle this condition, it irrevocably crashed and undid many days of hard work and testing. But Margaret did not lash out at Lauren for her playfulness. Instead, she paused and reasoned that such an error can be caused by anyone, including the astronauts onboard during a critical mission where so many instructions need to be followed. Therefore, this event must be taken into account in the software and handled gracefully. Margaret immediately lobbied for appropriate code interventions within the team to fix this issue. Great software is often built this way. The “what if” mentality dominated Margarets’s approach to programming. She always asked herself this basic question: “What if something you never thought would happen, happens?”.
The picture you see above is historically significant. The frail, petite, short, and smiling Margaret standing alongside reams of paper, stacked one upon the other, are the coding abstracts of what went into Apollo II. Most of it was written in what we call today as assembly-level code. She wasn’t too savvy with programing when she was recruited to code for the Apollo project, but she learned quickly, spurred by great curiosity, passion, and enthusiasm. And she wasn’t afraid of approaching a daunting problem. In a wonderful comment, she made in an interview some years ago, which could be a mantra for every potential programmer or any professional for that matter, she said: “what seems to work best for me when I want to learn about anything new or to do anything new is not to let fear get in the way…” There cannot be a truer message than this: Learn without fear.
In another interview, when asked about her groundbreaking contribution to the Apollo Project, Margaret only had this to say “ We had no choice but to be pioneers”. As a fitting tribute to Margaret Hamilton’s contribution to software engineering and her work on the Apollo 11 mission, Google created a magnificent tribute to her on the fiftieth anniversary of the Apollo 11 mission. A tribute made of reflected moonlight was created by positioning over 107,000 mirrors at the Ivanpah Solar Facility in the Mojave Desert. These mirrors were focused on the moon, and not the sun. The result was a spectacular 1.4-square-mile portrait of Margaret, bigger than New York’s Central Park.
It is because of the pioneering work of women like Margaret Hamilton that more and more women found their way into STEM fields carving special niches for themselves. The computer on board the Apollo 11 spacecraft was the world’s first portable computer, and Margaret and her colleagues wrote the code for it. It is an achievement that speaks volumes about this brilliant innovator and software engineer.