4 ms·
It's great the memory-safe languages that don't sacrifice performance are growing in popularity. But I must ask, what does Rust do better than Nim?
by jasfi 4y ago
It's great the memory-safe languages that don't sacrifice performance are growing in popularity. But I must ask, what does Rust do better than Nim?
- ursuscamp 4y agoIt's been a few years since I've used Nim, but outside of the language itself, the tooling around Rust is absolutely incredible. Rust Analyzer, Clippy, Cargo, etc.
- TheNorthman 4y agoNim, while providing the same memory safety as Rust, doesn't do so without overhead. So Nim very expressly sacrifices performance for safety. In rust, for example, it's possible to safely share data between threads without incurring costs of a garbage collector. Nim uses a different GC for each thread, so it naturally increases costs on a per-thread basis.
- planetis 4y agoNo more GC in Nim now there is an optional cycle collector https://nim-lang.org/blog/2020/12/08/introducing-orc.html https://nim-lang.org/blog/2020/12/08/introducing-orc.html it also offers experimental view types.
- TheNorthman 4y agoI was sort of vaguely aware of this but thank you for pointing it out! I think the point still stands, and that reference counting like this is just a different kind of garbage collection.
- planetis 4y agoIt's not exactly like that there is cursor inference and copy elision. But ok...
- frigid 4y agoIt certainly adds (some, not many thanks to static analysis) runtime checks, but it's also fairly distinguished from typical tracing garbage collection by being deterministic. I believe ARC/ORC also works with a shared heap via "isolated" data.
- hayley-patton 4y agoThat's correct; there are two chapters of the GC Handbook on reference counting, and ye olde unified theory of garbage collection <https://dl.acm.org/doi/10.1145/1028976.1028982 https://dl.acm.org/doi/10.1145/1028976.1028982>.
- duped 4y agoNetwork effects are big at this point. Nim doesn't have a userbase or ecosystem like Rust.
- Shish2k 4y ago> what does Rust do better than Nim? I can install Rust, for one thing (I’m on an M1 mac; trying the three main nim installers, one gives me an out of date version, one gives me the x86 version, and one segfaults) Also Rust’s error messages and standard library documentation are way more helpful Also Rust runs nearly twice as fast (I do like the nim language, but no more or less than I like the rust language; tooling makes a big difference though)
- cb321 4y agoFor me (and inv2004) Nim, runs faster than Rust on your RosettaBoy project.. But perf usually depends on an awful lot of territory that is routinely unexplored before conclusions are bandied about. The Nim installation & tooling experience unfortunately can be rough. OTOH, it has like <1% the funding/exposure. Also, I find the "100s of packages dependencies" for any non-trivial Rust program to be pretty awful, as well as reading other people's Rust code (a point made more salient by all the deps). Anyway, there are many dimensions/axes by which to evaluate most things in life and usually no objective way to weight/combine them into a single overall score. So, it's often good to keep an open mind. (Not saying you don't do so personally!)
- Shish2k 4y ago> For me (and inv2004) Nim, runs faster than Rust on your RosettaBoy project I didn’t spot that it had improved that much; I guess I need to hurry up and brute-force my way past the installer issues to try it out :D
- cb321 4y agoIf it helps, I almost always just git clone & compile Nim from source myself.. takes just a couple minutes. Never tried it on an M1, though.