Yes, I intentionally didn't go into other issues of reference counting, they being outside the point of my node.

Only recently did I look at how Perl 5 implemented reference counting enough to realize how horribly it was done. I'm not at all surprised that there are still bugs in that implementation. Perl 5 reference counting mostly requires matching each creation and destruction of references by hand. It is a huge manual effort that is very error prone.

Of course, it isn't easy to design something in plain C that does a fantastic job of enforcing this type of thing. C++ offers great ways of dealing with this (destructors fire when you leave a scope, no matter how you left it; so doing such work in c'tors and d'tors ensures that your inc/decs are paired without having to match anything by-hand and even in the face of exceptions being thrown or early return).

But you can certainly put more effort into making the system better at encouraging and enforcing proper habits so you don't have to put so much effort into figuring out proper ref count handling by-hand every time you add or change just about any of Perl's source code and not producing a system that is so confusing that it is almost always a source of questions and bugs for new XS coders. But that ship has at least mostly already sailed for Perl 5.

It wouldn't be trivial to implement a good system for reference counting in plain C, but the failure of Perl 5's implementation to become error-free has more to do with that particular implementation not making the effort up front to make future errors unlikely.

And it has at least mostly already sailed for Parrot as well. And at this point I'm doubtful that Parrot will ever be successful enough for us to see how big of a mistake this particular choice was. I consider timely and well-order destructors one of the most important tools of C++ but the designers of Parrot had no understanding of this and little interest in trying to understand the arguments of those who did understand this importance. Basing a design decision on ignorance (that was how the decision was made; it was a fiat of "I don't understand why you guys think reference counting is a good idea, but it doesn't matter because I've already decided and I'm writing it and that's that") in the face of several knowledgeable people criticizing that decision isn't usually a formula for success.

- tye        


In reply to Re^7: Parrot, threads & fears for the future. (ref counting) by tye
in thread Parrot, threads & fears for the future. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.