4 ms·
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
by Symmetry 4y ago
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.
- 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...