Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,148,425 members, 7,800,927 topics. Date: Thursday, 18 April 2024 at 09:05 AM

C++ Now Has Garbage Collection?! - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / C++ Now Has Garbage Collection?! (699 Views)

Laravel:call To Undefined Method Illuminate\database\eloquent\collection::save() / Collection Of Nigerian Programming Gurus (2) (3) (4)

(1) (Reply) (Go Down)

C++ Now Has Garbage Collection?! by asalimpo(m): 12:01am On Aug 30, 2014
Going thru explanation of smart pointers in a recent c++ book(c++11) and it all sounded like GC to me.
If c++ uses gc wont tht mean tht modern c++ is going to b slower than its predecessors?

1 Like

Re: C++ Now Has Garbage Collection?! by toshodei: 12:37am On Aug 30, 2014
asalimpo: Going thru explanation of smart pointers in a recent c++ book(c++11) and it all sounded like GC to me.
If c++ uses gc wont tht mean tht modern c++ is going to b slower than its predecessors?


I doubt it.

1 Like

Re: C++ Now Has Garbage Collection?! by BlueMagnificent(m): 8:51pm On Aug 30, 2014
asalimpo: Going thru explanation of smart pointers in a recent c++ book(c++11) and it all sounded like GC to me.
If c++ uses gc wont tht mean tht modern c++ is going to b slower than its predecessors?


No, smart pointers implementation is not the same as garbage collector. Smart pointers are actually classes that act like pointers they internally keep pointer to the object they hold and a reference counter for the number of references to the object in the program code. When any of the smart pointers holding a reference to an object goes out of scope, the destructor decrements the counter, if the counter has a value of 0 the objects pointed to is deleted. So in effect there is no background object (GC) tasked with monitoring your program to know when an object is no longer referenced
Re: C++ Now Has Garbage Collection?! by asalimpo(m): 11:23pm On Aug 30, 2014
BlueMagnificent:

No, smart pointers implementation is not the same as garbage collector. Smart pointers are actually classes that act like pointers they internally keep pointer to the object they hold and a reference counter for the number of references to the object in the program code. When any of the smart pointers holding a reference to an object goes out of scope, the destructor decrements the counter, if the counter has a value of 0 the objects pointed to is deleted. So in effect there is no background object (GC) tasked with monitoring your program to know when an object is no longer referenced
enlighteng. But for this reason, c++ with smartpointers is bound to b a bit slower for all d bacground wrk it's doing for d programmer. Not as slow though as full GC languages.
Re: C++ Now Has Garbage Collection?! by BlueMagnificent(m): 12:06am On Aug 31, 2014
asalimpo:
enlighteng. But for this reason, c++ with smartpointers is bound to b a bit slower for all d bacground wrk it's doing for d programmer. Not as slow though as full GC languages.

I won't really say slow cause the "smart operations" of a smart pointer introduce negligible performance hit

(1) (Reply)

Beginners Guide To HTML/CSS / T / If Microsoft Went Open Source With Its Os ...

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.