Comment by pjmlp
3 years ago
Because no two languages are implemented the same, and there are plenty languages with tracing GC that also support deterministic destruction.
Unfortunely people keep reading only about Java and then they think they know something about GC based languages.
Modula-3 and Mesa/Cedar are two examples from the past, D one from modern times, with many others in between.
Probably the same for the others; in D you have RAII but destruction is only deterministic for stack/static variables. There isn't deterministic destruction for heap allocated stuff unless you count manually freeing.
Except the little detail that manual heap allocation with RAII is also a thing.
In which case you're no longer using the GC. You don't have GC & deterministic destruction, you have GC xor determinism.
That case isn't completely deterministic the way stack is: for the stack you just shift the SP which is constant time, while heap allocation and deallocation require manipulation of a small database, possibly including a system call.
This is a bit of hair splitting I admit.
1 reply →
D is not a gc based language. GC is just another tool D makes available to the programmer.
For other folks who don't write D:
D has GC, no GC ("@nogc" mode), or Ref-Counting (experimentally) with "@safe" and "@live" modes.
Which is exactly the point of GC enabled systems programming languages since the Xerox PARC days.
Provide all the required features to write a full OS, while having the convenience of a GC for most of the code.
It is according to CS definition, and will keep being one unless @nogc is enabled by default for everything.
Using the GC in D is entirely at the user's discretion. You can also do functional programming in D, or not. The same with OOP, or not. Or RAII, or not.
This is unlike Java, which forces the use of GC and OOP. Or Haskell which forces functional style.
1 reply →