this is a source code that took humans to the moon in 1969. Usually, when you think about the moon landing, you think about these guys. The three brave astronauts that went to the moon.
You probably also think about Saturn 5. Which was the rocket that was used to take them to the moon. but the actual source code that took us to the moon, the computer that took us to the moon, known as the Apollo guidance computer, Unfortunately, it didn't get that much media hype, which is sad because even if you're not a software engineer or you haven't coded before, The Apollo 11 guidance computer and the source code is pretty interesting and actually tells a really great story.
the Apollo 11 mission was the first time humans landed on the moon. it happened on July 29th, 1969. And naturally the mission had a lot of moving parts.
We have the Saturn V, The Saturn V was a three stage rocket that launched the Apollo 11 mission from Earth. Standing at over 360 feet tall, the Saturn V was designed to lift heavy loads into space. And its job was to carry the entire Apollo spacecraft consisting of the command module and the lunar module out of Earth's gravity and into space.
Essentially setting up the mission for the journey to the moon. So before I go on to review the Apollo 11 guidance computer and the source code, it's important to know about the mission. The Apollo 11 spacecraft was actually two separate entities.
you have the command module and the lunar module. The command module was used to get the three astronauts to the moon and back again. Essentially, the command module was the cone that contained the crew and any vital equipment.
It was also the vessel that was returned back to earth. the astronauts inside of the command module. Well, you probably know of them.
They were Neil Armstrong, Buzz Aldrin and Michael Collins. Michael Collins was a command module pilot. He stayed in orbit around the moon and just ensured that the command module was always ready and functioning.
The lunar module was a module that was used to land the two astronauts to the moon while Michael Collins actually remained in the command module The two astronauts landing on the moon was none other than Neil Armstrong. And of course, Buzz Aldrin. I keep saying Buzz Lightyear.
Now, if you think about each of these modules, well, they needed to actually navigate through space. Sometimes with the help of astronauts, but sometimes these modules needed to actually navigate themselves. And this is why they needed a computer or better put a guidance system.
And excuse my language, but it was a fucking cool guidance system. So we know that the command module and the lunar module needed to be guided through space. It needed a guidance computer.
Well, enter the Apollo guidance computer or better yet known as the AGC. The Apollo Guidance Computer was a component of the Apollo's missions guidance system. Each mission had two AGCs, one in the command module and one in the lunar module.
and although the guidance computers were actually identical in hardware, they ran different software that was actually tailored to the specific tasks of the module. The tasks of the lunar module would be different to the tasks of the command module. Lunar module was for landing on the moon.
Command module was for the vessel transporting the astronauts there and back. by today's standards, the AGC was extremely, I want to say underpowered. but don't get that confused with the AGC being simple.
the AGC is a complicated computer. You may have heard media often describing the Apollo guidance computer as being more like a calculator than a modern computer. This has been disagreed by many experts in the field.
It's not a simple piece of software like a calculator. It really just undersells its capabilities. and you'll see as we go on how much the AGC was able to do.
The actual computer was sophisticated enough to support multitasking, which allowed it to run multiple programs simultaneously. And you know, this is in 1969. This was obviously quite a crucial feature for a mission with really many, many demands.
The myth about it being a calculator was probably because the interface looks a lot like a calculator. It looks like this. And this is all you would see.
So this is actually known as the display or keyboard unit. Often it's abbreviated to DSKY. I'm going to call it DISKY because that sounds quite cool.
And the DSKY provided the interface for the astronauts to actually interact with the Apollo guidance computer. Now the DSKY operated by using a simple noun verb system. the verb is the action that the astronauts wanted the computer to perform, such as, you know, display information, perform a calculation, and the noun was the specific data or parameter that they wanted to interact with, such as altitude, speed, velocity, whatever.
so, for example, if the astronaut wanted to see the current time, they would enter a verb and then a number like 16 followed by noun, and then another number like 65, once they press enter, the AGC would output the respected information into the display area or the display. Now, at the time, having a display interface like Disky wasn't common in the programming world. In 1969, your average software engineer was actually still using punch cards to code, which is pretty insane if you think about it.
Punch card programming was actually still used well into the seventies at that time. But because the AGC at NASA's headquarters and the one in the actual spacecraft had to communicate and run multiple tasks all at once, the AGC actually needed something that we take for granted today, which is a display or an interface. so DSKY wasn't really common for all computers at the time, but they needed it because of the specific mission.
The actual guidance computer or the AGC itself is just a box with electronic definitely lacking in a built in user interface. so the DSKY allowed the astronauts to input commands and view data. and again, for today's standards, the Apollo guidance computer was underpowered.
It's just amazing how much they managed to accomplish with so little. With so little. The AGC had a RAM of 3, 840 bytes.
It had a read only memory equivalent to about 69, 000 bytes. So comparing it to a modern smartphone, the AGC's RAM was about 0. 00000045 percent of the RAM in a smartphone.
Again, a really groundbreaking computer of the time. That being said, you can't really compliment a computer without complimenting its source code. And the source code, that's pretty epic.
This is Margaret Hamilton. She was the director of software engineering at the MIT instrumentation lab. the lab was contracted to build the onboard software for the Apollo missions, not only Apollo 11, there were multiple Apollo missions.
You probably would have seen this picture before when you read about the Apollo missions and Margaret Hamilton or the software engineering side of the Apollo missions. This is Margaret and she's standing in front of the actual source code that took us to the moon. And another interesting fact about Margaret Hamilton is that she actually coined the term software engineer.
And Margaret and her team developed the source code for the Apollo 11 mission. And this is it. We were lucky enough because in 2016, former NASA intern, Chris Gary, uploaded the source code for the Apollo 11 guidance computer.
I'll link it in the video description. The software was written mostly in assembly language, which is actually what you see here. Assembly language is indeed one of the more challenging languages in programming to work with.
It's an older language. I haven't worked on assembly before, but generally people who have worked on assembly are quite experienced developers. Assembly itself is a low level programming language that provides your direct control.
over a computer's hardware. Essentially, it sits above machine code. Machine code is actual binary instructions that the computer's CPU executes.
In other words assembly is a programming language that lets the programmer give instructions that are very detailed and very specific. Almost like speaking directly to the computer's brain. But assembly is much more easier to understand than the raw machine code, which is what a computer thinks in.
And raw machine code is essentially just binary. It's a bunch of ones and zeros. So the actual software for the Apollo 11 consists of two major programs.
If you get the luminary, and this program ran on the A GC inside the lunar module, guiding it during the lunar descent, and landing which you can see in the GitHub repo, which you can see here. All the luminary code is in the luminary 0 9 9 folder. So whenever you think of luminary or lunar, it has to do with the moon landing.
The other part of the software is Colossus. So this code ran on the AGC inside the command module. Remember the command module was responsible for transporting, handling navigation, docking, and obviously re entry to earth.
And in the GitHub repo, all the Colossus code is inside the folder called comanche055. I'm not sure if I am saying that correctly. So we're just going to focus on the Luminary code because the two are quite similar.
Originally, the code for the Luminary was just a massive block of instructions, just one big script. But when they decided to actually make it available online, just for easier management, the developers, specifically RSP. Decided to split it into smaller pieces, each representing different sub programs or different features.
These smaller pieces are then all linked together by a file called main. agc. So you'll see that there is a file called main.
agc in each of the folders. The script is just responsible for tying all the files together. But originally the script was just written as one big block of instructions.
In modern programming, if you haven't coded before, when you create a program, it's not just one big file. How the repo is set out is how applications are generally developed nowadays. You create multiple files that are somehow linked.
So that's the actual structure of the Apollo 11, but then you get the actual code, which surprisingly has a ton of easter eggs. if you go through the actual code, you'll notice that one, there are a lot of comments, which is good. And two, there are a lot of jokes.
For instance, the ignition routine code is called burn baby burn. That's the name of that part of the code. This section of the code manages the engine burn sequence.
So this includes igniting the engine at the right moment and controlling the burn duration, power, maybe even abort procedures. So sometimes they were quite creative with the names for specific sets of instructions. For example, another part of the code is called pinball game buttons and lights.
Code has nothing to do with pinball itself. Its name just reflects the fact that it likely controls the interface Between the astronauts and the AGC via the DSKY or the display interface. now, why did they call it pinball game buttons and lights?
Well, because the actual DSKY allowed astronauts to input commands, buttons. And receive some sort of visual feedback, your lights from the AGC, just like a pinball game. Now in the same part of the script, there's also a comment that's very interesting.
Comments in programming is almost like a text note that gives an explanation about the code. It doesn't affect how the code is executed, doesn't do anything with the actual code. it's just like a little post it note for more explanations.
So in the pinball file there was a comment which quoted Shakespeare, Henry VI Which you can see here and it reads, it will be proved to thy face that thou hast men about thee that usually talk of a noun and a verb and such abominable words as no. now this is a coder who is just making fun of the assembly language. And this code used a lot of nouns and verbs, which was the essence of the assembly programming language.
This quote from Shakespeare references how people talk about grammatical terms like noun and verb, which Shakespeare implies that it might be boring or maybe offensive. to others. so whoever wrote this code just playfully related this to their work and the assembly language.
They're just probably tired of writing a bunch of nouns and verbs. Pretty normal feeling to have for the complicated mission and a complicated script like this. Still pretty funny that they are actually adding jokes to the code.
And there's a ton of these jokes showing up. The coders just really liked playful one liners here and there. In line 666 for the lunar landing guidance equations, they commented numero my sterioso, and this translates to mysterious number in Latin or Spanish.
Obviously 666 is not a good number if you're superstitious or religious. in the lunar landing script, handling the actual landing on the moon. There's this comment, which reads, please crank the silly thing around.
So this actually seems to be related to some operation that required rotating or moving something. And the programmer just chose to make instructions less formal. Then further down, there's this comment in the same script about the lunar landing, and it says off to see the wizard.
this is a well known phrase from the movie, The Wizard of Oz, which was released in 1939. this is an important part of the script and part of the moon landing. So off to see the wizard is a pretty cool explanation.
What's interesting about this is that the code comments, provide a glimpse into the programmer's headspaces at the time. Instead of writing mundane and over technically, instead of writing mundane and over technical notes, they really did inject personality into their work. This doesn't really happen in modern programming.
File names, Comments are always pretty straightforward and serious, even if you are coding something that is not important at all. So it is quite cool to see them adding some humor in such a, in such an important project and mission. So that in a nutshell is interesting things about the AGC and the software.
However, no matter how well you develop something, there's always some issue that pops up. And often when the media or people speak about the A GC and the source code, they speak about the 1, 2 0 1 and 1 2 0 2 errors that happened when the crew was on board during the Apollo 11 lunar descent. The AGC in the lunar module triggered two alarms, 1201 and 1202.
These alarms actually indicated that the computer was overloaded with tasks. so seeing this may have been a bit of a surprise to the crew, to the astronauts. Here's what happened.
during the lunar descent, the AGC was running near its maximum capacity. At the time it was handling about 85 percent of its workload. The issue arose because a radar system designed to track the orbiting command module was left on standby.
and this radar system was unintentionally sending extra signals to the computer, adding even more work. so astronaut Buzz Aldrin entered a command to display some additional data about the lunar module's altitude, which pushed the computer past its limit and caused these alarms to happen. But despite these alarms, the software was actually designed with a really clever solution.
The A GC automatically restarted and cleared low priority tasks like the altitude display to ensure that essential landing functions could still continue. Houston's flight controllers at the time led by the guidance officer Steve Bales, assessed the situation, determined that the landing could safely proceed and they could go ahead. So they repeatedly gave the astronauts a go signal, allow the mission to continue.
You can see this on the actual transcript, pretty straightforward. command center didn't even give a detailed explanation to the astronauts. They just said everything is a go and to continue.
Now, the interesting part here is that media reports often state that this was an issue with the programming or even an issue with the pilot. This is not true at all. in fact, I believe it's still infuriates the experts when the situation is brought up.
The problem was not a mistake in the computer programming. Or even a pilot error. It was an actual known problem with the radar hardware.
so the engineers had previously identified the bug, but determined it was safer to fly with the hardware they had already tested than replacing it with untested equipment. so it wasn't a big deal at all, but you will see when you are reading up about this, this error does pop up and often notes a programming related error, which is not true. The AGC was a brilliant computer.
The source code was extraordinary. And looking back on the code and the Apollo guidance computer, it's incredible to think how they were able to achieve something so groundbreaking at the time. And what's really just impressive creativity of the engineers and the programming behind it.
They didn't have the luxury tools or massive computational power that we have. Yet they pushed the boundaries of what was possible and just combined brilliant software with hardware that had limitations. And that resulted in one of humanity's greatest achievements.
It's a really such an interesting read. There's a ton of resources that go into much more detail, which I recommend going through. You can check out some links in the description.
Thank you so much for watching. If you like my content, please like, comment, and subscribe, and I will see you on the next one.