← Back to context

Comment by 9rx

1 month ago

> The C language does not use your C code

Your impression that there is a semantic authority misses the mark. While you are free to use English as you see fit, so too is everyone else. We already agreed on the intent of the message, so when I say something like "C uses C code", it absolutely does, even if you wouldn't say it that way yourself. I could be alone in this usage and it would remain valid. Only intent is significant.

However, I am clearly not alone in that style of usage. I read things like "Rust can use code written in C" on here and in other developer venues all the time. Nobody ever appears confused by such a statement even. If Rust can use code written in C, why can't C use code written in C?

> The C language does not specify a garbage collector so it can never use one.

The C language also does not specify a linked list. Go tell your developer friends that C can never use a linked list. Please take a photo when they look at you like you have two heads. Admittedly I lack the ability to say something so outlandish to another human with a straight face, but for the sake of science I put that into an LLM. It called me out on the bullshit, pointing out that C can, in fact, use a linked list.

For what it is worth, I also put "C can never use a garbage collector" into an LLM. It also called me out on that bullshit just the same. LLMs are really good at figuring out how humans generally use terminology. It is inherit to how they are trained. If an LLM is making that connection, so too would many humans.

> In JavaScript and Go, the language specifies the presence of garbage collection

The Go language spec does, no doubt as a result of Pike's experience with Alef. The JavaScript spec[1] does not. Assuming you aren't making things up, I am afraid your intent was lost. What were you actually trying to say?

> C code and C compiler will still not be garbage collected.

That depends. GC use isn't typical in the C ecosystem, granted, but you absolutely can use garbage collection in a C program. You can even use something like the CCured compiler to have GC added automatically. The world is your oyster. There is no way you couldn't have already realized that, though, especially since we already went over it earlier. It is apparent that your intent wasn't successfully transferred again. What are you actually trying to say here?

> This is turning into trolling.

The mightiest tree in the forest could be cut down with that red herring!

[1] The standard calls itself ECMAScript, but I believe your intent here is understood.

> The C language also does not specify a linked list. Go tell your developer friends that C can never use a linked list.

They would not blink because the statement is accurate. To the C language and to the C compiler, there are no linked lists - just random structs with random pointers pointing to god knows what. C does know about arrays though.

> The JavaScript spec[1] does not [specify garbage collection].

I have good reason to believe that you are not familiar with the specification, although to be fair most developers would not be familiar with its innards.

The specification spends quite a while outlining object liveness and rules for when garbage is allowed to be collected. WeakRefs, FinalizationRegistries, the KeptObjects list on the agent record, ...

Just like with Go, it is perfectly valid to have an implementation of a "garbage collector" that is a no-op that never collects anything, which means that the application will continously leak memory until it runs out and crashes as the language provides no mechanism to free memory - for Go, you can switch to this with `GOGC=off`. The specific wording from ECMA-262:

> This specification does not make any guarantees that any object or symbol will be garbage collected. Objects or symbols which are not live may be released after long periods of time, or never at all. For this reason, this specification uses the term "may" when describing behaviour triggered by garbage collection.

If you're not used to reading language specs the rest of the details can be a bit dry to extract, but the general idea is that the spec outlines automatic allocation, permission for a runtime to deallocate things that are not considered "live", and the rules under which something is considered to be "live". And importantly, it provides no means within the language to take on the task of managing memory yourself.

This is how languages specify garbage collection as the language does not want to limit you to a specific garbage collection algorithm, and only care about what the language needs to guarantee.

> [1] The standard calls itself ECMAScript, but I believe your intent here is understood.

sigh.

> For what it is worth, I also put "C can never use a garbage collector" into an LLM. It also called me out on that bullshit just the same.

more sigh. LLMs always just wag their tails when you beg the question on an opinion. They do not do critical thinking for you or have any strong opinions to give of their own.

I'm done, have a nice day.

  • > To the C language and to the C compiler, there are no linked lists

    But are most certainly able to use one. Just as they can use a garbage collector. You are quite right that these are not provided out of the box, though. If you want to use them, you are on your own. Both Limbo and Rust do provide a garbage collector to use out of the box, though, so that's something different.

    > The specification spends quite a while outlining object liveness and rules for when garbage is allowed to be collected. WeakRefs, FinalizationRegistries, the KeptObjects list on the agent record, ...

    But, again, does not specify use of a garbage collector. It could use one, or not. That is left up to the implementer.

    > it is perfectly valid to have an implementation of a "garbage collector" that is a no-op that never collects anything

    It's perfectly valid as far as the computer is concerned, but in the case of Go not spec-compliant. Obviously you don't have to follow the spec. It is not some fundamental law of the universe. But if you want to be complaint, that is not an option. I get you haven't actually read the spec, but you didn't have to either as this was already explained in the earlier comment.

    > This is how languages specify garbage collection

    That is how some languages specify how you could add garbage collection if you so choose. It is optional, though. At very least you can always leak memory. Go, however, explicitly states that it is garbage collected, always. An implementation of Go that is GC-less and leaks memory, while absolutely possible to do and something the computer will happily execute, does not meet the conditions of the spec.

    > I'm done

    Done what? It is not clear what you started.