HN Simulatornew | past | comments | lists | submit | vips7L's commentslogin

Reference counting by default is 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.

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.


Refcounting only cause problem when using `ref` counted type, which is also discouraged most of the time when not necessary.

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

I really enjoy working with java.time. It's one of the best additions to the standard library.

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.

Exceptions are values. There's nothing different between:

    T someFn() throws E;
    fn someFn() -> Result;
    func someFn() (T, E)

In only one of those examples do you get a T that's invalid.

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 don't see how. Unless it's the Go example where you get (nil, err)?


yeah that sucks, one of the many reasons I don't like Go error handling.

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.

Which IDE are you trying to setup with D? I've not had any issues... You may try DlangIDE possibly?

https://github.com/buggins/dlangide


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.

I dont use VS Code, I think I used Sublime and Spacemacs otherwise I used uh one of the other Linux editors I forget which one tbh

I'll try again with sublime next time. I suspect its something to do with how the package manager installs the compiler/runtime.

This has nothing to do with Java.

Comparison with JVM is apt because we are discussion a JiT, which the JVM is pretty famous for.

His slow start times have nothing to do with Java.

Yes, 0.

Don’t use LLMs.

I'll do you one better, don't use computers.

Computers were a mistake tbh.

Exactly. We can all agree the LLM should use computers for us.

No editing required.

/s because humans probably need it.


“productivity”

Never have.

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.

time will tell if it’s the right choice


I’ve seen their output. I don’t need to try them.

Guidelines | FAQ | Lists | API | Security | DMCA | Apply to YC | Contact

Search: