5 ms·
Nim accomplishes memory safety using a garbage collector. That's pretty dissimilar to rust and more comparable to go or D.
by ben-schaaf 4y ago
Nim accomplishes memory safety using a garbage collector. That's pretty dissimilar to rust and more comparable to go or D.
- DeathArrow 4y agoNim allows you to chose what memory management method you want to use in a particular piece of software. It can be one of various garbage collectors, reference counting or even no memory management. It allows you to use whatever suits your needs.
- avgcorrection 4y ago> > Nim accomplishes memory safety using a garbage collector. No memory management in Nim equals no memory safety guarantees. Or no? Well in that case the statement above is true.
- cb321 4y agoYou can get management and safety with one of Nim's modes, as per the peterme link in my sibling, if you would like to learn more.
- avgcorrection 4y agoI don’t understand why you all are posting tedious details and well actuallys when the original assertion was (way back): > Nim, which technically accomplishes all (I assume) of the Rusty things that require syntax, manages to do it with quite a lot nicer syntax. Nim does not have something which gives both memory safety and no ((tracing garbage collector) and/or (reference counting)) at the same time. End of story. The fact that Nim has an off-switch for its automatic memory management is totally uninteresting. It hardly takes any language design chops to design a safety-off button compared to the hoops that Rust has to jump through in order to keep its lifetimes in check.
- cb321 4y ago>Nim does not have something which gives You are simply incorrect, appear unwilling to research why/appear absolutist rather than curious, and have made clear that what I think is "clarification" or "detail expansion" you deem "tedious" or "nitpicking" while simultaneously/sarcastically implicitly demanding more details. That leaves little more for me to say.
- avgcorrection 4y agoSorry about being an arse. I got frustrated by all the talking-past-each-other.
- avgcorrection 4y agoYou have managed to point out that tracing garbage collection and reference counting are indeed two ways to manage memory automatically. Three cheers for your illuminating clarification.
- Aeolun 4y agoIt would be helpful if you pointed out the Nim memory management method that works the same as the Rust one.
- j-james 4y agoFor posterity: https://news.ycombinator.com/item?id=31438134 https://news.ycombinator.com/item?id=31438134
- cb321 4y agoWhile tracing garbage collection is indeed one possible automatic memory management strategy in Nim, the new --mm:arc may be what darthrupert meant. See https://uploads.peterme.net/nimsafe.html https://uploads.peterme.net/nimsafe.html Nim is choice. :-) {EDIT: As DeathArrow also indicated! }
- avgcorrection 4y agoReference counting is a form of garbage collection.
- cb321 4y agoTerminology in the field can indeed be confusing. In my experience, people do not seem to call reference counted C++ smart pointers "garbage collection" (but sure, one/you might, personally). "Automatic vs manual" memory management is what a casual PL user probably cares about. So, "AMM" with later clarification as to automation options/properties is, I think, the best way to express the relevant ideas. This is why I said "tracing GC" and also why Nim has recently renamed its --gc:xxx CLI flags to be --mm:xxx. Whether a tracing collector is even a separate thread or directly inline in the allocation code pathway is another important distinction. To muddy the waters further, many programmers often mean the GC thread(s) when they say "the GC". What runtimes are available is also not always a "fixed language property". E.g., C can have a tracing GC via https://en.wikipedia.org/wiki/Boehm_garbage_collector https://en.wikipedia.org/wiki/Boehm_garbage_collector and you can get that simply by changing your link line (after installing a lib, if needed).
- avgcorrection 4y agoI see now that the GP wrote “a garbage collector” (not the article). Oops! “A reference counting method” doesn’t roll off the tongue. So it appears that your nitpicking was indeed appropriate.
- pjmlp 4y agoTerminology in the field is what CS books like "The Garbage Collection Handbook" (https://gchandbook.org https://gchandbook.org), or "Uniprocessor garbage collection techniques" (https://link.springer.com/chapter/10.1007/BFb0017182 https://link.springer.com/chapter/10.1007/BFb0017182), define. People don't call reference counted C++ smart pointers "garbage collection", because they aren't managed by the runtime, nor optimized by the compiler, rather rely on basic C++ features. But they call C++/CX and C++/CLI ref types, automatic memory management, exactly because they are managed by the UWP and CLR runtimes respectively, https://docs.microsoft.com/en-us/cpp/cppcx/ref-classes-and-structs-c-cx?view=msvc-170 https://docs.microsoft.com/en-us/cpp/cppcx/ref-classes-and-s... https://docs.microsoft.com/en-us/cpp/dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli?view=msvc-170 https://docs.microsoft.com/en-us/cpp/dotnet/how-to-define-an...
- xigoi 4y agoThat doesn't really matter for syntax. You could easily add lifetime syntax to Nim.
- darthrupert 4y agoWell, it's not exactly garbage collection in the way it's commonly understood, I believe: 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...