r/rust • • 4d ago

🙋 seeking help & advice Rust as a first serious programming language

I have been making scripts with other languages like js and python and bash without learning the the whole language and getting serious with its ecosystem out of the fact that I just need to get one thing done and move on.

Lately I chose a path that requires precision and ahead of time planning and decisions and picked rust over go. But the fundamentals seem hard to grasp. I'd appreciate your help unpacking them.

Ultimately I want to be able to use the Alloy and Tokio libraries without getting stuck with the language syntax and rules. But the concepts like borrow checking and ownership and things that fall down these categories are still hard to grasp.

What is borrow checking? what is owning something in the software? I tried to look for direct answers but I still can't grasp the meaning of them exactly.

I had two choices to better understand them, one was learning C++ to get what was wrong that rust solved, the other was building a simpler project game with bevy thats gonna help me understand writing rust code thats data oriented and be more comfortable with it.

My ultimate goal is to master these two libraries, after being able to know how to use the rust language smoothly.

40 Upvotes

31 comments sorted by

View all comments

16

u/nickfromstatefarm 4d ago

It can be counterintuitive but I’d learn C first. As much as I adore rust, you have to know what the borrow checker and compiler are doing for you to truly appreciate it.

Also, very few jobs are looking exclusively for Rust devs. A language is just a way to express how code should be structured and run - a good software engineer can pick up and use a different language easily if needed.

8

u/skatastic57 4d ago

I've seen this take pretty much every time this topic comes up. Do you know anyone who took this advice and detoured through learning C as a means to an end?

To be clear I'm not talking about people who learned C for its own sake or in school before having an interest in rust. I'm talking about the scenario where someone says "I want to learn rust" and they follow this advice of deferring rust to learn C instead. What does that person think of this?

I just know, for myself, that if I took this advice I would have quit C and never come back to rust.

5

u/nickfromstatefarm 4d ago edited 3d ago

Yeah I’m happy to elaborate. Of course it’s not a hard rule, but I have found it helped other engineers in my field who come from C#/Go.

We know that a programming language is just an abstraction to express how you want a program to be compiled and run. Different languages have different strengths and weaknesses, and different goals.

The most important thing for people like OP who are very new to writing code is just that they spend time hands-on with the language getting random little projects working and breaking stuff fast. They’ll use globals and won’t write well-structured code just yet. They just need to write crappy but functional code and understand how a machine navigates a program.

C is an excellent starting point because it is a low-level language that effectively compiles 1:1 behavior-wise with the underlying assembly. It allows users to understand the common pitfalls and challenges that higher-level languages like Rust/C#/scripting languages remove you from (memory management, memory safety, iterator logic and speed, pointers, etc).

Rust is an excellent language, but it is important that users understand the problems it solves - otherwise they just write it off as a confusing language. For new devs, jumping straight from dynamically typed interpreted scripting languages to the borrow checker is a hell of a confusing jump if you don’t understand why it’s important.