4 ms·
MISRA C is an effort to tame the wild beast of the C programming language. I get the impression it's not a bad ruleset, but there's plenty it doesn't protect yo
by MaxBarraclough 6y ago
MISRA C is an effort to tame the wild beast of the C programming language. I get the impression it's not a bad ruleset, but there's plenty it doesn't protect you from. MISRA C doesn't give solid assurances of the absence of undefined behaviour, for instance. [0]
If you're in the business of developing ultra-low-defect software, and you aren't committed to C, SPARK Ada is another option.
[0] https://learn.adacore.com/courses/SPARK_for_the_MISRA_C_Developer/chapters/07_undefined_behavior.html https://learn.adacore.com/courses/SPARK_for_the_MISRA_C_Deve...
- stjohnswarts 6y agoIt really is only a spec to adhere to to get rid of some of the more obvious errors. it certainly doesn't cover everything. Ada is definitely a better language. Also if rust ever settles down I think it would be great for aerospace 178b and other standards for aircraft. Also cars :) . I'd be surprised if some car companies aren't using it or at least researching it. It's still changing so fast though. I've only ever met one engineer who actually liked coding in Ada.
- MaxBarraclough 6y ago> if rust ever settles down I think it would be great for aerospace 178b and other standards for aircraft. Also cars :) I imagine the compiler situation would need to change before this could become a possibility. I doubt off-the-shelf Rust/LLVM is appropriate for compiling life-and-death code. I imagine it would also be necessary to strictly control memory management, using pools rather than doing the equivalent of malloc/free. It seems Rust has a crate for that: https://docs.rs/heapless/0.5.5/heapless/ https://docs.rs/heapless/0.5.5/heapless/ > I've only ever met one engineer who actually liked coding in Ada. It certainly lacks many luxuries. For that matter, it also lacks basic examples. I tried to dabble with Ada recently, and pretty quickly ran into trouble (I was unable to figure out how to instantiate any of GNAT's 'bounded containers').
- gusthoff 6y agoWould you mind sharing which bounded container you tried to instantiate and what the problem was?
- MaxBarraclough 6y agoI wasn't able to instantiate any of them, I couldn't figure out the proper syntax. There are no examples anywhere that show how to used them.
- gusthoff 6y agoIs this the kind of example you were looking for? with Ada.Text_IO; use Ada.Text_IO; with Ada.Containers.Bounded_Vectors; procedure Main is package BV_Integer is new Ada.Containers.Bounded_Vectors (Index_Type => Positive, Element_Type => Integer); use BV_Integer; Vec_Max : constant := 10; Vec : Vector (Vec_Max); begin Put_Line ("Appending some numbers..."); for I in 1 .. Vec_Max loop Vec.Append (Integer (I)); end loop; Put_Line ("Appending another number..."); Vec.Append (Vec_Max + 1); -- this raises an exception. end Main;
- MaxBarraclough 6y agoYes, thanks. Perhaps I was just missing Vec : Vector (Vec_Max);. I'll give this a go on GNAT some time.