473,239 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

Garbage collection?

Hi,

My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?

Just wondering :)

Rick

Jul 22 '05 #1
11 2687
Rick wrote:

Hi,

My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language?
You have to ask Mr. Stroustroup on this one.
He has written a book about why C++ looks and acts the way it does.
Locate his website, I think there is a description of that book.
Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?


Ts, ts, ruin everything.

But it's true. C and C++ is used a lot controlling software.
Imagine a nuclear power plant. Imagine that there is a malfunction
within the reactor. Further imagine that your software has detected
that malfunction and is going to shut down the reactor in an orderly
fashion. The software has waited until there is no other choice to
shutdown and it knows that this may be time critical. The software
starts the shutdown process .... and then the garbage collector kicks in.

That said: C++ is powerful enough that there are garbage collectors around.
Just google for them if you feel the need to use one.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2
On Fri, 05 Dec 2003 02:06:54 +1100, Rick <rrquick@nospam-com> wrote:
Hi,

My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?

Just wondering :)

Rick


I, for one, don't want anything to do with GC, thanks! The day C++
forces GC on me, I'll move on to Assembler if I have to.
Jul 22 '05 #3
Rick <rrquick@nospam-com> wrote in message news:<3f********@clarion.carno.net.au>...
Hi,

My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?

Just wondering :)

Rick


Why don't you ask Dr Bjarne Stroustrup :)

http://www.research.att.com/~bs/bs_f...age-collection
Jul 22 '05 #4

"Dan W." <da**@raytron-controls.com> wrote in message
news:e0********************************@4ax.com...
On Fri, 05 Dec 2003 02:06:54 +1100, Rick <rrquick@nospam-com> wrote:
Hi,

My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?

Just wondering :)

Rick


I, for one, don't want anything to do with GC, thanks! The day C++
forces GC on me, I'll move on to Assembler if I have to.


Amen, brother!

Jul 22 '05 #5
Karl Heinz Buchegger wrote:
<snip>
Imagine that there is a malfunction
within the reactor. Further imagine that your software has detected
that malfunction and is going to shut down the reactor in an orderly
fashion. The software has waited until there is no other choice to
shutdown and it knows that this may be time critical. The software
starts the shutdown process .... and then the garbage collector kicks in.

<snip>

This actually describes a need for a hard real-time OS. GC and
real-time are not inherently incompatible (there are real-time JVMs out
there), and not having GC is obviously not sufficient to ensure meeting
deadlines.

I understand the point you're making, Karl. I'm just picking on your
example. Real-time doesn't mean 'real fast', it just means 'real
predictable'.

Suffice it to say that GC will eat cycles, and if C++ were to provide GC
in the same manner as Java, then there would be no way to avoid spending
time doing garbage collection in a C++ application.

- Adam

--
Reverse domain name to reply.

Jul 22 '05 #6
"Rick" <rrquick@nospam-com> wrote:
My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language? Are there fundamental reasons behind this? Is it because
C is generally a 'low level' language and they didn't want garbage
collection to creep into C++ and ruin everything?


I guess the principle is not to take decisions about things like memory
management out of the programmer's hands ... C++ was designed to stay pretty
much as efficient as C. There is also a principle of "extensibility via
libraries" instead of adding features to the language (if you want a garbage
collector, you can always add one; the "new" operator was made overloadable
so that memory management could be done however you like). The disadvantage
is that some things would be much easier to use if they were built into the
language, eg. a "for each ..." statement (with a local body that allows
break & continue), a completely polymorphic type (like the "any" type in the
boost library), and (optional) garbage collection.

Here are some web pages related to garbage collection in C++:

http://www.hpl.hp.com/personal/Hans_Boehm/gc/index.html
(lots of garbage collection resources)

http://www.jelovic.com/articles/cpp_...ors_slides.htm
(a "safe pointer" type)

- neither of which I have actually tried, but they look good ...

I also read about a library which lets you group a set of objects together
and free them all at once (much faster than one at a time), but I can't find
it right now. Has anyone else heard of this library ?

David F

---

"I saw 'cout' being shifted "Hello world" times to the left and stopped
right there."
- Steve Gonedes
Jul 22 '05 #7
Thanks David,

David Fisher wrote:
I also read about a library which lets you group a set of objects together
and free them all at once (much faster than one at a time), but I can't find
it right now. Has anyone else heard of this library ?


Yup.. this is what "region-based memory management" is all about - first
introduced by Tofte and Talpin.

regards,
Rick

Jul 22 '05 #8
"Xenos" <do**********@spamhate.com> wrote in message news:<bq*********@cui1.lmms.lmco.com>...
"Dan W." <da**@raytron-controls.com> wrote in message
news:e0********************************@4ax.com...
I, for one, don't want anything to do with GC, thanks! The day C++
forces GC on me, I'll move on to Assembler if I have to.


Amen, brother!


Amen ^ 3.

GC is the concept of mopping the floor and putting the dirt under the carpet.
Furthermore, today, with all the great tools like valgrind, you can
detect all memory related bugs with a couple of good testcases.

Stelios
Jul 22 '05 #9
"Rick" <rrquick@nospam-com> wrote:
My question is.. if Lisp, a 40 year old language supports garbage
collection, why didn't the authors of C++ choose garbage collection for
this language?


I just came across this article on the "D" language, which includes garbage
collection ...

http://www.cuj.com/documents/s=8254/...86243774/d.pdf

David F
Jul 22 '05 #10
Adam Fineman wrote:
Karl Heinz Buchegger wrote:
<snip>
> Imagine that there is a malfunction
within the reactor. Further imagine that your software has detected
that malfunction and is going to shut down the reactor in an orderly
fashion. The software has waited until there is no other choice to
shutdown and it knows that this may be time critical. The software
starts the shutdown process .... and then the garbage collector kicks
in. <snip>

This actually describes a need for a hard real-time OS. GC and
real-time are not inherently incompatible (there are real-time JVMs
out there), and not having GC is obviously not sufficient to ensure
meeting deadlines.

I understand the point you're making, Karl. I'm just picking on your
example. Real-time doesn't mean 'real fast', it just means 'real
predictable'.


I think that was just his point. The GC kicks in at unpredictable times
and needs an unpredictable amount of time. It is just as bad for real
time as e.g. swapping is.
Suffice it to say that GC will eat cycles, and if C++ were to provide
GC in the same manner as Java, then there would be no way to avoid
spending time doing garbage collection in a C++ application.


Right.
Jul 22 '05 #11
Rolf Magnus wrote:
Adam Fineman wrote:

<snip>
GC and
real-time are not inherently incompatible (there are real-time JVMs
out there), and not having GC is obviously not sufficient to ensure
meeting deadlines. <snip>Real-time doesn't mean 'real fast', it just means 'real
predictable'.

I think that was just his point. The GC kicks in at unpredictable times
and needs an unpredictable amount of time. It is just as bad for real
time as e.g. swapping is.
<snip>


And my point was that GC and real-time are not incompatible, in that
there are real-time JVMs (with garbage collection) out there. In other
words, on these implementations, GC is only allowed to kick in at
predictable times and run for a predictable amount of time.

- Adam

--
Reverse domain name to reply.

Jul 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob | last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and...
6
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
34
by: Ville Voipio | last post by:
I would need to make some high-reliability software running on Linux in an embedded system. Performance (or lack of it) is not an issue, reliability is. The piece of software is rather simple,...
5
by: Bob lazarchik | last post by:
Hello: We are considering developing a time critical system in C#. Our tool used in Semiconductor production and we need to be able to take meaurements at precise 10.0 ms intervals( 1000...
8
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by...
28
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will...
56
by: Johnny E. Jensen | last post by:
Hellow I'am not sure what to think about the Garbage Collector. I have a Class OutlookObject, It have two private variables. Private Microsoft.Office.Interop.Outlook.Application _Application =...
350
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
158
by: pushpakulkar | last post by:
Hi all, Is garbage collection possible in C++. It doesn't come as part of language support. Is there any specific reason for the same due to the way the language is designed. Or it is...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.