“Programming in Space” – my first article published in a journal (Science magazine)

It is with great pride that I present to you my first article, which was published in the “BG Nauka” Science magazine, in their January 2021 issue. I have also written articles for this magazine on other occasions, but they ended up on their website, in the form of a blog post. The article about the programming languages that run spacecrafts, rovers, rockets, etc. is my first post in their actual monthly magazine. You can read the text here:

Space programming

On July 20, 1969, the world held its breath, fixed its eyes on the sky and on the television screen. On this date, a historic event of high altitude takes place, which is broadcast on a global scale – the first time a human foot steps on the moon. Neil Armstrong and Buzz Aldrin go down in history.

On November 26, 2011, NASA sent the Curiosity rover to collect data and study a number of factors on Mars. This flight took 253 days, years of careful planning and round-the-clock preparation.

On March 7, 2020, after 51 years of various space exploits, the world once again holds its breath with a nod to the skies and, of course, the television screens. Another event of high importance and historical factor is taking place – for the first time a private company sends people into space, most likely marking a new era in which not only a narrow circle of scientists and billionaires can afford a trip to the moon or to the International Space Station.

Not everyone realizes that these space flights would be impossible without the machines that carry them out purely physically. And these machines (something even fewer people think about) could not fly even at the height of ordinary passenger planes if they were not very precisely and correctly programmed.

Programming the complex systems and instruments required for manning space, does not happen in arbitrary or currently popular programming languages like C# or Java. Often even, this happens in almost dead and unusable programming languages for mass purposes. Let’s track some of them.

One of the most commonly used programming languages in spaceflight is called HAL/S. “HAL/S is a high-level programming language commissioned for development by NASA in the late 1960s. At that time, the programs used on board spacecraft were either written in assembly languages (complex to understand, complex to write, close to machine code – only zeros and ones, author’s note) or interpreted languages (such , which do not need an interpreter, author’s note).” [1] These reasons necessitated the use of HAL/S in the programming of NASA’s spacecraft systems. “The HAL/S language provides simple and intuitive constructs for functions commonly needed and performed by aerospace programming applications such as arithmetic, vector manipulation, and matrix operations.” [2] In most programming languages there are various complex constructs (such as “GOTO” for example) that “NASA considers to be symptomatic of unreliable software”[3]. They can simply turn otherwise simple and workable code into so-called “spaghetti code,” or to put it another way, code so messed up that it’s impossible to trace or fix. These constructs are specifically removed from the HAL/S language to make it perfect for the needs of the space agency. To this day, nearly 85% of NASA’s spacecraft use the HAL/S programming language in one way or another. An example of a spacecraft using the language is the autonomous Galileo, which was launched in 1989 to reach the orbit of Jupiter in 1995 and explore this interesting planet of our solar system.

[Picture 1] – “The Galileo spacecraft being prepared for its 6-year journey to Jupiter, 1989”, Source: Great Images in NASA

Another language widely used in spacecraft is Ada. It was developed from 1977 to 1983 as a direct order of the US Department of Defense. The language is named after the historical figure Ada Lovelace, who is considered to be the creator of the first computer program (long before there were even computers). Ada is a structured, statically typed programming language similar to the Pascal language. And why is it so widely used in spaceships? Mainly for readability. Most programming languages are structured in such a way that it is far easier to write a program than to read it. This is the reason why the price of software maintenance is many times higher than the price of the one-time development of the given software. Ada is not such a language. It has readability that helps programmers review and verify code easily, quickly, and efficiently. “Ada favors the program reader over the writer because a program is written once but read many times. A good example of this is that the syntax of the language disallows all ambiguous constructions, so there are no surprises when the code is read by people other than the program author.” [4] Another feature of language important to NASA is its stability. The most prominent example of a spacecraft/apparatus that uses the Ada programming language (to arrange its devices and systems to work flawlessly and in sync) is the International Space Station. Even the most important part of the ISS, namely the life support system (oxygen, temperature, pressure, etc.), is programmed in Ada, which is a good example of how reliable and secure software written in this language is.

[Picture 2] – “Image of the International Space Station taken by space shuttle Endeavor in May 2011” Source: NASA,  http://www.spaceflight.nasa.gov/gallery/images/shuttle/sts-134/html/s134e010137.html

The last language worth mentioning is C (pronounced “si” – author’s note), which was developed by Dennis Ritchie in the 1970s. Of the languages mentioned in this article, this is the most popular, even among non-specialists. C is a general-purpose, intermediate-level programming language often used in everyday life today (as opposed to the previous two, which only NASA seems to use), mostly for programming embedded systems (examples – calculators, cash registers, smart houses, robot vacuum cleaners, etc.). Because of the low level of abstraction, programmers have more control over the hardware of devices programmed in C, and programs written in it tend to run very quickly. An example of a spacecraft that uses the C language as its base code is the Curiosity rover. It has 2.5 million lines of C code that is compiled by a RAD750 processor. Another example of a whole series of space objects using the language are the many satellites that are part of NASA’s Earth Orbiting System (EOS). They are a large group of satellites and instruments that together make a network over the Earth to study it and send data about the various phenomena that are happening, the Earth’s surface, the biosphere, the atmosphere and the oceans.

[Picture 3] – “Curiosity rover near the Big Sky area of the Martian surface.” The photo was taken by the rover itself, so we can also call it a “selfie”, 2015″, Source: NASA,http://photojournal.jpl.nasa.gov/catalog/PIA19920

For more than half a century, mankind has been exploring the cosmos up close. This is done through numerous spacecraft taking a human foot to unsuspected objects outside our planet; spacecraft that orbit and explore distant and so far inaccessible places of our solar system; earth-orbiting stations and satellites in which countless experiments and scientific discoveries take place, etc. All this human progress would not be possible without those things that remain somewhat in the background. Just as very few people know that Neil Armstrong and Buzz Aldrin were not the only people on their mission to the moon. There was also a third astronaut, Michael Collins, who did not physically set foot on the moon, but stayed in the spacecraft in orbit around the satellite so that the instruments could be monitored, the surfacers could return, and the mission could be successful. Likewise, very few people know that behind each such spacecraft are not only many developers, engineers and designers, but also programmers who are fluent in any of the programming languages listed above. The programming of all kinds of smart devices does not only rule our planet, it often goes beyond it. And this is yet to happen more often.

Sources:

[1] – “[393-397] Appendix II: HAL/S, A Real-Time Language for Spaceflight”, Computers in Spaceflight: The NASA Experience, https://history.nasa.gov/computers/Appendix-II.html

[2] – “Current Status of the HAL/S Compiler”, Lytle, P.J., Archive.org, 1981

[3] – “NASA. Programming in HAL/S”, Ryer, Michael J.,  http://www.bitsavers.org/pdf/intermetrics/programming_in_hal-s.pdf

[4] – “European air traffic flow management: porting a large application to GNU/linux”, Proceedings of the 2003 annual ACM SIGAda international conference on Ada, Allaert, G., Craynest, D., Waroquiers, P., 2003 

Leave a comment