Would you pay for GC?
Paulo Pinto
pjmlp at progtools.org
Tue Jan 25 12:29:46 UTC 2022
On Tuesday, 25 January 2022 at 11:47:26 UTC, Ola Fosheim Grøstad
wrote:
> On Tuesday, 25 January 2022 at 10:56:50 UTC, Paulo Pinto wrote:
>> Pity that programmer knowledge can't do much to ABI
>> requirements.
>
> C++ has an ABI?
Yes, the one from the compiler and OS vendor shipping their C++
compilers on their platform.
>
>
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1116r0.pdf
>
> So this is basically about giving a shared_ptr the semantics of
> a unique_ptr.
>
> That is not required for what we are talking about here.
>
>
>> Also that trick only works in single developer code bases,
>> good luck not introducing a memory corruption some
>> months/years down the line.
>
> No, this is not a big issue if you create proper ADTs. The
> issue is that it is very difficult for a compiler to
> distinguish between objects that "wrap ownership" around a
> data-structure and nodes within a datastructure; in particular
> what happens to ownership when those nodes are rearranged.
>
> However, the programmer should have good and solid knowledge
> about this, so you only need to increment on the root-object if
> you know that nodes do not escape below a point in the call
> tree. (And you might be able to wrap this in a reference-type
> specific to the ADT).
>
> Anyway, in C++ you tend almost always to use unique_ptr,
> shared_ptr is the exception. So you usually have very few
> shared_ptrs and therefore they are not all that hard to reason
> about.
As someone that does security as part of DevOps assignments, what
the programmers should be able to do, and what they actually
deploy into production isn't always the same.
That is how we end up with the 70% magical number being quoted
from several security reports.
>
> For a language like D you could have ARC + borrow checker + the
> ability to constrain ARC-pointers (to get a unique_ptr) for
> shared objects and something GC-like for objects local to
> actors/tasks.
In theory yes, in practice someone has to put down the money to
make it happen and ensure that the performance gains are worth
the money spent into it.
More information about the Digitalmars-d
mailing list