3 ms·
> In my experience developing Ada software, not being able to depend on a garbage collector being present means that code intended to be used by others must man
by Raphael_Amiard 9y ago
> In my experience developing Ada software, not being able to depend on a garbage collector being present means that code intended to be used by others must manually manage memory. This means that it must manage memory exposed to client code and document who (the library or the client) is responsible for deallocation of a given data structure.
Ada has controlled and limited objects, which allows implementation of shared/unique_ptrs, so that's not true. As in c++, if you are in a performance sensitive area you will not use those, but that's also true with a GC, and then you have other options, like memory pools or static allocation.
> In effect, this makes Ada no more reusable or composeable than C.
I think you meant "with regards to memory management" :). As pointed out above, that's not true.
Also beyond memory management Ada has a generics model that composes much better than C++, due to being based on contracts for generic formals (think C++ concepts lite).
In general your statement strikes me as oversimplifying to the point of being simply incorrect.
- mcculley 9y agoMy last attempt at making reuseable Ada was with Ada95. Does the current standard provide for automatic deallocation such that one need never instantiate Unchecked_Deallocation? If so, I need to revisit it. Without a garbage collector, who deallocates graphs of objects with circular references?
- Raphael_Amiard 9y agoHello McCulley, sorry I missed your answer. > Does the current standard provide for automatic deallocation such that one need never instantiate Unchecked_Deallocation? The standard provide a host of containers and pointer-like constructs that would indeed allow you to never use Unchecked_Deallocation. There's one caveat: Performance. > Without a garbage collector, who deallocates graphs of objects with circular references? Like in other languages where you rely on ref-counting, you need to use weak references for that. This requires a bit more explicitness from the programmer.