how NASA writes space-proof code

Low Level Learning2 minutes read

NASA has a set of rules called the Power of 10 for code safety, advising against recursion and recommending stack memory over the Heap. Functions should be concise, variables should be scoped close to their use, and loops should have fixed upper bounds to limit memory allocation and debugging issues.

Insights

  • NASA's "Power of 10" rules emphasize code simplicity by limiting recursion, setting loop bounds, favoring stack memory over Heap, and advocating for concise functions with clear, minimal scope variables.
  • Prioritizing safety and ease of static analysis, NASA's guidelines underscore the importance of clear, single-purpose functions within a limited line count, enhancing code readability and testability while minimizing memory bugs.

Get key ideas from YouTube videos. It’s free

Recent questions

  • What are NASA's coding rules?

    NASA follows the Power of 10 rules for code safety and static analysis, emphasizing simple control flow, stack memory usage, and concise functions.

  • Why does NASA avoid recursion?

    NASA avoids recursion to adhere to the Power of 10 rules, ensuring code simplicity, safety, and ease of static analysis.

  • What memory type does NASA recommend?

    NASA recommends using stack memory over the Heap to prevent memory bugs and limit memory allocation for code efficiency.

  • How long should functions be according to NASA?

    NASA suggests keeping functions concise, around 60 lines, to maintain readability, testability, and adherence to the Power of 10 rules.

  • Where should variables be declared in NASA's coding guidelines?

    NASA advises declaring variables at the lowest scope possible for readability and testability, aligning with the Power of 10 rules for code simplicity and safety.

Related videos

Summary

00:00

NASA's Power of 10: Code Safety Rules

  • NASA has a set of rules, known as the Power of 10, to ensure code safety and ease of static analysis.
  • NASA restricts code to simple control flow constructs, avoiding recursion and setting fixed upper bounds for loops.
  • NASA recommends using stack memory over the Heap to prevent memory bugs and limit memory allocation.
  • Functions should be concise (around 60 lines), do one thing, and variables should be declared at the lowest scope possible for readability and testability.
Channel avatarChannel avatarChannel avatarChannel avatarChannel avatar

Try it yourself — It’s free.