Skip to content Skip to footer
0 items - $0.00 0

NASA has a list of 10 rules for software development by vyrotek

NASA has a list of 10 rules for software development by vyrotek

20 Comments

  • Post Author
    jmclnx
    Posted February 15, 2025 at 9:09 pm

    nice, saved because these days who know ho long the page will be available :)

  • Post Author
    readthenotes1
    Posted February 15, 2025 at 9:19 pm

    Someone in NASA once told me that it was easier to teach a mechanical engineer to program then a software developer mechanical engineering.

    From that perspective, the avoidance of recursion is more compelling. Plus, Fortran didn't support it…

  • Post Author
    dooglius
    Posted February 15, 2025 at 9:19 pm

    Title should indicate that this is a _criticism_ of the rules.

  • Post Author
    einpoklum
    Posted February 15, 2025 at 9:42 pm

    Well, I was expecting to see:

    Rule 1: Don't write any code that can make the ship go ka-boom.

    Rule 2: We need to consistently use the f'ing metric system and SI units – and don't you forget it.

    Rule 3: … You haven't already forgotten about rule #2, have you?

  • Post Author
    nealabq
    Posted February 15, 2025 at 9:46 pm

    No recursion means no Erlang. Which means no RabbitMQ?

  • Post Author
    toolslive
    Posted February 15, 2025 at 9:50 pm

    from the original document: "critical code is written in C." The document is not dated, but it's probably quite old (I'm guessing 30-something years). Writing critical code in C is probably a mistake, but once you find yourself in that situation, you will find these rules are too tight (which is also what the criticism is about). You should probably read them as "try to avoid …".

    So I would just prepend the document with "Rule 0: Try to avoid writing critical code in C."

  • Post Author
    zoogeny
    Posted February 15, 2025 at 9:53 pm

    > People using Ada, Pascal (Delphi), JavaScript, or functional languages should also declare types and functions as locally as possible.

    My own personal approach in JavaScript is to avoid defining functions in a nested manner unless I explicitly want to capture a value from the enclosing scope.

    This is probably due to an outdated mental model I had where it was shown in performance profiling that a function would be redefined every time the enclosing function was called. I doubt this is how any reasonable modern JavaScript interpreter works although I haven't kept up. Since the introduction of arrow functions (a long time ago now in relative terms) their prolific use has probably lead to deep optimizations that render this old mental model completely useless.

    But old habits dies hard I guess and now I keep any named function that does not capture local variables at a file/module scope.

    A lot of the other notes are interesting and very nit-picky in the "technically correct is the best kind of correct" way that older engineers eat up. I feel the general tone of carefulness that the NASA rules is trying to communicate to be very good and I would support most of them in the context that they are enforced.

  • Post Author
    jsrcout
    Posted February 15, 2025 at 10:03 pm

    I work with a lot of embedded and embedded-adjacent software, and even I think several of these rules are too much. Having said that, Holzmann's rules are from 2006, and embedded / space qualified hardware has improved quite a bit since then. These days planetary probes run C++, and JWST even uses JavaScript to run command scripts. Things are changing.

  • Post Author
    raylus
    Posted February 15, 2025 at 10:12 pm

    Note this is NASA/JPL, not NASA-wide, JPL is a NASA center (FFRDC).

  • Post Author
    matu3ba
    Posted February 15, 2025 at 10:25 pm

    Example 1 is a deficit of C with missing computed goto and switch continue. Example 2 review is ambiguous on practicality. Example 3 reads very odd, an over-approximated upper stack bound is very possible https://github.com/ziglang/zig/issues/157#issuecomment-76395… and tighter computation with advanced analysis as well. Example 4,5,6,7,8,9,10 yes.
    Overall good read.

  • Post Author
    layer8
    Posted February 15, 2025 at 10:32 pm

    The rule about recursion is likely also to ensure a statically known bound on needed stack space, in addition to a statically known runtime bound (in conjunction with the other rules).

    While the criticism of rule 3 is right in that there is a dependence on the compiler, it is still a prerequisite for deriving upper bounds for the runtime by static analysis on the binary. This is actually something that is done for safety-critical systems that require a guaranteed response time, based on the known timing characteristics of the targeted microprocessor.

  • Post Author
    AndyKelley
    Posted February 15, 2025 at 10:39 pm

    If I made my own criticism of these rules it would be very different from OP. It was difficult to take the article serious from the get-go when it defended setjmp/longjump. That pattern is so obviously broken from anyone who has ever had to go near it. The article makes an argument like this:

    1. setjmp/longjmp is exception handling

    2. exception handling is good

    and I take serious issue with that second premise.

    Also the loop thing obviously means to put a max iteration count on every loop like this:

    for (0..N) |_| {

    }

    where N is a statically determined max iteration count. The 10^90 thing is silly and irrelevant. I didn't read the article past this point.

    If I were to criticize those rules, I'd focus on these points:

    * function body length does not correlate to simplicity of understanding, or if anything it correlates in the opposite way the rules imply

    * 2 assertions is completely arbitrary, it should assert everything assertable, and sometimes there won't be 2 assertable things

  • Post Author
    dehrmann
    Posted February 15, 2025 at 10:40 pm

    Friendly reminder that you are most likely not NASA and have different goals, so you should approach the problem differently. The cost of a stack overflow (even at FAANG-scale) for you is likely many orders of magnitude cheaper than for NASA, and the cost of delaying a project for a year is much worse.

    Unless you work on commercial aircraft avionics. NASA flying a probe into Mars makes them look dumb. Flying an aircraft into a mountain haunts people for the rest of their lives.

  • Post Author
    bumby
    Posted February 15, 2025 at 10:46 pm

    Just for context, these aren’t really “rules” as much as proposed practices. Note that official “rules” are in documents with names like “NPR” aka “NASA procedural requirements.”[1] So, while someone may use the document in the featured article to frame a discussion, a developer is not bound to comply (or alternatively waive) those “rules” and could conceivably just dismiss them.

    [1] e.g. https://nodis3.gsfc.nasa.gov/displayDir.cfm?t=NPR&c=7150&s=2…

  • Post Author
    manmal
    Posted February 15, 2025 at 10:55 pm

    > All loops must have a fixed upper-bound

    Things like spinlocks or CAS (Compare-And-Swap) are elegant and safe solutions for concurrency, and AFAIK you can’t really limit their upper bound. Others in the thread have pointed out that those are more guidelines than rules – still, not sure about this one.

  • Post Author
    redtriumph
    Posted February 15, 2025 at 10:59 pm

    My ex-boss completed his PhD thesis with author of this doc as his advisor. So some of the ideas seem relevant since they popped up in few of the work related conversations with my boss.

  • Post Author
    gorfian_robot
    Posted February 15, 2025 at 11:23 pm

    now raise your hand if you are actually in the business of writing code being deployed on JPL missions …..

    bueller? bueller???

  • Post Author
    wileydragonfly
    Posted February 16, 2025 at 12:01 am

    The physical constraints of a sheet of paper are pleasing to the eye. Otherwise the dimensions of paper would be different. Oh well, it was good for a chuckle.

  • Post Author
    jph
    Posted February 16, 2025 at 12:02 am

    Read the original and it explains the purpose of each item:

    https://spinroot.com/gerard/pdf/P10.pdf

    The original clearly describes that the coding rules primarily target C and attempt to optimize the ability to
    more thoroughly check the reliability of critical applications written in C. The original author clearly understands what they're doing, and explains lots of other ways to verify C code.

    For what it's worth, the rationales in the original all make perfect sense to me. Perhaps this is because I learned C on tiny systems? I learned C for hardware for implanted medical devices, and our lab did similar kinds of guidelines.

  • Post Author
    fallingmeat
    Posted February 16, 2025 at 12:29 am

    fun fact, the same guy (G Holzman) also made the Spin model checker

Leave a comment

In the Shadows of Innovation”

© 2025 HackTech.info. All Rights Reserved.

Sign Up to Our Newsletter

Be the first to know the latest updates

Whoops, you're not connected to Mailchimp. You need to enter a valid Mailchimp API key.