I'm Learning Rust and I Need Advice

I only started working on it seriously recently. I never thought there would be so much fun.
Some advice:

  1. Start work on a real project ASAP.
  2. Use IDE tools. I use VSCode + RustAnalyzer. It generates "inlay hints" in your editor.

Rust-analyzer provides several specific flavors of these hints:

  • Type Hints: Shown next to variables (e.g., let x/*: i32*/ = 5;).
  • Parameter Hints: Shown in function calls to identify which argument is which (e.g., foo(/*name:*/ "Gemini")).
  • Chaining Hints: Shown at the end of method chains to show the resulting type of each step.
  • Closing Brace Hints: Shown at the end of long blocks to tell you which function or loop is ending.

The "inlay hints" are especially helpful during the first few days. Can't imagine life without it.

Also, ask AI for type tricks. I never had needs to ask those questions on this forum at all.

I wish I hadn't spent 3-4 years basically just solving and micro-optimizing data structures and algorithm related problems in rust on various sites :'D But to honest, the insane amount of practice did help out with developing a sort of a 'practical' mental model about rust semantics that someone like me (I have pretty severe ADHD) would be able to develop by just learning theory. So, the optimal learning approach depends on yourself too. I started working on some personal projects just last year and I wish I had a more project oriented learning approach and was active in the forums all these years. I probably would have become sort of an expert on some very niche topics in these wasted years :'D

Being active in the forums and reading replies from the many experienced and long term users has been one of the most impactful changes I have made in my learning process. But to be honest some of the discussions here often too advanced for someone new to the language. Sometimes I wish there was a separate category for these topics O.O, but that's a pretty minor nitpick.

5 Likes

What you're describing is completely normal and expected. The exact experience you'll get very much depends on your background, but the overall picture is the same with any new language or technology.

I started using Rust before 1.0, with a few years of experience with C and C++ and a little bit of this and that — Lisp, Standard ML, Haskell, Pascal, Java, etc. Rust was much harder to use back then, but I was very intrigued by its design philosophy, and pushed through anyway. Now I don't want to use anything else. Even though It was hard at first to adapt to it's strictness, it taught me invaluable lessons and made me rethink my approach to programming.

Recently, I've been interested in physics simulations, struggling with getting good performance and realising that there is no way I can simulate millions of particles on CPU. That forced me to learn how GPUs work, learn compute and render shaders, which I've been putting off for years. I had to deal with paradigm shift again, struggling to switch from thinking in terms of sequential operation to parallel algorithms. But it wasn't nearly as hard as I had imagined. I just had to be consistent, just like with pre-1.0 Rust.

Something eventually clicks in your mind, and you start to get it. It's only hard in the beginning. Rust still has a relatively steep learning curve, but it pays off big time — especially when you compare it to C++, which gives you a sense of great power, only for you to realise years later that you're been dancing around its seemingly endless quirks and limitations way too much for the benefits you got out of it. Rust is a very strict but very wise teacher.

By the way, even though lifetimes might be hard to grasp at first, you'll still need to understand the concept if you're serious about programming, regardless of the language you use. In practice, you don't need to use references that often anyway after you grasp Rust's ownership model and move semantics, and rarely need to deal with more than one explicit lifetime. References are pervasive in garbage-collected languages because nearly everything lives on the heap, but not nearly to the same degree in Rust.

Keep learning, struggling and making mistakes. You don't get good at programming by only reading literature and thinking. Don't think you're not smart enough because you didn't get a concept immediately, you just need more practice. When you look at great guitar player, you're tempted to think that they're just very talented, but what actually made them great is consistent practice for years.

I had the same experience as you. What helped me a lot is the tutorial by Philip Pflenker (hecto: Build Your Own Text Editor in Rust). With his help you walk through most concepts step by step. Way better than reading the book twice :grinning_face:

1 Like

Make sure to read some Rust code. This is a good way to learn idioms. The standard library is very readable, and Rustdoc has helpful links to the source just about everywhere. There are other good crates to read; it really depends on your interests.

The real challenge in my experience with Rust isn't the language. It is the libraries; to be a competent developer you need to know a lot of libraries and ecosystems beyond std.

1 Like

I finished the Rust Book about six or seven months ago, and I very much worried about what I'd do after. Here's my advice:

  • If there's a project mentioned in the Book that you didn't do, try it out! If you enjoy making it, really get stuck in: create docs, a README, a nice repo.
  • I briefly self-debated about reading it again, but I realised I didn't need to; if I forgot something, I could quickly go back to that chapter in the Book and simply soak up the forgotten information.
  • Use AI with caution: although a powerful tool, it's horrendously prone to hallucination. Don't ask AI for project ideas: it's far more rewarding to think of and develop projects yourself.
  • Create, create, create! As @jofas said, making things is, in my opinion, the best way to learn: it requires you to really think about ways to circumvent an obstacle. Also, when you've made something, improve it as much as you can. That's one of my favourite parts of making a project.
  • If it becomes dull or forced, take a break. Learning is because it's fun, not because it's forced.
  • Get familiar with standard library docs: they're one of your most powerful assets.
  • Please don't be afraid to ask! there are very helpful people on this forum and many others. I've asked quite a few of what I'd call stupid questions (or rather, questions that make me look stupid) and no-one's pointed it out to me (yet :slight_smile: ).

That's pretty much my advice for learning Rust. I hope it helps, and if you need anything, just ask.

You wake up my Turbo time!
Mostly Pascal, C, C++.

And make me remember meeting Kahn (Milano, north Italy, where I live)

1 Like

Yes,
but as beginner you also can't tell if someone on this forum does not hallucinate, or anywhere on web. Anyone can hallucinate, not only AI and for everything.
But programming is good, because you have compiler to confirm if this is hallucination or real thing :smiley:
So, compiler can fix programming hallucinations, you as programmer needs to fix logical hallucinations.

Yesterday I have asked AI to generate traits for tens of enums using one implementation as example. I have done manually. It generated good trait impl for all enums on diffirent file, but failed to copy them to right file. For some reason mist two } at the end of each impl block. After this is become crazy. It saw it made probem with } but could not find solution how to fix it. I just for fun was letting it try and try again. AI created multiple python codes to fix problem. After 10 min, it give up :smiley:
So, I have reverted all failed tries and fixed } manually. Had to add } two at the end of each impl block. VS Code help to show missing }
So, it was easy to fix.

Learn through hands-on projects. When you hit roadblocks, revisit the relevant book for clarification, or turn to a new one for fresh insights. AI assistance is a good idea too.

I also faced the same issue. No matter how many books you read or how many tutorials you go through, until and unless you test the water yourself, ideas will be vague.

To overcome this issue, I built a Neural Network program from scratch. No libraries involved.

Just maths and rust.

While working on this project, I had to go through many documentation and actually write incorporate them in my code. I not only built the neural network, I built few accessories too like a terminal plotter.

This project truly helped me solidify my understanding of Rust.

After it was done, I wrote a guide on it too for others to follow.

That was the moment which accumulated my knowledge of both the unknown fields.

If you are interested, you can follow it here: https://ai.palashkantikundu.in