4 ms·
Ada isn't safe the way Rust is safe. It can statically check that an access type (pointer) is only used with objects from a particular storage pool, but danglin
by prodigal_erik 10y ago
Ada isn't safe the way Rust is safe. It can statically check that an access type (pointer) is only used with objects from a particular storage pool, but dangling pointers to deallocated objects and stack-allocated objects still happen.
- Raphael_Amiard 10y agoIt's a bit more complicated than that. Ada has no safe object deallocation, but guarantees safety as long as you don't use any unchecked operations (object deallocation being one). Ada is also much more powerful than C/C++ in terms of how far you can go with the safe subset of the language, since you can pass/return objects of unknown size in and out of functions by value. There is no doubt that Rust static guarantees in terms of allocation/deallocation are very useful in some contexts. There is also no doubt that they're not sufficient at all to express every useful programs (for example you cannot safely express any structure with circularities, linked lists/graphs). In those cases you'll be back to unsafe constructs directly or indirectly. So Rust has more expressivity in this regard but is still no silver bullet.
- jeromel 10y agoIn terms of safe programs (e.g. programs that, if failing, could kill people), dynamic allocation is not allowed anyway (at least, dynamic deallocation is not allowed). So this makes this point void. Rust makes user-land programs less prone to crashes, but safe programs found a better way years ago to deal with deallocated pointers issues. That's also one of the reasons that prevented Ada compilers back in the days to create a garbage collector: there's no sound way to have a garbage collector compatible with real time constraints (which is sometimes safety critical: just imagine an air bag waiting for a garbage collection when it would instead need to pop out), and people creating safe applications don't need it anyway. So why bother?