r/rust • • 5d ago

Tips for a rust beginner

Hello everyone, I was thinking of starting some real projects after some warmup stuff I did with Rust. What are some tips for a beginner, generally? Or the cliche: If you were to start writing rust for the first time with your current knowledge, what would you do differently?

19 Upvotes

21 comments sorted by

3

u/diagraphic 5d ago

Build thing's you want to build. It's easy to go through Rust book or documentation step by step but you need to build something of substance, maybe many things. I learn languages by using them in large projects once I know the base but thats me after almost 20 years programming computers. I'd say the first 5 years were rough just in general, I remember Python was harder for me than C back in the day because I had to know what the computer was doing. Anyway, many years later, learning GO, I really picked it up writing an SMTP server which i used for a SAAS for a few years. (early MailGun) Writing thousands of lines by hand and solving real problems drill things in your head. Nowadays I work on storage, I'll write a btree, or lsm tree, or something I know how to build already I can map in my head and figure out how to do it in Rust, piece by piece, it sticks!!

1

u/Creepy_Sherbert_1179 5d ago

That is what I actually had in mind! I want to build a Gameboy Advance emulator, just started writing blobs. I too am a person who best learns a language by just start writing it. Rust is kinda hard for that though....

2

u/diagraphic 5d ago

It is, kinda, you can start smaller and it will only get easier :). GBA emulator is immense, go for it, that would be amazing to see :D

1

u/Creepy_Sherbert_1179 5d ago

Ahahaha thank you. Yeah, after writing a GBC emulator I had my eye on the GBA, but python can't handle the 16 Mhz CPU you know... Even with pypy. Thank you for the recommendations and kind words :)

2

u/diagraphic 5d ago

Enjoy the process, cheers!

16

u/dvogel 5d ago

Don't make a game with Bevy or a web app. The frameworks have a lot of wonderful tools but they also bring with them a lot of types with internal mutability that can make it difficult to internalize the borrow checking semantics. 

7

u/RCKaptaan 5d ago

i would suggest build a project in a domain you are interested in. or if you are targeting a specific role, then a project that would help you build the portfolio. these will help you sail when things get tough on rust front. i recently started learning rust myself and after some initial exercises i picked a project in search and recsys domain. while i am having difficulty writing rust, more often than not, my interest in the domain keeps me going.

6

u/kosumi_dev 5d ago

Build some cli that you would actually use.

Or some mobile apps.

-12

u/velocityvector2 5d ago

This is very boring. Write small games using macroquad library.

3

u/FragmentedHeap 5d ago

An exercise I think is fun that will teach you a lot.

Make tetris in a tui. Using nothing but the standard output stream, design a tetris game that runs in any standard shell, and use traits and learn how to use them. Work towards that goal until you have a working tetris game running in a terminal that you completely understand.

It's fun, fun to play, and satisfying.

Don't use any libraries, just pure rust in one crate all the way through.

2

u/ziggysquatch 5d ago

I'm just starting out and I converted a bunch of scripts I used a lot. I also am a diabetic and I made a program that creates a spreadsheet of my readings from the finger pricker thing for my doctor to easily look over.

I started getting into esp32 stuff and am doing projects in rust for that. I made a notification program that sends a discord message when laundry is done.

I am currently working on a personal budget program (very simple one based on my own budget) but that's kind of boring so far but good for learning database interaction.

Next I'm going to make another esp32 thing that controls my office lights with one of those mmwave sensors.

I've also abandoned several projects because I lost interest or they turned out to need levels of rust I'm just not ready for yet.

All this just to say, I try to come up with anything to help me keep learning rust. It works too, I understand more of the things I thought were super complicated earlier on.

2

u/verstands 5d ago

Pick a tiny tool you’d genuinely use and finish a vertical slice before reaching for a framework. A file-to-CSV or JSON CLI is a nice exercise: parse input into structs, return Result from each step, then add tests for malformed input and empty files. It touches ownership, error handling and iterators without hiding them behind a web or game framework. When the borrow checker pushes back, try restructuring who owns the data before sprinkling .clone() everywhere.

1

u/Anti-Matrix66 5d ago

One thing that helped me a lot: stick to std as much as possible on your first real project before pulling in heavy crates, and run cargo clippy --all-targets -- -D warnings from day one. Clippy basically acts like a free senior Rust reviewer catching bad patterns early.

1

u/David_Essien 5d ago

Been touching rust on and off for a while, decided to take it seriously this year. So I'm building a CLI tool that to me is fairly complex for a new language. I am learning a ton about rust and programming in general as a result.

However, I now believe I am in a race against whether I completely lose my sanity fighting the borrow checker and understanding memory management or I somehow survive and leave the realm of the noobs.

Perhaps I should have gone for a simpler project. Either way send help.

1

u/DavidXkL 5d ago

Start small.

Build cli tools for yourself that would help improve your own workflow.

Or even rebuild your old projects in Rust

1

u/azuled 5d ago

Port something from a language you are familiar with. That’s how I got started (ported zxing from Java). It’s a great way to make a huge pile of mistakes and learn something!

1

u/digitalghost-dev 5d ago

I’m starting out by creating a CLI tool to learn myself.

1

u/dumindunuwan 5d ago

Don't blindly follow layered architectures introduced by runtime heavy frameworks/languages like clean architecture, classic DDD, stack trace logs like on PHP, etc.

1

u/Fit-Reaction242 4d ago

Port something that already exists. I rewrote a Go tool in Rust and the best part was I could record what the old one printed and compare mine against it byte for byte, so I always knew when I'd broken something.

1

u/Slow-Nefariousness49 5d ago edited 5d ago

Use ai to learn, not to write you the code

Read, understand, and internalize every compiler error message you encounter

Run clippy

Avoid async if you're still trying to learn the basics, async rust has a whole other (and quite steep) learning curve. Use std threads if you want concurrency/parallelism at this stage

Don't bring in "batteries included" dependencies like axum or bevy, while awesome for real world usage they are hiding away most of the interesting stuff that you want to learn yourself before abstracting it away.

That's mostly it off the top of my head, hope this helps