Hacker News new | past | comments | ask | show | jobs | submit login

No. To be useful it needs to be a core language feature.



Languages like Ada provide hooks, for the runtime and compiler to collaborate together, because safety is more relavant than performance at all expenses.

Any variable declared as controlled type will have their "destructor" called just like C++, and that is what matters.

Like like RAII doesn't do anything, if the type is heap allocated and due to a bug not deleted or freed(), and someone has to write the destructor code, just like someone has to write the controlled type.


> Languages like Ada provide hooks, for the runtime and compiler to collaborate together, because safety is more relavant than performance at all expenses.

Does Ada come with optional garbage collection, at least? Memory leaks are a big safety concern, perhaps the biggest in practical code, and IIRC Ada still doesn't have GC "by default" for some unimaginable reason.


Ada 83 had one, however production deployment scenarios never required one so Ada 2005 dropped it, and nowadays thanks to SPARK and controlled types is not required anyway.

Additionally Ada controls many types directly like strings and vectors, and storage pools.

I recommend the FOSDEM talk about Ada memory management.


The unimaginable reason is that one of Ada's core competencies is realtime embedded systems. Very often, these don't allocate or free memory ever.


Don’t a lot of those systems allocate and free slots in large arrays, which is almost as risky?


Ada arrays are actual types, they're bounds-checked, the language provides some niceties for indexing, and Ravenscar and SPARK are available. You're going to have less issues with Ada in that case than you are with just about any other language out there.


`Ada.Finalization` is a core language feature, it's a package defined as part of the standard. Like many Ada features, RAII (via Controlled Types) is something you can opt into, such as if you need more than just record initialization.


I am corrected.


It is a core language feature as of Ada95. Ada, unlike most other languages generates calls into the standard library to implement complex features, controlled types and tasks are two such features. And no, I don't mean generating simple calls to compiler intrinsics.


It is a core language feature. You don't understand what Ada packages are.


Core language feature and package are not necessarily the same thing. No reason to bump heads. Instead you could provide a link to the RM: http://www.ada-auth.org/standards/12rm/html/RM-7-6.html




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: