What do you do for improving your Rust coding skill?

Hello.
I'm a beginner programmer from Japan.

I use kotlin at my work. So I learn Rust in my private time. I'm looking for a good way to improve my Rust coding skill because I want to use my time efficiently.

For improving my Rust skill, I do 2 things.

One is seeing Rust forum and chatting with the people there. They often say that making a conversation about Rust with many people is good. So I keep chatting this forum.

The other is making something in Rust in fact. For example, I implemented HLS function on an open source RTMP server. (It is not completed yet though :roll_eyes:) I wonder it was effective.

They are what I do for improving my Rust skill, and then I'm interested in what you do.

What do you do for improving your Rust coding skill?

I try to get good at reading the Rust crates docs; and it's not easy since I often have trouble mapping my programming experience in other languages to what I see in the docs.

Wading through code examples (if a crate provides any) in various crates helps me understand what is meant by cryptic passages in the crates docs; then asking for advice on this forum helps a great deal.

It would be really great if there were a section of mandatory comprehensive examples of using the crate listed in the docs; sometimes "there are", but mostly not.

1 Like

Good, I have to do that, too.
It is kinda hard and it takes much time from me :scream_cat:

I've started some programmer challenges in rust. Things like advent of code and Project Euler problems.

The downside is that these problems are already quite hard so aren't the best way to learn rust. If anyone hasn't already, read the book to be introduced to rust's unique concepts.

If you've read (and reread) the book, but still struggle to write rust code (I've been there!) I would recommend getting to know the rust documentation, just the std library (it helps that all crates use the same documentation format.

There are lots of useful functions (combinators?) for Option and Result that can help a lot as well as lots of iterator functionality.

Finally, projects. Find something with a well defined scope that is easy and make it! You can always finish it early and try something harder next. Personally I'm terrible at finishing projects, but even without finishing I've learned something :slight_smile:

2 Likes

I don't get into coding challenges much. I find it hard enough to get anything want to do working.

But as I was trying to get familiar with Rust a few months back I happened to recast a Project Euler solution from C to Rust. Problem number 256 : Tatami-Free Rooms: https://github.com/ZiCog/tatami-rust

To be honest I'm still not sure how it works but when I matched the speed of the C versions I was happy.

1 Like

I walked through the Rust docs i could found and was collecting the features i needed. It matched. I wrote a few small libs in C before and tried to implement them into Rust. That is an very easy Way i think. Of course reading the Rust documentation beside again and again.

My improvements are based on the needs inside the libs. So it was a good way to start.

After that i took a look on each Help Section Post in this Forum and try to understand how real rust Programmer/Inventor are thinking. If i found new Ways to handle old Stuff i tried to used them too.

But thats not a special but an common Way to learn and improve yourself.

1 Like

Start coding something, but limit yourself to a subset of the language at first. No references in structs; no generics; don't use traits; clone freely to make the borrow checker happy; don't worry about writing macros. Limiting yourself to this subset of the language will make it easier to learn about Option and Result, get comfortable with iterators, get a feel for why the borrow checker yells at you, and learn when functional style makes sense.

Once you feel comfortable with the subset, start to use more advanced features. Traits were the first thing I added to my code. Then I eliminated the bulk of the clone operations by having long conversations with the compiler. Generics came next. Finally, I created a couple of structs that had references. Next on my list is to write a macro or two.

3 Likes

I think that is sound advice.

I started out by reading the book till I reached some level of comprehension overload. That's no good, I need to see something working.

So I set out writing simple code, in the style of C which is a language I have used a lot. After many long and interesting discussions with the compiler things came together. The error messages are very good and often the suggestions it makes to fix them are on the mark. But beware, when you get into more complex things, like using async and tokio, the error messages can be totally meaningless and following any suggestions it makes will lead you astray.

It's amazing how far you can get without ever creating macros or traits or generics or fussing with lifetime tick marks.

I like the approach of https://learncodethehardway.org/c/. If you see an nice example in the book or else where then tweak with it, try to break it, see what happens. Getting familiar with the most common error messages and what you did to induce them is invaluable.

2 Likes

It feels a good way because I'm a novice. I don't actually understand not only macros, but also something advanced. So I have to understand them one by one. :smile_cat: