Hacker News new | ask | show | jobs
by vips7L 2057 days ago
How do you manage memory then? Linking to libc and malloc/free?
2 comments

--gc:arc. Plain reference counting with move semantic optimizations, offers a shared heap. It offers deterministic performance for hard realtime systems. Reference cycles cause memory leaks, beware. --gc:orc. Same as -gc:arc but adds a cycle collector based on "trial deletion". Unfortunately that makes its performance profile hard to reason about so it is less useful for hard realtime systems. --gc:none. No memory management strategy nor garbage collector. Allocated memory is simply never freed. You should use --gc:arc instead.

Nim offers alloc, dealloc, allocShared, deallocShared

So in other words Nim does not actually offer a true compile-time memory management feature like Rust does? I'm afraid my impression of a language only decreases when I see its supporters dodge an issue like this...
Yes, if you want to operate in "unsafe" mode you can manage memory yourself with pointers and malloc/free. But it is rarely needed in practice. Also, Nim compiles to C or C++ (and also to Javascript). Because of that Nim's C/C++ FFI is natural ans wrapper-free.