Garbage Collection for Systems Programmers

ryuukk_ ryuukk.dev at gmail.com
Thu Apr 4 15:42:24 UTC 2024


On Thursday, 4 April 2024 at 14:32:58 UTC, bachmeier wrote:
> On Thursday, 4 April 2024 at 04:01:56 UTC, cc wrote:
>
>> Seriously though, what an asinine opinion.  Excluding an 
>> entire market, to satisfy your religious opinions on memory 
>> management.  Nobody has stopped anyone from improving the GC.  
>> By all means, please improve the GC.  I develop commercial 
>> games in D, I have come to avoid the GC much of the time, and 
>> I'm pretty sure I haven't spent any of the past 10 years of my 
>> workload getting in your way of making the GC the best it 
>> could be.  I simply haven't been using it.  Oh no, someone 
>> exposed GC.free and __delete as a hacky temporary stopgap?  
>> Gosh, that 30 seconds of work sure did get in the way of a 
>> decade of someone else making that thing I want better.
>
> I think you're taking the wrong thing from this conversation. 
> You're helping to make the case that the anti-GC crowd is 
> wrong. For me, the problem is that the anti-GC zealots make the 
> following claims:
>
> - The GC gets in the way. It needs to be removed the way Rust 
> removed theirs for performance reasons.
> - D isn't suitable as a systems programming language because it 
> has a GC.
> - GC should be removed as the default because it leads to bad 
> practice.
> - All D programs have to use the GC.
>
> These things appear on Reddit, Hacker News, etc. etc. any time 
> D is discussed, and it has an effect. Convincing someone to use 
> the GC might be right on paper in some cases, but in practice 
> it doesn't work if the other side has a fundamentalist 
> viewpoint that the GC has to be removed entirely. You can see 
> it in the comments on the story: "That's a valid point, but..."
>
> I do think we need to be realistic and realize that the anti-GC 
> crowd has found its love and they've married Rust or they've 
> decide that C++ is a flawed but good enough spouse. That battle 
> is over. D needs to worry about folks that like C (D makes it 
> realistic for them to keep writing the code they like writing) 
> and folks that like GC (the story's probably not as good as it 
> could be).
>
> I'll also add that I use SafeRefCounted a lot, so I'm also 
> avoiding D's GC much of the time rather than forcing the GC 
> into everything I do.

There is no anti-GC crowd

I will not speak for other people, so i will speak for myself

I advocate for: GC as a library and core language as pay as you 
go, so i can use a great language without people making it 
annoying to use

Imagine:

```D
int[] myarray;
create_array(allocator, myarray, length: 16);


int[int] mymap;
create_map(allocator, mymap)


// or fall back to using GC for casual scripting
```

No need to pick a clan, be smart, enable people


There is no reason to require the GC to report errors for 
example, this is beyond stupid

The absolute best is what Zig is doing by encouraging people to 
use/request for an allocator

The pro-gc people love to enforce the GC everywhere that's not 
needed, and when people start having issues with it, everyone 
becomes silent

```D
import core.memory;
import std.stdio;
import std.conv;
import std.datetime.stopwatch;

string[int] stuff;

void main()
{
     for (int i = 0; i < 10_000_000; i++)
         stuff[i] = "hello_" ~ to!(string)(i);

     auto sw = StopWatch(AutoStart.yes);
     auto a = new ubyte[512_000_000];
     writeln(sw.peek.total!"seconds");
}

```

Question to pro-GC crowd, why does it take 2 seconds to create 
the array?


More information about the Digitalmars-d mailing list