Thread: garbage collection enabled c++

  1. #16
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If I recall, Stroustrup mentioned that C++0x was going to have some form of garbage collection in it (togglable at the compiler level).
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I dunno. I don't think they were going to add it. It is a heated discussion, but I don't think it has been decided to implement yet. Perhaps. But if would definitely be togglable.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #18
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by XSquared View Post
    If I recall, Stroustrup mentioned that C++0x was going to have some form of garbage collection in it (togglable at the compiler level).
    The current TR1 doesn't mention it and this documented is not going to be changed. It's a draft still because that's part of the procedure for the Committee. Short of an earthquake, I don't see that being added.

    In fact, Stroustrup seems to not favor the need for such an addition http://www.research.att.com/~bs/bs_f...age-collection
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #19
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Aah. He had mentioned it briefly at a talk he gave at my university over the summer, and I just looked it up and it seems that they've put it off into TRs past C++0x.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #20
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Actually I now remember you then mentioning it in these forums. Didn't you?
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #21
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Yep. I believe I posted a link to the talk a while back.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  7. #22
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Standardized garbage collection (an optional feature for compilers) was planned for C++09, but has been taken out due to time constraints. The current working draft contains wording that describes when 3rd-party GCs have to work correctly, and when they're allowed to fail (mostly to do with masking pointers so that the GC collects an object before it's really given up).
    By formulating these core requirements, they can later put actual garbage collection into a library TR.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #23
    Banned
    Join Date
    Nov 2007
    Posts
    678
    although, thanks to all of you, that i now have more idea about how to manage my dynamic memory.
    still, cant there be two forms of new/delete operators. like a gc_new/gc_delete.
    if we want full efficiency and control use new/delete. if we want automatic garbage collection use gc_new/gc_delete.

  9. #24
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    still, cant there be two forms of new/delete operators. like a gc_new/gc_delete.
    if we want full efficiency and control use new/delete. if we want automatic garbage collection use gc_new/gc_delete.
    What would gc_delete do? From what I see of garbage collection in PHP and Java, you only use new and garbage collection handles when to release the memory.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #25
    Banned
    Join Date
    Nov 2007
    Posts
    678
    oops! ur damn right! i forgot! yeah no need of gc_delete!

    PS: but as per the mind set of c++. a gc_delete can still be there to manually force the garbage
    collection to take place.

  11. #26
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Not really, no. That would be against the spirit of garbage collection and also pose practical problems.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  12. #27
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    But as noted, the garbage collection won't guarantee destructors to be run, if I understood correctly, which is not the best thing. Smart pointers do not have this problem.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #28
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by Elysia View Post
    But as noted, the garbage collection won't guarantee destructors to be run
    They will, definitely. Just not necessarily when the object loses scope. This is mainly what differentiates GC from RAII.

    While trying to look for that herb sutter article to post here, I come across differentiated opinions on the subject. GC may indeed have its uses. However, they are localized instances and it's my opinion GC shouldn't dominate a program deallocation strategy. Well... not in C++ at least.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #29
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    A nice story from Andrew Koenig (the guy the name lookup is named after) about GC

    http://www.ddj.com/blog/cppblog/arch...tic_memor.html

  15. #30
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by CornedBee View Post
    Standardized garbage collection (an optional feature for compilers) was planned for C++09, but has been taken out due to time constraints. The current working draft contains wording that describes when 3rd-party GCs have to work correctly, and when they're allowed to fail (mostly to do with masking pointers so that the GC collects an object before it's really given up).
    By formulating these core requirements, they can later put actual garbage collection into a library TR.
    God, I wish they wouldn't. This is only going to encourage people to write even crappier code than before, under the assumption that "the GC will take care of it." Not only will this code suck, it will be unusable on compilers that don't implement GC.

    What a nightmare.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Garbage Collection is not so complicated
    By Nalpdii in forum C Programming
    Replies: 2
    Last Post: 10-07-2007, 11:34 PM
  2. C++ Garbage Collection
    By vaibhav in forum C++ Programming
    Replies: 1
    Last Post: 11-27-2005, 10:26 AM
  3. Garbage Collection
    By Orborde in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2005, 11:18 PM
  4. SDL: Garbage collection (?) screwing me
    By Brian in forum Game Programming
    Replies: 4
    Last Post: 05-08-2005, 09:13 AM
  5. garbage collection
    By joed in forum C Programming
    Replies: 4
    Last Post: 04-01-2004, 01:47 PM