6
$\begingroup$

For the purposes of clarification
- will include machine code generated by a programming language on earth.
- 'in space' includes anything in orbit and deep space transit.
- special mentions of programming language on devices in space appreciated.
- special mentions of any coding by astronauts in space appreciated.
- 'popular' = by count of the number of satellites not most 'liked'. although discussion on this is welcome.

This question follows a reading of the excellent answers to my earlier question What was the first programming language in space?

$\endgroup$
  • 1
    $\begingroup$ Will "most popular" be problematic? Do you mean the one people liked the most, or most frequent/common? $\endgroup$ – uhoh Jun 14 '17 at 1:23
  • 1
    $\begingroup$ What if language A is present on by far the highest fraction of satellites, but there are by far the most lines of language B in space, and yet by far programmers were the most fond of language C? $\endgroup$ – uhoh Jun 14 '17 at 2:51
  • 1
    $\begingroup$ Edited my OP to clarify : by count of satellites installed on. Mostly I'm curious which languages are used and if this has changed since the first satellites. $\endgroup$ – aspiringGuru Jun 14 '17 at 4:16
  • 2
    $\begingroup$ @superdesk It confused me at first too, but I'm pretty sure he means that if a program is written in C and compiled to machine code, which is then sent to space, this will still count as "C in space". $\endgroup$ – called2voyage Jun 15 '17 at 17:40
  • 1
    $\begingroup$ Most projects don't really talk about the software side, so I can only talk about things where I was personally involved in some way, which is a quite limited sample. Nevertheless, I would say terrible horrible spaghetti Fortran is the most popular choice. $\endgroup$ – Rikki-Tikki-Tavi Jun 16 '17 at 21:48
10
$\begingroup$

I wrote code that flew on 3 spacecraft that went to Mars, one to the Moon, one to a comet and back, and a few Earth-orbiting satellites, the last of which was about 10 yrs ago. All of them used C.

It's not the only language out there, of course, but it's popular because the perception is that code can be made smaller and faster using C, without the overhead required by a managed language.

Maybe things have changed in recent years. I hope so.

I don't have first-hand knowledge, but my guess is that the first satellites used assembly language -- small, tight code on slow processors with little RAM.

$\endgroup$
  • $\begingroup$ Well, the first satellites predated the first versions of C by about fifteen years... Even the Apollo program was pretty much in wind-down mode by the time early work was done on C, and it wasn't until 1978 (says Wikipedia) that The C Programming Language was published. $\endgroup$ – a CVn Apr 28 at 10:00
2
$\begingroup$

C would seem like a good guess: C is popular for embedded systems, satellites are embedded systems, therefore C is popular for satellites. There are a lot of holes you can poke in this line of reasoning, and of course many languages have been used to varying degrees of popularity. In the absence of a survey of languages used that would answer this question decisively, the examples here can give some context.

Keep in mind that since a significant number of satellites do not have publicly available information, such as military and spy satellites. One could guess that Ada may be more popular than a general survey would suggest, given it's widespread use in the US military in the past. More information on Ada is provided in this related question.

A specific example of C's use: NASA's Core Flight System (cFS homepage) is written in C, and is in use on several missions right now (related question).

Smaller platforms such as CubeSats may change the languages in space distribution as well: there are many of them and they have a much higher risk tolerance (and lower success rate). From the LightSail paper presented at SmallSat 2015, "LightSail FSW (software and firmware) is written in the C programming language." LightSail also ran a Linux distribution, again written in C.

Assembly was also a popular language, at least historically, according to Ron Garret who wrote the following about working at JPL in 1988: "Spacecraft were mostly programmed in assembler, or, if you were really being radical, Ada." The article with this quote documents the work done on Remote Agent, an experimental LISP program that controlled the Deep Space 1 satellite for two days during its mission.

$\endgroup$
  • $\begingroup$ Ah...Ada. $\endgroup$ – called2voyage Jun 15 '17 at 13:54
  • 1
    $\begingroup$ From personal experience I know Fortran is pretty popular as well. I think C beats it out though. $\endgroup$ – Arthur Dent Jun 15 '17 at 14:52
  • $\begingroup$ The question is a little bit fuzzy in that respect, but I think point #1 in the question together with some of the OP's comments would disqualify a lot of your examples, since the C code would be compiled on earth and what is actually installed on the spacecraft would be machine code, so the C code is not actually "in space". There are some exceptions, e.g. the C code that was uploaded to the Pathfinder spacecraft to be run in the C interpreter of its VXWorks operating system in order to fix the priority inversion problem. $\endgroup$ – Jörg W Mittag Jun 16 '17 at 7:27
  • $\begingroup$ I don't see the comments by aspiringGuru that clarifies point #1... I myself commented asking for clarification. Stepping back for a moment: counting the assembly generated by the compiler instead of the language the source was written in 1) doesn't follow conventional wisdom and 2) makes the question much less interesting. $\endgroup$ – superdesk Jun 16 '17 at 12:03
  • $\begingroup$ @ArthurDent Which kind? Sure, Fortran 2000 beats the pants off C, but I'd rather program in C than Fortran IV!! $\endgroup$ – WetSavannaAnimal Jun 18 '17 at 11:39
1
$\begingroup$

For the most part, the C programming language will be the language of choice for a majority of spacecraft. It has a long legacy of being a trustworthy language for space missions. I would argue that C++ is a better choice due to its zero-cost abstractions and type safety. We are utilizing C++ for our flight software for these very reasons. I think one reason C is still so prevalent not only in spacecraft but also in the embedded world in general, is that the engineers are often afraid of abstractions. But, it is these abstractions that grant us safer, more reliable, and readable code. As a result, I have noticed an increased interest and application of C++ for spacecraft. Check out this great talk on the use of C++ for the Curiosity rover's autonomy system.

Lastly, here is a great video from a prominent member of the C++ community, Jason Turner, on using modern C++14 in a Commodore 64 with no overhead. Here he demonstrates that C++ is not a slow, bloated language like many embedded developers have come to believe, mostly from statements made in the 90's.

$\endgroup$
0
$\begingroup$

Although not a direct answer to your question, it might be worth considering the attributes of programming languages as they relate to spaceflight applications.

C is a good choice because it is a high-level language which is still "close to the hardware" (seems like a paradox, but it isn't). As already stated, it is often used in embedded systems, and satellites/space probes are embedded systems. It is also used in aviation (avionics) for all the same reasons. Compilers will produce efficient run-time code. Assuming the developer follows appropriate practices, the runtime will execute predictably and deterministically, which is critical for testability and reliability. Code can be "provably correct".

Java and C# are evolutions on C (by way of C++) which dramatically improve developer productivity. They may find use in non-critical spaceflight applications, but are unsuitable for high-reliability embedded systems such as autonomous spacecraft or safety-critical systems aboard manned spacecraft. They employ memory management / garbage collection schemes which make runtime behavior non-deterministic and execution times unpredictable. While it is easier to write more complex and sophisticated applications in newer languages like Java and C# than it is in C, it is much more difficult to guarantee that the code will never fail.

You can expect that other languages will be used or not used with similar considerations in mind as to language features and attributes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.