Re: Re: Re: my garbage collector sucks
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
"Paul Prescod" <[email protected]> wrote in message news:[email protected]... > Mark Hahn wrote: > > > Paul Prescod wrote: > > > >>It is probably not a deciding factor, but if you put performance > >>aside, reference counted languages can make guarantees about object > >>finalization that m&s garbage collected languages cannot. > > > > > > It turns out that is a myth. As an outcome of the turing halt theorem, you > > cannot predict when and on which instruction the count will go to zero for > > different program inputs. > > > The Halting Problem only applies to *computer programs* trying to > predict the behaviour of other *computer programs*. I am talking about a > human being trying to predict the behaviour of a computer program. > Anyhow, this is blindingly obvious if you write the following Python > program: > > for i in range(0, 10000): > file = open(str(i)+".txt", "w").write("Hello world") What happened to using spaces for indentation? You've gone back to no indentation. > Maybe there is no *computer program* that can see that this would have > different behaviour in Python versus Jython/Java but I can see it with > my own two eyes. In Jython it will open somewhere between 1 and 10000 > files simultaneously and in Python there will never be more than two > files open at a time. There is a ton of garbage collection reference material out there that isn't aware of this. The guy in charge of garbage collection for parrot isn't even aware of this. Or if they are aware they are ignoring it and not writing about it. I hate to say it but proper coding would say to include the file closes because you never know what garbage collector your code will be run on. All the garbage collection material says you cannot count on finalizers. While this may not be true for ref counting, it is true in general. Anyway, I have to weigh all the advantages and disadvantages in making the Prothon decision. Having a generational garbage collector that burns a lot fewer cpu cycles, works better with multiple cpus, and is easier to code in C outweighs this finalizer issue. Adding file close statements not only protects against different garbage collectors but is explicit and good coding style for readability.