Program crash: GC destroys an object unexpectedly

Steven Schveighoffer schveiguy at gmail.com
Thu Sep 23 13:05:07 UTC 2021


On 9/23/21 8:10 AM, eugene wrote:
> On Wednesday, 22 September 2021 at 18:38:34 UTC, Steven Schveighoffer 
> wrote:
>> I find it interesting how you blame yourself for C's idiosyncrasies
> 
> Me? Blaming *myself* for C 'idiosyncrasies'? :) Where?

"When my C program crashes, I'm 100% sure I made something stupid"

One might argue that C's approach to memory management is a contributor 
to people writing code that fails.

>> I would say C has far more pitfalls than D.
> 
> No doubt - and I've never said C is "better" than D.
> I was going to try betterC subset
> (say, try to implement dynamic arrays),
> but did not have much free time yet.

Your assertion that programming in GC languages may be harder than 
manual memory languages is what I was addressing.

My point is that C has a lot more memory management pitfalls than D, not 
addressing any "better than" arguments.

> 
>> Check out the undefined behaviors for C.
> 
> Nothing interesting...
> Most of UB in C are just programmer's sloppiness.
> C requires a programmer to be careful/punctual,
> much more careful, than ... a python, for ex.

UB in C leaves traps for the programmer, similar to this trap you have 
found in the GC. Where code doesn't do what you are expecting it to do.

-Steve


More information about the Digitalmars-d-learn mailing list