IIRC, ref counting is at least more deterministic than traditional GC because it only runs when you destruct the object (it goes out scope, object gets reassigned whatnot).
In Comparison, traditional GCs like JVM runs on a background thread, it's hard to determine when they run and generally blocks the whole program while collecting (stop-the-world).
So at least they are a little better in that regard?
I can’t speak of Nim’s implementation but reference counting can block the whole program as large object graphs have to decrement their counts. But you are right it is more deterministic.
Javas modern GCs also have extremely low pauses. ZGC is effectively pauseless, you’re likely to experience kernel jitter/traps that last longer than a ZGC pause.
Does it suffer from the same trap as Dlang, in that their GC is also optional, but you lose the many of the conveniences from the standard library if you forgo completely with it?
GC is optional in the sense "don't use `ref` types and there will be no GC"
Value types (`object`) use mutable value semantics and scope based destructors, so there are safe without GC
ref counting is only performed if you use `ref` types, e.g.
type
RefObj = ref object
foo: string
bar: int
ValueObj = object
foo: string
bar: int
`RefObj` is ref counted equivalent to a shared_ptr in C++ land (non-atomic counter unless using --mm:atomicArc or Nim3/Nimony has this as a default I believe). `ValueObj` is equivalent to struct in C, C++, etc.