comp.lang.ada
 help / color / mirror / Atom feed
* Ada has garbage collection
@ 2004-08-24  3:49 Wes Groleau
  2004-08-24  8:05 ` Florian Weimer
  2004-08-24 18:41 ` Jean-Marc Bourguet
  0 siblings, 2 replies; 4+ messages in thread
From: Wes Groleau @ 2004-08-24  3:49 UTC (permalink / raw)


OK, we could argue semantics, but every language with
parameters/data on the call stack has garbage collection
for all those objects.

And Ada makes it far less necessary than some languages
to avoid pointers and use locals instead.

Many vendors use the heap for large things, but AFAIK,
they keep it transparent and do the "garbage collection"
just as well as if the objects stayed on the stack.

Of course, some problems/data structures almost demand
pointers, but with sensible encapsulation and package
designed, controlled types provide all the GC those things need.

How does that differ from C++ destructors?

Java couldn't afford to be without universal GC, because
it makes almost everything on the heap, and allows no
definition of destructors.

-- 
Wes Groleau

Even if you do learn to speak correct English,
whom are you going to speak it to?
                     -- Clarence Darrow



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada has garbage collection
  2004-08-24  3:49 Ada has garbage collection Wes Groleau
@ 2004-08-24  8:05 ` Florian Weimer
  2004-08-24 18:35   ` Randy Brukardt
  2004-08-24 18:41 ` Jean-Marc Bourguet
  1 sibling, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2004-08-24  8:05 UTC (permalink / raw)


* Wes Groleau:

> OK, we could argue semantics, but every language with
> parameters/data on the call stack has garbage collection
> for all those objects.

That's a sure way to lose an argument with a garbage collection
advocate.

> Of course, some problems/data structures almost demand
> pointers, but with sensible encapsulation and package
> designed, controlled types provide all the GC those things need.

Of course you can implement an ownership policy manually (or some
simple form of garbage collection like reference counting, especially
if your data structures aren't cyclic).  This is a tedious task, and
if you implement the wrong ownership policy, you often prevent code
reuse.  It's quite a bit of work to make something completely safe
against misuse.  Memory management errors are hard to debug.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada has garbage collection
  2004-08-24  8:05 ` Florian Weimer
@ 2004-08-24 18:35   ` Randy Brukardt
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Brukardt @ 2004-08-24 18:35 UTC (permalink / raw)


"Florian Weimer" <fw@deneb.enyo.de> wrote in message
news:87oel1j70l.fsf@deneb.enyo.de...
> * Wes Groleau:
...
> > Of course, some problems/data structures almost demand
> > pointers, but with sensible encapsulation and package
> > designed, controlled types provide all the GC those things need.
>
> Of course you can implement an ownership policy manually (or some
> simple form of garbage collection like reference counting, especially
> if your data structures aren't cyclic).  This is a tedious task, and
> if you implement the wrong ownership policy, you often prevent code
> reuse.  It's quite a bit of work to make something completely safe
> against misuse.

Designing for reuse is hard, period. And expecting to reuse things without
that is folly. And, if you're designed for reuse, you *have to* make it safe
against misuse.

Claw does a lot of things that aren't strictly necessary in order to
eliminate or mitigate misuse. One example is that all of the entry calls
into the message task are timed entry calls; an exception is raised if they
aren't accepted in a reasonable time. That's done to prevent deadlock which
can occur when an operation is called during the rendezvous of a handler.

> Memory management errors are hard to debug.

True, but not if they aren't made in the first place. :-) The last two
memory leaks I had to debug turned out to be compiler errors -- the software
was correct, the compiler wasn't implementing it properly. And those were
the only ones in the last year.

Note that any sort of memory recovery is wasted effort in quick running
programs; Janus/Ada only tries to recover memory that could be reused during
a compilation (a very small proportion of the memory allocated); the
completion of a compilation pass ends all use of memory without any overhead
at all.

                          Randy.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ada has garbage collection
  2004-08-24  3:49 Ada has garbage collection Wes Groleau
  2004-08-24  8:05 ` Florian Weimer
@ 2004-08-24 18:41 ` Jean-Marc Bourguet
  1 sibling, 0 replies; 4+ messages in thread
From: Jean-Marc Bourguet @ 2004-08-24 18:41 UTC (permalink / raw)


Wes Groleau <groleau+news@freeshell.org> writes:

> OK, we could argue semantics, but every language with
> parameters/data on the call stack has garbage collection
> for all those objects.

The term has been used in relation with dynamic allocation
for so long that I would not be able to hold for that side
without feeling that I'm cheating.

> And Ada makes it far less necessary than some languages to
> avoid pointers and use locals instead.

The major use of GC is not for the cases where Ada allow to
prevent dynamic allocation where other languages force its
use.

> Of course, some problems/data structures almost demand
> pointers, but with sensible encapsulation and package
> designed, controlled types provide all the GC those things
> need.
> 
> How does that differ from C++ destructors?

C++ destructors offer exactly the same functionnality as
controlled types -- with an added convenience of beeing less
heavy (they are available for non tagged types).  And there
are people in the C++ community holding exactly the same
view as you: that GC is not needed because of that.  

Note that I'm not a strong proponent of GC: I feel it
provides the most convenient implementation of shared
ownership policies, it doesn't allow to skip the choice of a
sensible ownership policy for the problem at hand.  Too many
proponents of GC seems to argue that shared ownership policy
is the only one needed.  Constrained by the languages I
mainly use (C++ for work, Ada when I've no external
constraints), I tend to use design that don't benefit a lot
from GC (but I see places where there would be a benefit)
and I wonder how my design would change if I became used to
a language with GC.

> Java couldn't afford to be without universal GC, because
> it makes almost everything on the heap, and allows no
> definition of destructors.

A static analysis should allow to use stack allocation for
most variables where programmers in other languages would
have used it.  But that's a very weak argument.  Not
offering explicit stack allocation (along with a Ada's
finalization/C++ destructor feature) is, IMHO, one of the
mistakes of Java.

-- 
Jean-Marc



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-08-24 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-24  3:49 Ada has garbage collection Wes Groleau
2004-08-24  8:05 ` Florian Weimer
2004-08-24 18:35   ` Randy Brukardt
2004-08-24 18:41 ` Jean-Marc Bourguet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox