4 ms·
I’m not the author, but there’s a few reasons Ada tends to be forgotten in these discussions: Back when Ada was new, people just didn’t actually like programmi
by steveklabnik 2y ago
I’m not the author, but there’s a few reasons Ada tends to be forgotten in these discussions:
Back when Ada was new, people just didn’t actually like programming in it much. Some did, of course, but many did not. This is the reason the Ada Mandate was abandoned.
This led into a situation with a small, walled off community that didn’t really communicate with the outside world much. This has a compounding effect over time.
Ada, while designed for safety critical systems, was not actually memory safe until fairly recently. Deallocating memory at runtime wasn’t, and in my understanding, may only be in the presence of SPARK? Hopefully someone can chime in here. Now, that fine for the systems Ada tended to be used for, which often have either no dynamic allocation or a singular allocation at program startup, but for inspiration for other language designs, given that it forgoes a hard problem, it’s not really as useful to those who are trying to solve those problems. This doesn’t mean Ada is useless for inspiration, but for “how do I implement memory safety,” it doesn’t have many unique uses things to offer.
None of this means Ada is a bad language, but these are the main contributing factors that I see with regards to your specific question.
- pjmlp 2y agoThat is the usual Ada outdated image, just like unsafe code blocks in Rust, those Unchecked Deallocation are wrapped in safe calls, and since Ada95 there are controlled types, allowing for RAII patterns. Additionally, it is common to use arenas, and many types can be dynamically stack allocated with a retry operation in case there is not enough space, so that the call can be redone with a smaller size. Memory Management with Ada 2012 from FOSDEM 2016, https://archive.fosdem.org/2016/schedule/event/ada_memory/ https://archive.fosdem.org/2016/schedule/event/ada_memory/ Doesn't go much into SPARK related improvements though, given its date.
- steveklabnik 2y agoSure, none of that is particularly novel though, so in terms of citing it as something specifically to add to the conversation, there isn't any real reason.
- quietbritishjim 2y agoIt was the article author's choice to specifically say there is no safe systems programming language other than Rust. If that is not true then it's worth citing in discussion of the article.
- steveklabnik 2y agoMy parent confirmed that deallocating memory is still unsafe, even though there are common usage patterns that help make sure you're doing it correctly.
- pjmlp 2y agoJust like using double linked lists in Rust is unsafe, unless special libraries are used, this is no different. Also we aren't talking about Ada83 any longer.
- roca 2y agoHow does "redo the call with a smaller size" possibly help you? If you could get by with less memory, you should have asked for less memory in the first place.
- pjmlp 2y agoFor some types of applications, it is a doable use case, it is the same as asking how malloc() returning NULL helps.
- roca 2y agomalloc() returning NULL isn't that helpful. Most applications just react to that by aborting, and most applications that don't abort take poorly-tested error-handling paths that often don't work. I don't remember ever seeing an application that reacted by trying the allocation again but requesting less memory. I have seen applications react by pausing and trying the allocation again a few seconds later --- this can be shockingly effective! https://hacks.mozilla.org/2022/11/improving-firefox-stability-with-this-one-weird-trick/ https://hacks.mozilla.org/2022/11/improving-firefox-stabilit...
- roca 2y agoRust's affine types and borrow checking give safe Rust a lot more power than the safe subset of Ada95. A trivial getter method that returns a reference (i.e. pointer) to a field of its object is safe in Rust, but in Ada95 (and C++ and most other non-GC languages) in general you can't ensure the object outlives the reference. It is true that Ada has a safe suitable-for-systems-programming subset that's much better than most languages. I think when people say "Rust is the first safe systems programming language" they implicitly mean "that is expressive enough for me to replace C++ with".
- pjmlp 2y agoExcept we are into Ada 2022 nowadays, so SPARK is also part of the story.