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.
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
Java has a pretty good approach of promoting the more popular library for a thing to standard library status, with relatively minor changes. It's an easy way to get a really good standard library over time, as it's already proven in practice
Personally I think Go style is worse, because the runtime and compiler don't force you to handle the error. I just had to fix a critical issue because a dev forgot to check the result coming from a function, exceptions would have forced it to happen.
Some patterns, notably when a reasonable default can be provided, are better handled in Go. In such a case the error handling can often be omitted entirely. Neither Rust or Go recognize this pattern explicitly, however. In Go, as your comment, the function signature doesn't say the result value is actually a valid default when there is an error.
True, Go does require you to follow a convention here (dont use T if err is not nil). In practice it works pretty well, though obviously not bullet proof.
I believe some exceptional languages are similar, like Ruby. If you rescue but dont abort, the variable on the left hand side gets a nil when that may otherwise not be possible. Of course, that is handled cleanly as its own error.
I try D almost every year, but I've never really gotten a working IDE environment with it. I'm not sure if it's issues with being on Windows or just the LSP not being that great. I really wish D was adopted as widely as Go.
I've tried the intellij plugin and vscode extension. It never seems to work right. I remember there being lots of issues about not finding phobos/the standard library.
in that case an argument could be made that you are behind the curve.
there’s very little downside to earnestly trying it, I used it for like a month, realized that it got out of my control, and if I wanted to master it I would have to develop skills and tooling, which seemed counterproductive at worst, and competing in a massively oversupplied field at best.
so my competitive advantage is now NOT using vibecoding.
reply