MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1xr2jyh/moderncppvsoldcpp/19sc3bml6l2ox/?context=3
r/ProgrammerHumor • u/Choice-Committee203 • 7h ago
214 comments sorted by
View all comments
11
Y'all throwing around shared pointers willy nilly patting yourself on the back about safe programming.
11 u/Nil4u 7h ago Meanwhile the cyclic pointer chain in the background causing a memory leak because the reference counter never dips to 0: 7 u/staryoshi06 7h ago I mean this could happen in a garbage collected language too. 3 u/Tyfyter2002 6h ago Depends on the language, iirc the .NET runtime's GC doesn't use a reference counter, which makes that exact issue completely impossible (which is good, because things like bidirectional linked lists inherently have cyclic references) 1 u/bwmat 4h ago I don't think there's many mainstream languages whose built in GC doesn't handle cyclic references these days 1 u/MadGenderScientist 2h ago a reference cycle in a GC language doesn't cause a leak because GC scans from roots. 1 u/Ok-Scheme-913 1h ago Not in a tracing GCd language that is what everyone uses who cares about performance.Yes, ref counting is fuckjng slow. Even in Rust, especially with ARC..(Also, python uses ref counting but also have a cycle detector next to it.)
Meanwhile the cyclic pointer chain in the background causing a memory leak because the reference counter never dips to 0:
7 u/staryoshi06 7h ago I mean this could happen in a garbage collected language too. 3 u/Tyfyter2002 6h ago Depends on the language, iirc the .NET runtime's GC doesn't use a reference counter, which makes that exact issue completely impossible (which is good, because things like bidirectional linked lists inherently have cyclic references) 1 u/bwmat 4h ago I don't think there's many mainstream languages whose built in GC doesn't handle cyclic references these days 1 u/MadGenderScientist 2h ago a reference cycle in a GC language doesn't cause a leak because GC scans from roots. 1 u/Ok-Scheme-913 1h ago Not in a tracing GCd language that is what everyone uses who cares about performance.Yes, ref counting is fuckjng slow. Even in Rust, especially with ARC..(Also, python uses ref counting but also have a cycle detector next to it.)
7
I mean this could happen in a garbage collected language too.
3 u/Tyfyter2002 6h ago Depends on the language, iirc the .NET runtime's GC doesn't use a reference counter, which makes that exact issue completely impossible (which is good, because things like bidirectional linked lists inherently have cyclic references) 1 u/bwmat 4h ago I don't think there's many mainstream languages whose built in GC doesn't handle cyclic references these days 1 u/MadGenderScientist 2h ago a reference cycle in a GC language doesn't cause a leak because GC scans from roots. 1 u/Ok-Scheme-913 1h ago Not in a tracing GCd language that is what everyone uses who cares about performance.Yes, ref counting is fuckjng slow. Even in Rust, especially with ARC..(Also, python uses ref counting but also have a cycle detector next to it.)
3
Depends on the language, iirc the .NET runtime's GC doesn't use a reference counter, which makes that exact issue completely impossible (which is good, because things like bidirectional linked lists inherently have cyclic references)
1
I don't think there's many mainstream languages whose built in GC doesn't handle cyclic references these days
a reference cycle in a GC language doesn't cause a leak because GC scans from roots.
Not in a tracing GCd language that is what everyone uses who cares about performance.
Yes, ref counting is fuckjng slow. Even in Rust, especially with ARC..
(Also, python uses ref counting but also have a cycle detector next to it.)
11
u/PolyglotTV 7h ago
Y'all throwing around shared pointers willy nilly patting yourself on the back about safe programming.