Brad Abrams posted an e-mail from Brian Harry written during development of the .Net framework. It details many of the reasons reference counting was not used, even when one of the early priorities was to keep semantic equivalence with VB6, which uses reference counting. It looks into possibilities such as having some types ref counted and not others (IRefCounted
!), or having specific instances ref counted, and why none of these solutions were deemed acceptable.
Because [the issue of resource
management and deterministic
finalization] is such a
sensitive topic I am going to try to
be as precise and complete in my
explanation as I can. I apologize for
the length of the mail. The first 90%
of this mail is trying to convince you
that the problem really is hard. In
that last part, I’ll talk about things
we are trying to do but you need the
first part to understand why we are
looking at these options.…
We initially started with the
assumption that the solution would
take the form of automatic ref
counting (so the programmer couldn’t
forget) plus some other stuff to
detect and handle cycles
automatically. …we ultimately concluded that
this was not going to work in the
general case.…
In summary:
- We feel that it is very important to solve the cycle problem
without forcing programmers to
understand, track down and design
around these complex data structure
problems.- We want to make sure we have a high performance (both speed and
working set) system and our analysis
shows that using reference counting
for every single object in the system
will not allow us to achieve this
goal.- For a variety of reasons, including composition and casting
issues, there is no simple transparent
solution to having just those objects
that need it be ref counted.- We chose not to select a solution that provides deterministic
finalization for a single
language/context because it inhibits
interop with other languages and
causes bifurcation of class libraries
by creating language specific
versions.