From r/linux: Which language should i use/learn ?

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 11 23:06:17 PST 2016


Chris Wright <dhasenan at gmail.com> wrote:
> Okay, and D gives me sufficient tools to not leak database connections 
> under typical workflows. So does C#. So does Python. So does Java, these 
> days. The last time it's been even vaguely annoying for me was with 
> nodejs, thanks to callback hell, and even then it was only an annoyance.

TBH, IDisposable/AutoClosable is just a PITA. It's like going back to
manual memory management and doesn't work at all for shared ownership.

> The only type of resource I have to deal with that isn't a database 
> connection or memory is a socket. They don't go out of scope before 
> they're closed. Ever. So that automatic resource cleanup stuff doesn't 
> even help there.

Another kind is wrapping non-threadsafe FFI object structures, which are
actually also memory.
Because of finalizers running in a different thread, you cannot just rely
on the GC but have to make everything either synchronized or IDisposable
(or a combination thereof).
It's not impossible but requires some serious thought and overhead.

> My handling of non-memory resources that require any sort of cleanup 
> takes up like 3% of my code, constrained to two files. (I measured.) So  
> it's going to be right quick for me to isolate any problems.

The problem is not where the code is written but where it is used
(transitively).
Tools like IDisposable are contagious and infect everything that's using
it.





More information about the Digitalmars-d mailing list