5 ms·
>They appear to use 3 different compilers for this reason (Ada) I understand why Ada is used for safety-critical applications, but I have to wonder: Does the f
by wyager 13y ago
>They appear to use 3 different compilers for this reason (Ada)
I understand why Ada is used for safety-critical applications, but I have to wonder: Does the fact that Ada is a relatively old and unfriendly language lead to more bugs than it prevents? My mind would probably go blank if I had to stare at Ada code for 8 hours a day.
What if we used Haskell for all non-realtime safety-critical functionality in aircraft? With a few extra rules to prevent stack overflows, I think I'd trust a million-line Haskell program over a million-line Ada program (although it would probably be more like ten-thousand-line Haskell program vs million-line Ada program).
- protomyth 13y agoAda is proven in this area and generates fast, efficient code that is suitable for embedded systems. Ada's last revision is 2012. What do you find unfriendly? I would most certainly not trust Haskell over Ada in embedded system work.
- wyager 13y ago>Ada is proven in this area and generates fast, efficient code that is suitable for embedded systems. So does coding in assembly. The idea is to create fast, efficient code that is also simple and easy to understand. >I would most certainly not trust Haskell over Ada in embedded system work. If the system does not have hard realtime requirements and has a decent resources, why wouldn't you trust Haskell?
- akiselev 13y ago>> If the system does not have hard realtime requirements and has a decent resources, why wouldn't you trust Haskell? Because that doesn't describe cars, a jet, space shuttles, or ... well anything I'd trust my life to. Hell, Haas CNCs still run DOS 8.0
- comex 13y agoYeah, I would avoid trusting something hard-realtime to a language with lazy evaluation and garbage collection, even if it's quite trustworthy for other purposes. (IIRC, these programs don't even use malloc, let alone garbage collection :)
- akiselev 13y agoMISRA discourages use of malloc (because you can deviate with clear documentation as to why) but it's not at all unheard of. That said, many embedded systems don't come with a usable implementation of malloc so the safe default is to write your own memory manager (safer but not always possible: use a well tested one) that uses static memory pools to allocate dynamic memory.
- userbinator 13y agoAny time you're using malloc() you run the risk of running out of memory, which is a very very bad thing for a safety-critical embedded system. Statically allocated, fixed-size things are good, as are algorithms that are designed not to require O(n) space to perform their processing.
- wyager 13y agoThere are many safety-critical systems that aren't hard realtime. Radio transponders, human interface systems, life support systems. In fact, I'd say a great way to do it would be to implement all the hard realtime bits in some low-level, pain-in-the-ass language like Ada and then wrap all that unpleasant stuff in a high-level language that is very unfriendly to implementation bugs (like Haskell).
- codygman 13y agoI'm sure someone once made the same comment about Ada when compared to competing languages (C? Assembly?) too ;)
- protomyth 13y agoThe history of Ada is about these type of systems. Haskell's history and runtime characteristics aren't.
- mcguire 13y agoAs an aside, I've been playing with learning Ada for a while (and all of the books I have from the last time poked at it are very out of date). Do you happen to know of any good references, online (Better!) or off?
- protomyth 13y agothis seems to be a good starting point these days - http://www.adacore.com/adaanswers/resources http://www.adacore.com/adaanswers/resources I learned with "ADA as a Second Language", but its way out of date and I do believe out of print.
- a3n 13y agoThey wouldn't be running Ada 2012 on a 777.
- protomyth 13y agoI was just answering that the language is not old. I'm really not sure what they would be running (83 probably, since its first flight was before 95).
- anaphor 13y agoI am a big Haskell fan but no, just, no. That would be a terrible idea because of how inherently unpredictable lazy evaluation is. Replace "Haskell" with OCaml or SML though, and I definitely agree. Also as others have commented there are usually special requirements for embedded systems that may even occasionally require one to drop down to assembly (e.g. to get the code in the right place to execute if you're on bare metal).
- astrange 13y agoWhat's so great about Haskell? It has no particular safety features compared to other languages, I think. It won't help with with static analysis of any numeric types (though you can turn bad conversions into type errors, it can't tell if an explicit conversion is right or not) and the timing of anything is really hard to reason out.
- wyager 13y ago>What's so great about Haskell? The type system. When I write Haskell programs, I create orders of magnitude fewer bugs than I do when writing programs in other PLs. The language makes it very hard to screw up implementing an idea. Haskell forces me to implement things in ways that are both elegant and easy to comprehend. Haskell does not easily admit spaghetti code.
- protomyth 13y agoHave you programmed any Ada?
- deleted 13y ago[deleted]
- psuter 13y agoThe things that matter in critical embedded systems are typically not captured by type systems: memory boundedness, running time upper bounds, overflows,... For these things even (controlled) C is a better option than Haskell today.
- wbl 13y agoThere is enormous tooling and a very good semantics for Ada. Haskell is only somewhat comparable: I've not seen anything like SPARK for Haskell.
- Dn_Ab 13y agoYou know, there are other languages than Haskell doing interesting things. Ada2012 for example, introduced design by contract with support for formal verification in conforming subprograms. This may be a near term more practical path than dependent types. Highly interesting. -> http://www.open-do.org/projects/hi-lite/gnatprove/ http://www.open-do.org/projects/hi-lite/gnatprove/ http://www.open-do.org/wp-content/uploads/2011/12/hi-lite-erts2012.pdf http://www.open-do.org/wp-content/uploads/2011/12/hi-lite-er...
- philwelch 13y agoGolden hammer, meet screw.
- tel 13y agoThis sounds like a gross misunderstanding of the kinds of guarantees made by Haskell's static systems. The closest you're going to get it something like Atom [0] which is used to program a few different hard realtime systems. If you look at the Atom docs, however, you'll quickly find that programming in Atom is nothing like programming in Haskell---it's merely embedded there. The type system helps to ensure that your embedding does falter, but most of the errors still live in the sublanguage and I'm not sure how far Haskell's type system goes toward reducing those. [0] http://hackage.haskell.org/package/atom http://hackage.haskell.org/package/atom
- gnaffle 13y agoAvionics software is written in an environment where, _if_ such a problem as a programming language being "old and unfriendly" introduced bugs, that would have been noticed and mitigated. http://www.fastcompany.com/28121/they-write-right-stuff http://www.fastcompany.com/28121/they-write-right-stuff