and I know that is the convention in C++, but it still makes my eyes bleed. It's a gross violation of the Law of Least Astonishment, since, of course,
int32* p,q;
doesn't do what you might think it would, based on the syntax. This is not a problem for the F-35 code, since multiple declarators per declaration are forbidden.
Sorry, I'm an old C guy and I guess there are some new tricks I just can't learn...
It seems that this standard definitely goes for clarity of code over syntactic shortcuts.
Which, you know, is probably a good idea for critical system software on an aircraft. It's better for your intermediate developers to know exactly what your code is going to do than to be able to use some greybeard tricks that can lead to buffer overflows if the person modifying them doesn't know exactly how they work.
Don't get too wrapped up with these standards. When asked about them Stroustrup himself said they aren't a general C++ standard, but something very specific to the embedded & critical systems of fighter jets. I can't remember the exact talk, but it was from one his Going Native talks:
It's not used 100%. As a mandate it disappeared a while ago, anyone that's using it is using it because of institutional momentum (rare) or some cost/risk analysis, or projects they've inherited or a rare mandate from the program office. I'd be happy if it were used more often, but it's not. And I'm not sure where vonmoltke gets that use is dissuaded, that's not been my experience. It's often that the language chosen isn't mandated and companies just don't choose it (there was too big a backlash in the 80s about the original mandate).
--------------
EDIT
The OS [1] for the F-35 and the 787, tightly integrated with development environments for Ada and C/C++. I really don't get the Ada knocking going on, it's a solid language and a hell of a lot better than C/C++. The reason it loses is corporate culture and lack of familiarity from developers, and an inherited hate/dislike that's persisted since the 80s. For these applications it really is the better language.
I do not think there is a viable alternative to C++ as a systems language, thus it's utilization in a complex project combining many systems developed by different parties makes sense. That being said, no humanly comprehensible amount of rules can make average engineer churn out good C++ code and no amount of good engineers can save project with bad management.
You said viable, so I guess you mean production ready, which excludes still experimental or "in gestation" languages like rust or ATS, but they are indeed worth a look (note that ATS in its 1st incarnation targets C).
I'd like to point out that there was a post several weeks ago on /r/haskell of someone having implemented a BSD kernel module. There's also MirageOS, an OCaml implemented framework providing all the services of an OS, thus letting people boot their apps in a VM very easily (that's the aim of the project afaik, given that it comes from the same lab than Xen. While not specifically tuned for OS development, they seem able to cope well with the task. Note that both languages also have a native SSL library development ongoing, which is a part of the MirageOS framework in the case of OCaml.
Galois and others have had success using Haskell, or using Haskell tooling to generate formally assured c/c++. I think there's plenty more industry could be doing today, even when tied to c/c++.
"AV Rule 1: Any one function (or method) will contain no more than 200 logical source lines of code"
Are they crazy? 200 SLOC is a huge beast. With our non-mission-critical software, we typically aim to not exceed 20 lines of code per function, and this including comments and whitespace. Typically it is not very hard to get functions of size < 10 sloc.
With your non-mission-critical software, you also probably don't have hard limits on recursion. Writing iterative versions of naturally recursive functions can blow up function sizes fast.
"4.13.4 Function Invocation
AV Rule 119 (MISRA Rule 70)
Functions shall not call themselves, either directly or indirectly (i.e. recursion shall not be
allowed)."
Unexpectedly running out of stack space at Mach 1 while pulling a 5g maneuver is a little different than unexpectedly running out of stack space while playing tetris. Most recursion can be rolled into loops, so it's not completely limiting.
The rationale is sensible though. C/C++ do not have tail call optimization, recursion reduces available stack memory which is a limited resource. By barring recursion, note they also bar malloc after initialization, they allow the program's memory usage to be determined at compile time, rather than during runtime. This allows them to satisfy requirements like "shall not use more than 50% of memory" (NB: this doesn't mean it will never use more than 50%, that extra memory available allows them to modify the program in the future and relax the memory constraint as needed without needing to modify hardware).
I feel like if I were a pilot with even a modicum of engineering and language experience, I'd be pretty frustrated that they aren't using something like Haskell that provides a certain level of runtime security. C++ seems like it has enough ways to generate a memory leak to sink a boat, or drop a fighter out of the sky.
C++ may not be the best choice, but a language like Haskell would be worse for an aviation application for a number of reasons:
1) Memory on the hardware is tightly constrained and controlled, and you need some visibility into its usage at any given time. Even if it exposes you to null pointer errors and the like.
2) Along the same lines, throughput must be predictable and is tightly constrained. Anything happening at runtime that can't be predicted at compile time is, for a safety critical aviation application, a huge risk and is usually explicitly forbidden by the requirements.
3) Haskell is relatively new. C++ has stood the test of time and the DoD can be sure plenty of C++ programmers will still be around in 30+ years.
All of these are dealbreakers from the DoD's perspective. The technical risks associated with handling your own memory and not having provably safe code can be addressed with enough time and expense. Since the DoD is not short on money and operates on time scales of years or decades, this is acceptable. In a startup or academic environment, the balance of risks and resources is completely different. But believe it or not, the DoD and commercial aviation entities actually do look at the tradeoffs associated with the tools they choose and don't simply choose them out of inertia.
Source: I develop commercial jet engine software, where many of the same resource/risk tradeoffs exist.
While initially this seems like a good idea, and I thought things like this for a while... I'm sure they are using a real time operating system. Imagine having things garbage collect for you when trying to fire a missile. This may seem inconsequential, but reliability is everything.
In addition to the other replies, Haskell lacks a proper ISO or ANSI standard.
I think that current safety-critical best practices (what real software engineers actually do) do a good job at correcting the warts inherent to the C family while respecting the need for real-time execution. Not clear what Haskell brings to the table here (or on other embedded systems in general).
I'm surprised folks are down voting my comment. See http://rt.com/usa/f35-jet-software-delay-233/ for example. And as the one who programmed in C++ for 20 years I think I know what I'm talking about.
[+] [-] rootbear|12 years ago|reply
Sorry, I'm an old C guy and I guess there are some new tricks I just can't learn...
[+] [-] exelius|12 years ago|reply
Which, you know, is probably a good idea for critical system software on an aircraft. It's better for your intermediate developers to know exactly what your code is going to do than to be able to use some greybeard tricks that can lead to buffer overflows if the person modifying them doesn't know exactly how they work.
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] tdicola|12 years ago|reply
http://channel9.msdn.com/Events/GoingNative/GoingNative-2012...
or
http://channel9.msdn.com/Events/GoingNative/2013/Opening-Key...
(both are _well_ worth a watch if you like C++ or program in it)
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] wil421|12 years ago|reply
Edit: Link in case anyone is interested from the discussion below is interested.
http://www.seas.gwu.edu/~mfeldman/ada-project-summary.html
[+] [-] Jtsummers|12 years ago|reply
--------------
EDIT
The OS [1] for the F-35 and the 787, tightly integrated with development environments for Ada and C/C++. I really don't get the Ada knocking going on, it's a solid language and a hell of a lot better than C/C++. The reason it loses is corporate culture and lack of familiarity from developers, and an inherited hate/dislike that's persisted since the 80s. For these applications it really is the better language.
[1] http://www.ghs.com/news/archive/211031l.html
[+] [-] vonmoltke|12 years ago|reply
[+] [-] foobarqux|12 years ago|reply
[+] [-] z3phyr|12 years ago|reply
[+] [-] rvkennedy|12 years ago|reply
AV Rule 60
Braces ("{}") which enclose a block will be placed in the same column, on separate lines directly before and after the block.
Example:
if (var_name == true)
{
}
else
{
}
[+] [-] exelius|12 years ago|reply
[+] [-] john_b|12 years ago|reply
https://news.ycombinator.com/item?id=3967316
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] TrainedMonkey|12 years ago|reply
[+] [-] fzltrp|12 years ago|reply
I'd like to point out that there was a post several weeks ago on /r/haskell of someone having implemented a BSD kernel module. There's also MirageOS, an OCaml implemented framework providing all the services of an OS, thus letting people boot their apps in a VM very easily (that's the aim of the project afaik, given that it comes from the same lab than Xen. While not specifically tuned for OS development, they seem able to cope well with the task. Note that both languages also have a native SSL library development ongoing, which is a part of the MirageOS framework in the case of OCaml.
[+] [-] mercurial|12 years ago|reply
[+] [-] jasonwatkinspdx|12 years ago|reply
[+] [-] steveklabnik|12 years ago|reply
[+] [-] pkolaczk|12 years ago|reply
Are they crazy? 200 SLOC is a huge beast. With our non-mission-critical software, we typically aim to not exceed 20 lines of code per function, and this including comments and whitespace. Typically it is not very hard to get functions of size < 10 sloc.
[+] [-] Jweb_Guru|12 years ago|reply
[+] [-] ape4|12 years ago|reply
[+] [-] smutticus|12 years ago|reply
That's too bad.
[+] [-] SoftwareMaven|12 years ago|reply
[+] [-] Jtsummers|12 years ago|reply
[+] [-] AnimalMuppet|12 years ago|reply
[Edit: or function call times]
[+] [-] barkingcat|12 years ago|reply
[+] [-] secstate|12 years ago|reply
[+] [-] john_b|12 years ago|reply
1) Memory on the hardware is tightly constrained and controlled, and you need some visibility into its usage at any given time. Even if it exposes you to null pointer errors and the like.
2) Along the same lines, throughput must be predictable and is tightly constrained. Anything happening at runtime that can't be predicted at compile time is, for a safety critical aviation application, a huge risk and is usually explicitly forbidden by the requirements.
3) Haskell is relatively new. C++ has stood the test of time and the DoD can be sure plenty of C++ programmers will still be around in 30+ years.
All of these are dealbreakers from the DoD's perspective. The technical risks associated with handling your own memory and not having provably safe code can be addressed with enough time and expense. Since the DoD is not short on money and operates on time scales of years or decades, this is acceptable. In a startup or academic environment, the balance of risks and resources is completely different. But believe it or not, the DoD and commercial aviation entities actually do look at the tradeoffs associated with the tools they choose and don't simply choose them out of inertia.
Source: I develop commercial jet engine software, where many of the same resource/risk tradeoffs exist.
[+] [-] vitno|12 years ago|reply
https://en.wikipedia.org/wiki/Real-time_operating_system
edit: also, time/space leaks in haskell.
[+] [-] vowelless|12 years ago|reply
[1] I should point out that dynamic_cast is a little tricky -- http://www.stroustrup.com/fdc_jcse.pdf
[+] [-] mcmancini|12 years ago|reply
I think that current safety-critical best practices (what real software engineers actually do) do a good job at correcting the warts inherent to the C family while respecting the need for real-time execution. Not clear what Haskell brings to the table here (or on other embedded systems in general).
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] wtracy|12 years ago|reply
[+] [-] russoue|12 years ago|reply
[+] [-] AnimalMuppet|12 years ago|reply
[+] [-] fbomb|12 years ago|reply
[+] [-] mercurial|12 years ago|reply
[+] [-] dgreensp|12 years ago|reply
[+] [-] amaks|12 years ago|reply
[+] [-] amaks|12 years ago|reply