6 ms·
What things do you wish for in Nim from Rust?
by arc776 5y ago
What things do you wish for in Nim from Rust?
- k__ 5y agoLess clutter. I like ML and Python syntax.
- arc776 5y agoThe syntax is what attracts me to Nim too. Why use Rust over Nim in this case? Is it Rust's static lifetime constraints? Is there some feature you would miss if you used Nim instead? Or would you prefer to use Rust because more organisations are using it?
- k__ 5y agoI like the lifetimes, the traits, the pattern matching, but also that it's used by more people, yes
- cb321 5y agoNim's concepts [0] are sort of like Rust's traits or Haskell's typeclasses - maybe more expressive in some ways. Pattern matching can be added on as a simple library and has been done several times, maybe most pedagogically outlined here [1]. Lifetime annotations just seem unproductive to me. Nim with ARC/ORC does have safe [2], automatic memory management without "a GC" or need for lifetime annotations. [0] https://nim-lang.org/docs/manual_experimental.html#concepts https://nim-lang.org/docs/manual_experimental.html#concepts [1] https://nim-lang.org/blog/2021/03/10/fusion-and-pattern-matching.html https://nim-lang.org/blog/2021/03/10/fusion-and-pattern-matc... [2] https://uploads.peterme.net/nimsafe.html https://uploads.peterme.net/nimsafe.html
- arc776 5y agoThanks for your reply. It's interesting to know what the perceived weaknesses and strengths are. Nim does have pattern matching but it's rarely used, whereas it seems to be used a lot in Rust (probably because of the prominence of enums). Nim has static lifetime management, but it's mainly used for eliding and thread safety (for now). Traits are an interesting feature, and make a good example of why I'm so bullish on Nim: someone has already replicated them with a macro: https://github.com/haxscramper/nimtraits https://github.com/haxscramper/nimtraits The popularity critical mass thing is mainly getting eyes on the language, but I think Nim has a slight advantage in that it's incredibly cooperative with its compile targets and FFI. Like Python, it's great for good glue code and 'scripting' without the performance penalty, and I hope that helps it meld into people's toolboxes over time.
- lostdog 5y agoRust's Result type and `?` operator makes error handling kinda fun. Every language should strive to be this clean.
- elcritch 5y agoNim’s got an Option type, though it’s not as popular as exceptions. There’s also third party option libraries that provide ‘?’ like features.
- lostdog 5y agoHaving a single Result type as standard has a huge benefit. You can do error handling for every library you use in exactly the same way. You also get decent stack traces because the runtime can reason about a single error type. Unified error handling is, IMO, necessary for making a language a pleasant experience.
- arunc 5y agoThey probably mean ownership?