Where can I learn just enough Rust for CP?

Hi everyone,

I am a Python programmer (83rd %ile according to Pluralsight Skill IQ), getting into Competitive Programming.

C++ (and its errors like segfault and stuff) makes me spend too much time on language instead of solving problems & learning Algo & DS.

So I want to learn Rust. Of course loops, variables, etc. concepts are transferable, but I want to learn to write good Rust code, not like a toddler stringing together words.

My aim is

  1. ASAP :- be immediately productive in CP with Rust
  2. Next :- write idiomatic Rust
  3. Someday :- discover lang internals to really master Rust.

How can get 1, 2 &3?

Have you taken a look at the book yet? It gives a good overview over all the important features to get you started using the language properly and isnʼt too long.

I wrote about Rust and competitive programming here.

3 Likes

Have you tried https://exercism.io/

Note that when it comes to competitive programming, the platform I know that supports Rust the best is kattis.

1 Like

For 1 & 2 the best way to get up and running would be to take a problem you have solved before in another language and try to implement it in Rust.

You'll probably struggle at first because the language tends to prefer correctness over immediate productivity. That means where some languages may let you get away with fumbling through and figuring it out later (typically in a debugger), the Rust compiler often won't let your code compile until it's at least moderately correct.

Some general bits of advice for getting into Rust:

  1. Read the error message. Like, actually read it! The Rust compiler's error messages are really well written and often come with little hints or suggestions for how you could fix the issue. I know when I was writing C# I was trained to barely look at the error message from Visual Studio's output window because it was a useless generic one-liner and you often see the same thing in newbies that come to this forum from other languages.
  2. Use the community. A lot of the places around Rustaceans hang out on the internet are helpful and welcoming (I personally prefer this forum and the community Discord). There are lots of people who want to help you figure out your question or improve your knowledge, you just need to learn how to ask. Then once you've gained a bit of familiarity with the language, try to pay it forward by helping the next guy.
  3. Don't learn more than you need to. You probably don't need to worry about this because your explicit goal is to be productive quickly, but it's worth saying anyway. As a systems language, Rust tries to give programmers a lot of control over how things are done so there are a lot of advanced features for you to explore (traits, lifetimes, sync vs async, FFI, etc.). The trick to getting somewhere is to know how far down the rabbit hole to go in order to solve your current problem.
3 Likes