3 ms·
> C# doesn't have ownership/lifetimes and the kind of safety that comes with them. Could you elaborate? C# has a garbage collector for tracking resources.
by hgs3 3y ago
> C# doesn't have ownership/lifetimes and the kind of safety that comes with them.
Could you elaborate? C# has a garbage collector for tracking resources.
- lucasyvas 3y agoI think the parent post is wrong. This rewrite probably has more to do with performance, "fearless concurrency", and/or developer happiness. C# is safe.
- whimsicalism 3y agothread safe?
- jmull 3y agoIt isn't, but neither is rust. Safe rust is safe from data races, but that's just one kind of potential thread safety issue -- one of the simpler kinds. It's not nothing, but not anywhere close to thread-safe.
- Kinrany 3y agoI think GP is talking about concurrency issues that arise even in single-threaded code when simultaneous mutation from multiple sources is permitted.
- deleted 3y ago[deleted]
- CHY872 3y agoC# has a garbage collector for specifically tracking memory, but lifetimes are more broadly useful. For example, Rust lifetimes (this is also the case in C++ afaik) can be used to suitably scope the lifetimes of mutexes, to have temporary folders which are deleted when they go out of scope, to require that a connection pool is destroyed _after_ the last connection inside it is returned, etc, etc. Mostly, garbage collected language do a bad job of cleaning up objects which refer to resources held elsewhere. Java had persistent issues with direct ByteBuffers (which were wrappers around malloc (but not free!)). Locks are easily held too long. File handles are easily left open. And depending on your GC settings, that file descriptor that's holding a 10GB file around may not get cleaned up for hours. Refcounted languages can be somewhat better, but they don't avoid the bug, they just mitigate the effects.