|
|
|
|
|
by zeugma
5528 days ago
|
|
Maybe that what's the author wanted to pointed out: if you have garbage collection (at least the way it's implemented in C#/Java) you have to give away scope lifetime of object.
This is annoying because you want determinism for some kind of resources (file, lock, ...) and then you have to manually clean them, which is what you wanted to avoid in the first place with garbage collection. In C++, if you declare the object on the stack, the destructor will be called when the scope is closed. Which is very handy for e.g. lock. The thing is, garbage collection could be use together with scope lifetime (aka RAII) just let the programmer choose which is best/more convenient for him given his resources. |
|
The article is clearly written for pogrammers coming from C++ to C#, which there are a lot of, including myself. I like both C++ and C# a lot but have to admit that managing object lifetime in C# is one of the things I really dislike. There's the suggestion that RAII is reasonable in C# but for me always ends up being a headache.