7 ms·
I also prefer Nim to Rust, but I haven't done anything extensively in either. How does Nim do in the safety area? AFAIK, Rust has e.g. regions and linear types
by nextos 11y ago
I also prefer Nim to Rust, but I haven't done anything extensively in either.
How does Nim do in the safety area? AFAIK, Rust has e.g. regions and linear types to achieve memory safety.
- pcwalton 11y agoLast I looked: - Nim had a lot of undefined behavior. Dereferencing a null pointer, for example, led to undefined behavior because of compiling to C. - Nim seemed to have less flexible data race prevention (though the abstract interpretation stuff that Nim does to determine disjointness of arrays could be more ergonomic than Rust's split_at_mut, albeit more complex). Data races were also more of a problem in Nim because the lack of a thread-safe GC meant that races could result in use-after-free. - Nim was in the typical "memory safety requires a GC; opt out of GC and you lose memory safety" category of languages (reference counting being a form of GC). Rust, by contrast, retains safety even when GC is not used (which it rarely is). This was many months ago, so it may well have changed.
- kirbyfan64sos 11y agoIn most cases, though, the GC is light enough that it can stay enabled, and you'll rarely ever end up with raw pointers. For threading, you can use the capabilities at: http://nim-lang.org/docs/threadpool.html http://nim-lang.org/docs/threadpool.html
- pcwalton 11y agoThe GC was not thread-safe at that time, so you did not need raw pointers to get the unsafety.
- dom96 11y agoThis forum thread might be of interest http://forum.nim-lang.org/t/1961 http://forum.nim-lang.org/t/1961