6 ms·
Interesting. Could you give an example of such a memory lifetime bug in C# and why C++ is impervious to it?
by LessDmesg 7y ago
Interesting. Could you give an example of such a memory lifetime bug in C# and why C++ is impervious to it?
- nwallin 7y agoasync factory methods for stuff the API requires me to keep around, but the same API requires my objects to be constructed synchronously. (This includes stuff in .NET) C++ doesn't have async as a language construct. (yet. I dread the day.) IDispose. We have an ecosystem where a nonnegligible number of in flight objects need to manually be disposed of. In C++, RAII takes care of this for us. Un listening to events. Needs to happen manually in the standard .NET listeners. C++ solves this with weak_ptr. C# could solve this with a better standard library, but we have .NET. Honorable mention (not lifetime, but the deadlock quagmire that is C# and its half async half synchronous standard library) is WritableBitmap, which is impossible to use correctly, and has not been deprecated or had a safe replacement offered. C++ surprises me in ways I expect to be surprised. C# surprises me in ways that leaves me confused and perplexed.