20 points · by azth · 12y ago · 67 comments
int32* p;
and not int32 *p;
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...
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.
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)
Edit: Link in case anyone is interested from the discussion below is interested.
--------------
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.
Edit: did some research and the people I know work on projects started before the change; F-22/C-130. And it wasnt 20 years ago more like 15, although I couldn't find an exact date.
I actually worked in some of the Ada code in the F-22. The code and the SBC it ran on were designed in 1993. My understanding is the code was rewritten in C++ in about 2009. I believe the Ada code in the F-22 PICC module went the same direction as the module design evolved.
C and C++ are the languages of choice for hard and firm real-time code. Java is popular for UI code, though C and C++ are still used on some older Solaris-based front-ends.
See the software section of this document which says that military airborne software isn't, in general, acceptable to the FAA, which implies that the military are bound to weaker standards. http://www.faa.gov/documentLibrary/media/Order/ND/8110.101.p...
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
{
}
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.
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.
That's too bad.
[Edit: or function call times]
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.
http://smaccmpilot.org/images/dronecon-talk.pdf
This has the potential for nice compile-time guarantees without the runtime cost (and potentially at much lower cost than full formal verification)
(also, fwiw, Haskell has been around since 1990, making it about 7 years younger than C++)
https://en.wikipedia.org/wiki/Real-time_operating_system
edit: also, time/space leaks in haskell.
[1] I should point out that dynamic_cast is a little tricky -- http://www.stroustrup.com/fdc_jcse.pdf
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).
Besides, most commercial applications of C++ tend to devolve into "C with objects." IMO this is because well-written blocks of C are actually very readable, and you're a lot more likely to mess up memory management when you start passing data around just to break up large code blocks. The whole reason Java has garbage collection and only one way to pass objects is because they help write more readable code.
If you can't have non-deterministic behavior such as GC, you can't waste gobs of heap or stack memory, you have to be able to interface with C libraries and embedded components, you need hard real-time guarantees, and your whole development stack needs to be stable and well supported, you end up with C or C++, it's that easy. You don't gamble by picking the hipster language du jour all the cool kids use to write websites or phone apps, but proven technology that (if used correctly) gives you reliable and predictable results, and will still be around and supported in 40 years time when these jets are still in service.
Blaming the failure to deliver the f35 on time and within budget on C++ is really quite a cheap stab.
Why is it no wonder these things don't fly? Are the rules too strict? too loose? too broad? too stupid? or is it the choice of language? Your post provides no insight into your opinion at all and added no value for anyone else, quite the contrary.