> Do not use [..] direct or indirect recursion. Ok.. I get it that they don't want their C programmers to do that, but do they also mean that this is to "complex" for normal developers to implement in a fault-free manner?
The Power of Ten – Rules for Developing Safety Critical Code
21–30 of 155 posts
Re: The Power of Ten – Rules for Developing Safety Critical Code
#22If we're talking about high reliability code, one thing claimed about Haskell, is "if it compiles, it has no bugs". How close is it to the truth ? And how close are we to having that kind of capability for real-time programming(even assuming we're willing to forsake protability, community, and maximum efficiency to some extent ) ?
"Haskell vs. Ada vs. C++ vs. Awk vs. ... An Experiment in Software Prototyping Productivity"
Re: The Power of Ten – Rules for Developing Safety Critical Code
#23Earlier quoted context omitted.
dynamic memory allocation is very much frowned upon in embedded systems, not just for strings. Everything should be static and deterministic at all times. This is the easiest/only way to ensure you have no resource issues. You should always (statically) allocate for maximum/worst case.. because you have analysed your worst-case, haven't you?
How do you analyze worst case ? don't you need to know what calls what, up to what depth, and that's dynamic by nature ?
i.e. "You shall handle x messages in y milliseconds."
from that, you derive your worst case buffer size given that you can service that buffer every 'z' milliseconds at most (Note, that involves a hard-real-time requirement as it is a bounded maximum time).
Re: The Power of Ten – Rules for Developing Safety Critical Code
#24If we're talking about high reliability code, one thing claimed about Haskell, is "if it compiles, it has no bugs". How close is it to the truth ? And how close are we to having that kind of capability for real-time programming(even assuming we're willing to forsake protability, community, and maximum efficiency to some extent ) ?
Another thing is, if you want to write high reliability code in a general-purpose language, you have to have the discipline not to use all language features because a general-purpose language is by default not safe enough. This article basically outlines a subset of the C language for writing high reliability software, and I imagine if Haskell is used for similar software, a large number of language features and functions in the base library would need to be banned.
Re: The Power of Ten – Rules for Developing Safety Critical Code
#25Speaking from experience, the biggest problem with NASA's software engineering requirements ( http://nodis3.gsfc.nasa.gov/displayDir.cfm?t=NPR&c=7150&s=2B ) is the way that they tend to feed down into non-safety critical projects. It's getting better though.
I dream of the day when not making use of contracts, static analysis and type based programming is seen as quality smell and not something that only a few are allowed to make use of.
Re: The Power of Ten – Rules for Developing Safety Critical Code
#26This is being re-posted approximately every two weeks. Why?
Re: The Power of Ten – Rules for Developing Safety Critical Code
#27If we're talking about high reliability code, one thing claimed about Haskell, is "if it compiles, it has no bugs". How close is it to the truth ? And how close are we to having that kind of capability for real-time programming(even assuming we're willing to forsake protability, community, and maximum efficiency to some extent ) ?
Re: The Power of Ten – Rules for Developing Safety Critical Code
#28The recommendations look good to me and (with one caveat) correspond to rules that I apply when writing C code with a high reliability requirement.
My one caveat is in "Rule No. 8 – Limited Use of Preprocessor" which bans all complex uses of the preprocessor. The problem is that it is common in C to encounter situations where the only way to avoid lots of code duplication is to store a table of facts in a macro definition and use the preprocessor to expand those facts into the relevant bits of code in each place where they are used. So in these situations you face a trade-off between the risks due to complex preprocessor use, and the risks due to code duplication (namely, a maintainer might change a fact in one place where it is used but fail to change it in another). My experience is that the risks due to code duplication are very high, and so it's worth the risk of using complex preprocessor macros to avoid them. The risks can be mitigated by implementing the necessary macros in a structured way to keep the complexity under control: http://garethrees.org/2007/04/24/relational-macros/
Re: The Power of Ten – Rules for Developing Safety Critical Code
#29Re: The Power of Ten – Rules for Developing Safety Critical Code
#30Speaking from experience, the biggest problem with NASA's software engineering requirements ( http://nodis3.gsfc.nasa.gov/displayDir.cfm?t=NPR&c=7150&s=2B ) is the way that they tend to feed down into non-safety critical projects. It's getting better though.
Sadly quality is highly disregarded in our field. I dream of the day when not making use of contracts, static analysis and type based programming is seen as quality smell and not something that only a few are allowed to make use of.
Advanced typing/static analysis is not a pinnacle of software engineering, it's a set of training wheels. Useful? Yeah. But sometimes you may need to skip them.