by yjftsjthsd-h · 9y ago · 0 comments
So you might occasionally see the unsafe package being used to deallocate memory, even though there are better ways to do it, e.g. controlled types.
The other point, is that Rust prevents data races via the type system, while you can deadlock Ada tasks if the monitors aren't properly implemented.
Ada side is producing a new model for parallel and concurrent programming called ParaSail:
http://www.embedded.com/design/programming-languages-and-too...
http://www.math.umn.edu/~arnold/disasters/ariane.html
Although that was not a failure of language safety, but an overflow issue. The software was designed successfully for another rocket, and was reused for a rocket that didn't match the original specification.
Programmers blindly following specs put together by people who have no claim to expertise in these matters without questioning the assumptions behind the spec is the cause of all manner of disasters. And "but that's what the spec said to do" is all to common an excuse when the problem is with subtle runtime behavior issues that fall squarely in the programmer's domain of responsibility.
The decision to re-use the component as-is in the Ariane 5 without sufficiently investigating the consequences of the higher horizontal velocities that it is subject to compared to the Ariane 4 cannot so obviously be blamed on the programmer that implemented it years before in a different context.
1) No manual memory management, everything is static and you have memory safety
2) Garbage collection, you have memory safety
3) Manual memory management, you lose memory safety
Rust provides memory safety in the case of manual memory management.
Ada provides more ways to automate memory management, though.
Controlled types are Ada's version of RAII, used for arenas and smart pointers.
Also in Ada you can dynamically allocate everywhere, so a common pattern is to use a subroutine parameter to do stack allocation. If it fails, by throwing an exception, recall the subroutine with a smaller size.