4 ms·
Neither Pascal nor Ada are memory-safe.
by cyberax 2y ago
Neither Pascal nor Ada are memory-safe.
- docandrew 2y agoIt’s possible to write unsafe code in either but it’s also much easier to write safe code in both Pascal and Ada than C/C++. And it’s easier to write safe code in C++ than C. Memory safety exists in a spectrum, it’s not all or nothing.
- pjmlp 2y agoMore than C or C++ will ever be. It is like complaining a bullet vest doesn't protect against heavy machine gun bullets.
- cyberax 2y agoNot really. Standard Pascal's dynamic features were barely present, but even they allowed dangling references to exist. And all practical Pascal clones (e.g. Object Pascal) had to grow constructor/destructor systems to cleanup the memory on de-allocation (or they went the garbage collection route). So they were on-par with C++ for safety. Ada is similar. It provided safety only for static allocations with bounds known at the compile-time. Their version of safe dynamic allocations basically borrowed Rust's borrow checker: https://blog.adacore.com/using-pointers-in-spark https://blog.adacore.com/using-pointers-in-spark
- pjmlp 2y agoNo one used Standard Pascal, just like everyone embraces their Compiler C extensions and many of them are blissfully unaware their code fails to compiler under strict ISO C conformance mode. We are beyond Ada 83, Controlled Types and SPARK exist, and Rust also does runtime bounds checking, so what.