3 ms·
I think ultimately the big thing Rust brings to the table is that a lot of Rust's features is geared towards detecting problems as early as possible. This mean
by otikik 4y ago
I think ultimately the big thing Rust brings to the table is that a lot of Rust's features is geared towards detecting problems as early as possible.
This means you get complexity, especially on the "initial phases".
* The initial learning curve is steeper than usual . You have x types of string instead of one or two, you have lifetimes, etc, etc. Fortunately you pay it once and then can use it many times (maybe with some revisits to the docs :P)
* The initial building of a feature might take a bit longer than in other less complex languages (the borrow checker gives you a particularly tricky error, etc). But what is happening here is that the language is picking up problems that other languages ... don't. They "defer to production".
Others are mentioning that cargo is another feature that helps. I think it does, but indirectly. What cargo does is improving the developer experience. Having all the packages at the tip of your fingers, without needing to jump over hoops like in other languages is just ... nice. Given the initial ramp up in complexity, and the initial harder-than-usual first write, anything that improves the UX goes towards alleviating that. I personally would put cargo on the same bucket as "helpful compiler messages" and "good docs".
- 0x457 4y agoAgree with you on most except for one point: > You have x types of string instead of one or two Funny how you said X, while there are really only 3 types of strings in standard library. You generally only encounter 2 of them: String and OsString. OsString, while annoying, but it's one of the things that makes rust safe. You only ever deal with 3rd type, CString, when you work with FFI, at which point you better already know how strings work on C.
- nicoburns 4y agoThere is also PathBuf, which would use a string in most languages. And sometimes one may need to work with Vec<u8> or Vec<Char>. And then slice/view variants of all the above.
- manholio 4y ago> And then slice/view variants of all the above. So all in all, about a dozen kinds of strings.
- d3nj4l 4y agoYeah, when Rust beginners (like me!) think "types of string" I think it's more likely to be &str (and its lifetime variants), String and Vec<u8>. I've gotten pretty far as a beginner by sticking to over-copying with just String, but eventually I think I'll have to figure out what works best for perf.
- 0x457 4y ago> There is also PathBuf, which would use a string in most languages. I feel bad for them. I wanted to fix something in NeoVim's built-in lsp recently and lost all interest because of all the things you have to do to: - Get parent directory for a path - Create that directory if it exists Why was I annoyed by that? Well, different OSs use different path separators, in rust this is trivial because `Path` and `PathBuf` are target-specific. That's not a type of string though, it's a path, the fact that it uses `OsString` underneath is irrelevant. > Vec<u8> or Vec<Char> There isn't really anything special to learn about it them, though? I doubt newbie encounter this while learning. Slices are the same thing, you just can't extend it, what is there to learn?
- otikik 4y agoI said X because people include some and not others, and the conversation rapidly deviates (as shown on this thread). The point remains that there’s more ways to skin that particular cat in Rust than in other languages.