Sei sulla pagina 1di 6

Coding for space: programs that took us

to the Moon and beyond


This morning at 3.45 am the lunar lender Beresheet developed by the Israeli nonprofit
organisation SpaceIL has started its 2-month journey to the moon. If the mission is
successful, Israel will become the fourth country who has set foot on the surface of our
satellite, thus carving this day into history.

Inspired by the moment, we've plunged ourselves into studying the greatest milestones of
space exploration and brilliant minds standing behind them. Each successful lending,
colorful photo of a distant galaxy and radio-signal sent from light hours away is a result of
many-ears work of scientists and engineers, who were and still are the pioneers in their
field.

Being a software development company, we simply could not hold ourselves from studying
the work of our colleagues. We've explored the code powering the first manned lunar
mission, the development rules for building Martian rovers and how far-reaching assembly
languages can be.

Now we're sharing our findings with you.

BURN_BABY_BURN: Code that took us to the Moon

NASA’s Apollo 11 mission was launched in 1969 - literally pre-historic time for developers
working with UNIX-like systems (well, almost all developers). But the most thrilling thing
here is that the source code for Apollo 11 Guidance Computer (AGC) and the command
and lunar modules is in free access on GitHub.

Thanks to the Virtual AGC and MIT Museum initiative, everyone can now explore the
original lines that flied us to the moon. Those who are especially excited about coding for
space can even compile them using the emulation of Apollo's onboard guidance computer.

It's worth saying, that the language in which the code was written is hardly recognizable to
modern engineers. But, still, it is rather readable - Margaret Hamilton and her team at MIT
added many comments to give each other (and us) a heads up on what each certain line is
for. And yes, they've named one of the files BURN_BABY_BURN–
MASTER_IGNITION_ROUTINE. Here's an excerpt from it:
A deeper look can give you not only the idea of what was going on in a program but also
what their work was alike. You can imagine their thoughts when typing this:

or this:

or when discussing how not to do poodoo (which was actually a condition called “P00DOO
abort” with two zeros after "P". But, come on, it's unbelievable someone had pronounced it
that way!)

The total weight of the whole program is slightly bigger than 2MB — the screenshots we’ve
made for this article are almost the same weight! But isn't that fascinating that such a tiny
piece of code was able to take us so far? Well, there was a checklist error that had almost
prevented the lunar module from lending. But that's another story. This one is about
people who had no Stack Overflow to search for help, about times when common software
development and design principles were in their infancy and about the “pocket calculator”
that made it possible for people to walk the moon.
Power of 10 to power the one: coding for Mars
Our developers can spend hours arguing what programming language is the most popular
on Earth. But when it comes to Mars the answer is clear – it's C. The most of software of
Curiosity, the only operating rover on the planet's surface, is built in it (it was 2,5 million
lines in 2012 and should be much more as of today). It also has over 1 million of Java and
C++ code responsible for driving the rover and controlling its robotic arm.

But the most curious thing about Curiosity code is HOW it was written.

Shortly after heading JPL’s Laboratory for Reliable Software (LARS), Dr. Holzmann
noticed that developers don't follow most of rules set in Coding Standards. And, on top of
it, every mission had its own standard. As a result, you could get conflicting numbers when
running the same code on different environments.

Dr. Holzmann has spend endless hours asking his programmers only one question:

“if you could pick 10 rules to follow and ignore hundreds of others, what 10 rules
would it be?”

Their answers have formed the "Power of Ten" – a set of risk-based coding rules, where
every rule was coming from a real-life accident or failure caused by its violation.

These rules are as follows:

1. Avoid complex flow constructs, such as goto and recursion.


2. All loops must have fixed bounds. This prevents runaway code.
3. Avoid heap memory allocation.
4. Restrict functions to a single printed page.
5. Use a minimum of two runtime assertions per function.
6. Restrict the scope of data to the smallest possible.
7. Check the return value of all non-void functions, or cast to void to indicate the return
value is useless.
8. Use the preprocessor sparingly.
9. Limit pointer use to a single dereference, and do not use function pointers.
10.Compile with all possible warnings active; all warnings should then be addressed
before release of the software.
You can find the detailed and comprehensive explanation of all 10 rules in Holzmann's
article "The Power of 10: Rules for Developing Safety-Critical Code" published in June
2006 issue of IEEE "Computer" magazine.

Based on these 10 principles coding standard for Curiocity software was developed. It
includes 4 levels of compliance each containing its own set of rules. Check them up by the
link if you wish to learn what is it like to code the NASA way.

The best languages to get out of the system


If you think that assembly languages won't take you far these days – think again. Even
though Fortran, Cobol and Algol sound like witty names for dinosaurs, they have a
potential to become truly interstellar (even without black holes and wardrobe universes).

The Voyager mission was launched in 1977th. Both probes have already left the
heliosphere, everyone from the original team has retired, but the project is still considered
to be in its middle ages – it is planned that the mission will last till late 2020-es or even
longer.

However, coding for Voyagers is not only the way to send your lines out of the Solar
system but also to invite someone from outside in. Both spacecrafts carry identical golden
plaques with earth images and sound records – kind of time capsule or “message in a
bottle” for extraterrestrial lifeforms.

But to actually see this content our alien friends (or foes) should be a little bit programmers
themselves. The cover diagram with the instruction for playing the records as well as
locating the solar system is encoded in binary.

Here's the explanation of each element:


You can also explore the content of the Golden Record on NASA's website by the link.
May it be your today's dose of inspiration.

***

These examples give us a chance to observe the technology progress from another angle. They
show how novel and pioneering can be 40-years-old technologies, how the brilliance of human
mind can flawlessly rule spacecrafts with only 2 megabytes of code and how the right question
asked to the right people bring solutions to the next level.

We hope you enjoyed reading this article the same as we did when writing it. And to finalize it, a
short quote from one of Apollo engineers:
This morning the Israeli first lunar lender “Beresheet “was successfuly launched from Florida.
Inspired by this historical event we've prepared an article about software development for space.
Prorrams powering NASA's Apollo 11 mission, coding rules for Martian rovers and what language
does the Voyager speak – all this you'll find by the link.

Potrebbero piacerti anche