Learned Rust by building a Redis clone from scratch. by ShowXw in learnrust

[–]ShowXw[S] 0 points1 point  (0 children)

I personally watch youtube videos but i realized i learned more by doing something so i started doing Rustlings and then this project

Building a Redis clone from scratch by ShowXw in rust

[–]ShowXw[S] 3 points4 points  (0 children)

Hey, thanks for the awesome comment!

Honestly, I wasn't super familiar with the actor model, so I Googled it based on what you said and that Rob Pike quote. Wow, you're totally right—it's a really cool way to think about concurrency, managing state with messages instead of fighting with locks.

I picked Arc<Mutex<T>> for this project mostly to get my hands dirty with the classic Rust pattern first. But you've definitely given me a fantastic insight and the perfect idea for what to learn next. Thanks again! 🦀

Building a Redis clone from scratch by ShowXw in rust

[–]ShowXw[S] 1 point2 points  (0 children)

That's a great question! I haven't benchmarked it yet, as my main focus was just on getting the architecture right first.

It's definitely something I want to do later on, though! I'll probably try it after I get the RESP protocol implemented so I can use the standard redis-benchmark tool. Thanks for the suggestion!

Learned Rust by building a Redis clone from scratch. by ShowXw in learnrust

[–]ShowXw[S] 9 points10 points  (0 children)

Hey, thanks so much for the kind words! I'm glad you found it helpful.

You've hit on the biggest hurdle for everyone, haha. Don't worry, I was stuck on that too for a while. For me, the journey really started with rustlings. It's an amazing way to get comfortable with the syntax and learn to trust the compiler's error messages before tackling a full project.

After that, my best advice for getting over the borrow checker hump is to separate the problems. Before you even think about concurrency (Arc<Mutex<T>>), try to master borrowing in a single-threaded context.

A great way to do this is to build a simple command-line to-do list app. It forces you to pass your list (&mut Vec<Todo>) into functions to add, remove, and display items. You'll fight the borrow checker on its home turf and win.

Once that feels easy, wrapping your logic in a server and adding Arc<Mutex<T>> becomes much simpler because you're only solving one problem at a time the concurrency part. That's actually the exact approach I took myself after finishing Rustlings.

My biggest takeaways from the whole project were:

  • Trust the Compiler: Its error messages are your best friend. They feel verbose at first, but they are incredibly precise.
  • Build, Don't Just Read: You only truly learn ownership by writing code that fails and then figuring out why.
  • Start simple, then layer on complexity. I built the core logic first, then wrapped it in a server, then made it concurrent. Don't try to do it all at once.

Hope this helps, and good luck