4 ms·
Newbie here. Can anyone share their experiences with Rust?
by marvel_boy 11y ago
Newbie here. Can anyone share their experiences with Rust?
- vbezhenar 11y agoI generally work with high level languages (Java, JavaScript, Scala) but I always loved C (and in some ways C++) because it's so close to metal. I fell in love with Rust. Usually I (internally) complain about a lot of things in languages. There are many drawbacks and bad design decisions. It might be hard to express but there's sense of engineering beaty. And I like Rust almost in every way. So far I wrote a bunch of little programs and some simple parser (bitmessage protocol). I didn't have any real problems. Macroses looked a bit clumsy, I hope they'll see some overhaul, but they did their work. Much better than cpp anyway. And I can say that it's just so easy to write code when you're 100% sure there are no problems with memory management. There are billion of other little things making life easier, but painless memory management is the big one.
- steveklabnik 11y agoI just posted this paper[1] to HN. It's an bachelor thesis comparing Rust, Go, and C for high performance computing. The author claims to have 'moderate' experience with Rust and C, at least. It includes a story about how the Rust version actually caught an error in the C and Go implementation. 1: http://octarineparrot.com/assets/mrfloya-thesis-ba.pdf http://octarineparrot.com/assets/mrfloya-thesis-ba.pdf
- st3fan 11y agoI'm interested in those stories too. Also do a search for Rust in the story subject here on HN. There are many many 'one week with rust' and 'moving to rust' articles posted. Many are interesting reads.
- Eerie 11y agoNewbie here. My first language was Python, then I wanted to learn a so-called low-level language, but not C or C++, as I felt I don't have THAT much free time to waste. This left me only Rust, and it is a pleasure to learn. The compiler errors are very helpful, and so is the community. You can take your time and gradually discover new stuff, like the difference between heap and stack, static/dynamic dispatch, Move vs. Copy semantics, usefulness of tagged unions in combination with pattern matching and so on...
- mdup 11y agoAnd if you ever want to learn C++ later (C++11 specifically), you'll have a big chunk of the work already done. Rust's move semantics are very helpful to understand C++ smart pointers, for example. Also, lambdas/closures. You'll also miss how you were babysitted (in a good sense!) by the Rust compiler, whereas C++ does not care if you mess up with dangling references!
- cornstalks 11y agoI mainly program in C and C++, but have recently started a side project in Rust. So these are thoughts from a Rust newbie (which I still think can be valuable): Pros: - Pattern matching is beautiful, and is one of the things I miss most when not working in Racket. - I love their static typing. I think they hit a sweet spot with type inference inside of functions but required types to be specified as parameters (too much inference can make it hard to know exactly what type something is, too little inference means I spend all my time writing type signatures). - Borrowing and lifetimes are neat and have helped me avoid some lifetime-related bugs. - Being able to call Rust code from C is a huge win, and I think this world needs more "systems-level" languages than C and C++. Cons: - Borrowing and lifetimes. This is actually is a huge pro, but sometimes the compiler can spot a lifetime issue that I don't understand (which makes fixing it hard). I'll get better with this with time, but associating lifetimes with object types is a bit confusing and hard to do if you want to do anything nontrivial. Again, I'm sure this is mostly because I'm a newbie, but it's also reality. - Verbosity. Rust is actually concise for the most part, but if you want to pass a &str to a function, but have a String, (which, FYI, is fairly common in my experience, as most string-related functions take a &str), you've got to either call as_str() (which is unstable) or dereference-reference (i.e. &*) the String. There are a few simple things that require you to be more verbose than some other languages do. Overall I like Rust. I think it's worth experimenting with, but I wouldn't start a really serious project with it right now (because it's so young and volatile). If someone wants to use it for a really serious project, I'd suggest checking out Rust in another year or two when it's a little more mature.
- steveklabnik 11y agoGlad you're having a good time with Rust. :) One small note: > if you want to pass a &str to a function, but have a String You can just add a & to your String. &String coerces to &str. Deref coercions are one of the few places where Rust does an implicit coercion: http://doc.rust-lang.org/nightly/book/deref-coercions.html http://doc.rust-lang.org/nightly/book/deref-coercions.html
- cornstalks 11y agoAh, cool, that's much better! Is that relatively new? I swear you had to do &* if you had a String and & if you had a &String. Edit: Ah, here: https://github.com/rust-lang/rfcs/blob/master/text/0241-deref-conversions.md#benefits-of-the-design https://github.com/rust-lang/rfcs/blob/master/text/0241-dere...