News for hackers. Stuff that matters.
Re:NimConf 2022 – Nim Online Conference by jadbox on Friday October 21, 2022 @10:38AM (#33288431)
Does anyone have experience with Nim and Zig that can talk about which use-cases each works better for?
Re:NimConf 2022 – Nim Online Conference by Symmetry on Friday October 21, 2022 @10:47AM (#33288543)
I've only used Nim but generally if you can use a garbage collected language you should in most cases but there are many cases where you can't, reasonably, and so we have languages like Zig, Rust, C, etc. Unless you're going to be doing something very sensitive to performance to the extent that you were going to be thinking carefully about memory lifetimes anyways.
Re:NimConf 2022 – Nim Online Conference by http-418 on Friday October 21, 2022 @11:58AM (#33289448)
TIL about Zig. It looks like it's been released a while ago (2016) but when I searched for how they handle concurrency all I could find was it's still in the research phase :(. I thought I was going to be able to find at least a design document like with Swift:

https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9...

Re:NimConf 2022 – Nim Online Conference by goodpoint on Friday October 21, 2022 @12:10PM (#33289608)
> if you can use a garbage collected language

With ARC there's no GC runtime anymore, making Nim a competitor with Rust.

Re:NimConf 2022 – Nim Online Conference by timeon on Friday October 21, 2022 @05:29PM (#33293245)
Do you mean with Rust's Rc or Arc?
Re:NimConf 2022 – Nim Online Conference by generichuman on Friday October 21, 2022 @08:54PM (#33294581)
Re:NimConf 2022 – Nim Online Conference by k__ on Friday October 21, 2022 @11:18AM (#33288903)
Isn't the GC of Nim optional?
Re:NimConf 2022 – Nim Online Conference by spijdar on Friday October 21, 2022 @11:35AM (#33289117)
Optional, though the language and standard library are kind of designed around it. So I'd say Nim can be used without the GC, but is optimized with the idea that you'll use the GC by default, with escape hatches for manual allocation when you need the power for performance or efficiency, e.g. manually managing big blocks of memory for tight loops.

Contrast to a language like Zig, which has a standard library and syntax built around the idea of manual allocators and what not, but is missing the "ease of use" of GC. Personally, I agree with GP, and like Nim's compromise of GC with a "I know better, let me do it manually" syntax, but there are domains where you want a language like Zig.

Re:NimConf 2022 – Nim Online Conference by auxym on Friday October 21, 2022 @11:48AM (#33289305)
Correct. I'd add that with ARC (or ORC even), there's little reason to do manual memory management (alloc/free), even for embedded systems. ARC is an automatic memory management system based on reference counting, but there's no "runtime". It actually injects alloc and free calls at compile-time based on static analysis.

ORC adds runtime GC only for cycles, and will be the default in Nim 2.0.

Re:NimConf 2022 – Nim Online Conference by ilaksh on Sunday October 23, 2022 @06:22AM (#33305881)
You're information seems to be dated by the presentation.
Re:NimConf 2022 – Nim Online Conference by ZoomZoomZoom on Friday October 21, 2022 @11:23AM (#33288990)
I suggest you think of Nim as a better Go - more ergonomic, easier to start being productive in, faster, giving more control if necessary (by descending into the unsafe territories of manual memory management, `emits` and such), more portable, suitable for workstations and embedded alike.

Zig is definitely not that. And I understand the description above misses the downsides of a small community and not the strongest ecosystem.

Re:NimConf 2022 – Nim Online Conference by 0cf8612b2e1e on Friday October 21, 2022 @12:21PM (#33289763)
I think it is a stretch to compare Nim and Go as anything other than statically compiled languages. Nim is the anti-Go with every possible programming paradigm inside the language.
Re:NimConf 2022 – Nim Online Conference by ZoomZoomZoom on Friday October 21, 2022 @12:39PM (#33290022)
The implementation details and the development ethos differ, but from the pragmatic point they compete, offering higher abstraction level over C. Moreover:

- Both took some inspiration from languages of Wirthian family.

- Both promise easy onboarding and high readability.

- Both rely on automatic memory management by default.

On the other hand, I agree that Nim feels and functions totally different while offering much more possibilities. You can definitely call Nim the anti-Go, but it doesn't negate the fact it could absolutely shine in the same domains, at least with a bit more love, attention and funding.

Re:NimConf 2022 – Nim Online Conference by Mikeb85 on Saturday October 22, 2022 @01:07AM (#33295788)
But they're both statically typed GC languages that compile to native binaries. Versus Zig which has no GC and is more akin to C, Rust, Ada, that sort of thing...
Re:NimConf 2022 – Nim Online Conference by goodpoint on Saturday October 22, 2022 @05:26AM (#33296755)
With ARC Nim is also very akin to Ada and Rust: https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
Re:NimConf 2022 – Nim Online Conference by Mikeb85 on Saturday October 22, 2022 @12:39PM (#33299826)
> ORC is Nim’s all-new cycle collector based on ARC. It can be considered a full-blown GC since it includes a local tracing phase (contrary to most other tracing GCs which do global tracing). ORC is what you should use when working with Nim’s async because it contains cycles that need to be dealt with.

From that blog post. Nim is great but it's more Go and less Rust...

Re:NimConf 2022 – Nim Online Conference by goodpoint on Sunday October 23, 2022 @05:55PM (#33310664)
> more Go and less Rust

Not at all, it does not have a runtime with a built-in thread pool and channels like Go.

Re:NimConf 2022 – Nim Online Conference by anta40 on Friday October 21, 2022 @11:34AM (#33289112)
I learnt a bit of Nim few years ago, but haven't continue it. My understanding so far is unlike Go, Nim doesn't have concurrency built into the language/runtime?
Re:NimConf 2022 – Nim Online Conference by auxym on Friday October 21, 2022 @11:43AM (#33289231)
Hopefully it should get better soon-ish, but concurrency (and even parallelism aka threads) unfortunately is probably Nim's weakest point at the moment.

On the good side, compared to go, Nim's interop with C is fully transparent (since Nim uses C as a backend). This means easy access to C libraries, but also makes it very appropriate for embedded targets like microcontrollers (especially with its ARC memory-management system, which is static/deterministic automatic reference counting).

Re:NimConf 2022 – Nim Online Conference by ilaksh on Sunday October 23, 2022 @06:21AM (#33305877)
Of course it does.
Re:NimConf 2022 – Nim Online Conference by vfclists on Friday October 21, 2022 @03:16PM (#33291976)
Perhaps Nim will compile to Zig one day?