4 ms·
Does anyone have experience with Nim and Zig that can talk about which use-cases each works better for?
by jadbox 4y ago
Does anyone have experience with Nim and Zig that can talk about which use-cases each works better for?
- Symmetry 4y agoI'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.
- k__ 4y agoIsn't the GC of Nim optional?
- spijdar 4y agoOptional, 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.
- auxym 4y agoCorrect. 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.
- ilaksh 4y agoYou're information seems to be dated by the presentation.
- http-418 4y agoTIL 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/31ed37682ef1576b16bca1432ea9f782 https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9...
- goodpoint 4y ago> if you can use a garbage collected language With ARC there's no GC runtime anymore, making Nim a competitor with Rust.
- timeon 4y agoDo you mean with Rust's Rc or Arc?
- generichuman 4y agoThey mean this: https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc-in-nim.html https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
- ZoomZoomZoom 4y agoI suggest you think of Nim as of 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.
- anta40 4y agoI 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?
- auxym 4y agoHopefully 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).
- ilaksh 4y agoOf course it does.
- 0cf8612b2e1e 4y agoI 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.
- ZoomZoomZoom 4y agoThe 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, high readability and high productivity. - 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.
- vfclists 4y agoPerhaps Nim will compile to Zig one day?