Brand new to Rust

Just started reading the Rust Book, second edition.

Anything a newbie should know about before jumping in?

I already have some knowledge with C (still a beginner, though) and I'm starting to take up Ruby (to help me learn Rails).

I gave up on Swift. OO languages are not my thing. I'm having a bad enough time with Ruby.

2 Likes

Don't be afraid to try stuff out if you're not sure. The Rust compiler has the best error messages of any compiler I've ever used, so 99% of the time if you're wondering whether something will work you can just try it (possibly using the playground) and the compiler will explain what the issue is.

People are also really nice in the Rust community! There are a couple tricky concepts like lifetimes and generics, so if you're having trouble don't be afraid to ask for help.

I find the best way to learn a new language, in general, is to rewrite an application I've already done. My standard example is writing a basic parser/interpreter for a lisp-like programming language. I've found it's quite a good introduction to how a language deals with things like string manipulation, as well as exposing you to how it deals with complex data structures. Otherwise there's also the standard problem sets like exercism and Project Euler.

There are also a lot of really good libraries out there for doing things, so don't be afraid of pulling in libraries from crates.io. Some of my favourites which I use all the time are clap (for command-line argument parsing), serde (converting to/from formats like JSON and XML), failure (error handling), and rlua (because who wouldn't want to embed a scripting language in their application?!).

6 Likes

I've been learning rust on and off for a while and just recently it clicked for me and I've never been happier. Some advice to save you some time.

First off, and most importantly, what helped me fully 'get' the language is to always think about what each line of code does memory wise. Think in terms of ownership, borrowing, and lifetimes. Do this as soon as possible to minimize pain.

Secondly, the second version of the book is what convinced me finally to fully invest in the language. It's that good. I keep a file called definitions.txt to hold definitions I encounter in the book, which they thankfully emphasize using italics. This is important because the same terms come up over and over again and it helped me understand the whole rust ecosystem more.

Good luck on your journey to learn rust, and don't give up!

5 Likes

Agreed with both!

The community very friendly regardless of your level.

The book which I'm about 40% through is exceptionally well written. It's so nice, to have this, some other language guides are woeful and made me not even bother with the language.

I am enjoying seeing how others solve the exercism problems against how I do it too. I'm trying to not get too far into exercism and not far enough into the book though, even though I can program.

I am also very impressed with intelliJ for Rust.

Ownership, borrowing are key, I'm sure they'll catch me out for some time yet as I get used to them. Another one I'm finding is understanding what types are expected, they're not always as you expect. You'll probably encounter this too as you go through Exercism.

Before you start off with anything ensure you know about ownership & borrows. That is the main principle of Rust. Other principles you can learn as you go. Remember at every small step to check if there is a better way and more "native" way of doing the same thing (cause in most cases, there is). Enjoy your ride :slight_smile:

I’m new to Rust too. I’m about a week in. I’ve read the entire Second Edition up to the server tutorial chapter. Don’t forget to read the first book too, in tandem with whichever topic you are reading. I found there was more on Errors in the 1st book. I’ve found that coding along to the second book isn’t enough to get started, unless you have a photographic memory. I do not. As others have said, knowing the rules for Ownership & References (borrowing) will make or break your experience.

I’ve read through those chapters in Blandy et al’s Programmng Rust book 3 times slowly and I have a much better understanding of the small details than I ever gained reading through the Second edition. Programming Rust was written by Mozilla Engineers, and they do a thorough job. You can read it for 10 days free on Safari Books Online, if you haven’t already signed up for a free trial.

4 Likes

Something I spent time on, that I wished I didn’t have to was deciding what coding tools to use. Having spent the last few months coding Go in Jetbrains GoLand IDE, I thought I’d try their Rust plugins but the debugger plugin itself is, by the maintainers own admission, buggy.

If you value a working step-debugger, then Visual Studio Code is your friend. There's a Rust Language Server plug-in, so you get code-completion and tooltips. Check out the status of the different options with the following link...

https://areweideyet.com

1 Like

See my post in another topic about learning Rust. I would second @Michael-F-Bryan reading the Rust Book, second edition, while completing Rust exercism.io exercises and running code in play.rust-lang.org.

Thanks everyone for replying.

I just got done with the guessing game on the Rust book.

I'll admit, the language is very different.

I'm still new to C but I feel exactly how I did when I first started learning C.