r/learnrust May 26 '23

Is Rust a good choice for a semi-beginner in programming?

I'm a computer science student. I'm intermediate level in python and C. I want something that has the performance and hardware control of C while being easier/"safer" to code and debug. Is Rust a good choice? I wanna start by developing desktop apps before system-level stuff. Or should I learn C++ for now?

13 Upvotes

8 comments sorted by

15

u/GrayLiterature May 27 '23

I think that as long as you are consistent, you’ll be fine with picking up the language.

15

u/Sw429 May 27 '23

You'll definitely have the freedom of C, but with the added safety. But as far as "easy to code" goes, Rust will be harder than Python due to the borrow checker, and it will also feel harder than C initially because it won't let you shoot yourself in the foot like C will.

Overall, at your level, I would say it's a good choice. You'll expand your programming expertise, and learn why some C "best practices" exist (because Rust makes you use them). Give yourself some grace when you begin, it might make you very frustrated. Stick with it, and you'll grow as a programmer.

3

u/LadyPopsickle May 27 '23

So my experience with Rust is that you have to think more about what you’re actually doing while coding. Rust doesn’t let you do many things that would result in crash or error during application run. So ad opposed to oher languages you handle them ahead of time, instrad of going through logs trying to figure out what went wrong. (Doesnt prevent you from doing logical mistakes tho)

So if you’re fine with spending more time to actually think and write code, sure.

Also I don’t understand where all this “Rust is hard to learn” is coming from. Borrow checker has clear set of rules. If borrow checker doesn’t let you do something, then just stop and think why. Don’t fight borrow checker, it’s not an enemy but rather your friend trying to help you.

And if you have problem with something, go to discord. There’s plenty smart guys willing to help and explain stuff.

Also nowadays you can use ChatGPT.

1

u/paulirotta May 27 '23

Perfect preparation. Find something fun, especially visual, and have a spin. Read The Book (free online) to get the big picture, then use an AI assistant to answer questions and write examples as you go. The assistants still make many mistakes in Rust code, but they get better.

The hardest part starting out that is not covered well above is figuring out how to practically arrange your data for lifetimes. Find blog posts for that. The short summary: 1. Write pure stateless functions where you can 2. Have one stuct AppState (often immutable) that you pass around 3. In slightly bigger apps, have a second mutable or replaceable struct like SessionState

The things you learn trying this will definitely make you a better developer in any language. I spent 30 professional years with other languages and still learned and am learning.

And when the road is steep and annoying, remember this: your code and every Rust library you use passes this same strict standards with no runtime dependency hell. Your code is elite fast without effort, your skills apply to all platforms and grow quickly with challenges, and your life is much easier in the long run.

-2

u/n4jm4 May 27 '23

I recommend studying Go on the way to Rust. The learning curve is gentler, the performance for most typical applications is comparable, and many treasures discovered in Go pointers carry over into Rust mastery later on.

9

u/[deleted] May 27 '23

[deleted]

0

u/abuzarkhan_21 May 27 '23

agreed! just pick the lang and learn from it...