← Back to context

Comment by pjmlp

3 years ago

Is biased and incorrent in a few places, like disregarding system programming languages with GC that also support deterministic destruction of resources.

I'm not surprised: when you read something and the part you know about is bullshit, there's a good chance that the part you don't know about is also bullshit even you can't see it.

What language have both GC and deterministic destructors, and how does it works? I'd guess it couldn't be tracing GC (because the GC runs whenever it wants, so you don't have determinism, or at least that's my understanding). Or maybe it's something like RAII for non-memory resources (with a destructor that doesn't free memory), and a GC for memory management?

  • Mesa/Cedar, Modula-3, Active Oberon, D, Nim, for example, not to make an exhaustive list. C# also does provide some mechanisms to dive into it, since version 7, although not as easy.

    Basically you can use GC heap as usual, or native heap with untraced references, stack or global memory segments.

    Value types with constructors/destructors pairs are also supported.

    So you have all the building blocks to do C++ style RAII when needed, otherwise relax and enjoy the GC.

This article was mainly about memory safety approaches (GC, RC, borrow checking, etc) and their effects on development velocity. It wasn't trying to compare all languages along all dimensions. That would be quite a long article!

Anyway, I think you're referring to `defer`? Though perhaps you're referring to something else, as defer also appears in non-GC'd languages as well so it didn't seem like a very relevant factor in this specific comparison. I do agree that defer (and try-with-resources) can be stellar tools for GC'd languages.