Worst ideas/features in programming languages?

deadalnix deadalnix at gmail.com
Fri Oct 15 16:44:57 UTC 2021


On Friday, 15 October 2021 at 16:21:32 UTC, SomeGuy wrote:
> When people complain about GC in D it's mostly because the 
> library ecosystem is by default `@YesGC`. TBH I like having a 
> GC and using it when I don't care about memory usage or speed. 
> This mostly when I use D as a Python replacement and it does 
> its job well.
>

You kind have to, the alternative being that the library aren't 
@YesGC as you say, and then whatever reference they manipulate is 
now invisible to the GC. That may cause library users to see 
their object being collected when they are still alive and a 
whole slue of similar problem.

If you want the language to support a GC, you *HAVE TO* have the 
library allocate anything using the GC.

 From there you have several options:
1/ Not use a GC at all and do manual memory management à la C++.
2/ Use a GC for everything à la Java.
3/ Not use a GC an use an ownership system instead à la Rust.
4/ Allow for manual memory management via GC free, but in which 
case the compiler can't prove anything, so things like @safe or 
@nogc cannot work by design.
5/ Use a GC *AND* an ownership system that allow the compiler to 
prove invariant about freeing (and even do a lot of it 
automatically) so things like @safe can work (and @nogc needs to 
forbid GC leaks rather than GC allocations).

D correspond to none of the above, even though it tries to be 
kind of 4 kind of 5.

Then end result in practice is that almost everything uses the 
GC, and that @safe and @nogc are almost useless.


More information about the Digitalmars-d mailing list