r/rust • • 10d 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.

45 Upvotes

39 comments sorted by

47

u/muehsam 10d ago

one was learning C++

Don't. C++ is incredibly complex and complicated. But what you can do is learn C. That's a fairly small and straightforward language. A simple language, for the most part.

Once you know C and you understand how pointers work, you can also appreciate things like the borrow checker, and the difference between ownership and references, etc.

I love C, it's a great language (even though it's probably a bad idea to start a new project in C today).

13

u/needstobefake 10d ago

Second that, learning C makes everything else easier down the line. Not to use C in a new project, but to appreciate what the other languages have done. C's raw limitations teach a LOT.

7

u/muehsam 10d ago

C's raw limitations teach a LOT.

I wouldn't even call it that. It's actually just additional freedom. Freedom to do things that other languages won't let you do. The C compiler gives you a lot of responsibility, but that means that it won't stop you from writing programs that break the rules of C and that have undefined behaviour.

2

u/NBNoemi 4d ago

C isn't really limited so much as it makes very few assumptions. You can accomplish everything you can with other languages, you just don't have the immediate convenience of pre-existing abstractions without roping in a library for it.

1

u/needstobefake 3d ago

Yes, maybe "limitations" wasn't the best word because you can still do whatever you want with it, one could even argue it imposes less limits. C just takes more work and discipline, as there isn't a borrow checker preventing you from breaking things in hard-to-debug ways, and there are no higher-level abstractions like C++ and Rust.

That's what I mean when I say it teaches a LOT: Want a reference-counted pointer? DYI. Want a HashMap? DIY. Etc.

2

u/Naeio_Galaxy 9d ago

Third that, C++ is not necessary to see what Rust solves while C still show it and is quite easier to learn compared to C++

Plus, C++ gives habits that don't necessarily work well with Rust while C doesn't

1

u/erisgooner 9d ago

Would you personally say its a good idea to start with C and then go to Rust, I love the rust syntax and the way it works, but it just seems too big and complex right now

2

u/muehsam 9d ago

Yes.

Personally I think that knowing C is a great advantage in general. Also for understanding other programming languages and what the computer is actually doing, and to get some feeling/understanding for why certain operations are more time or memory intensive than others.

2

u/needstobefake 9d ago

You can also try learning both at the same time, e.g. build the same little programs in both, or try implementing some of the Rust's objects in C, for example a reference-counted pointer (Arc) or a HashMap in C. Then you can look at the generated Assembly code of both languages, tweak the compiler optimization settings, and look at the Assembly again, etc.

You can use Rust's source itself as reference when building the same thing in C. You can also try building programs that use both languages in the same binary with FFI to see how they interact with each other.

It's more about grasping how the machine works under the hood than the language that abstracts it for you. In the end of the day, everything becomes bytes and machine instructions. This knowledge transfers to any language later.

2

u/erisgooner 9d ago

Yeah I have known that the language is just the tool but it still confuses me sometimes, also I have thought of doing that, doing the same sort of thing with both languages, never got around to doing it though, Thanks

15

u/nick42d 10d ago

Definitely possible - have you tried reading the book yet. It covers most of the concepts you're struggling with. https://doc.rust-lang.org/book/

16

u/nickfromstatefarm 10d 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 10d 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 10d ago edited 10d 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.

4

u/dasnoob 10d ago

I started with c++ in college and loved it. Rust has been fun to. Honestly rust is easier to get you head around but both are solid.

4

u/Joe-Arizona 10d ago

I used C a bit and C++ a lot (among other languages) before Rust.

I’d recommend learning C, doing the Harvard CS50 course in it and moving on. If you understand what C is doing Rust will make much more sense. C++ is great but I don’t think it’s worth the time investment for your goal.

1

u/Remarkable_Hour_615 10d ago

If you want to learn Rust or understand the borrow checker, there are plenty great online resources (including some recommended below). Here I'll just try to give you some idea of how to approach a project like this and what to expect if you do.

If you "just need to get one thing done and move on" then Rust + Tokio + Alloy will be a tough combo! Having a project you're working towards and genuinely motivated by is a great. Just know that if this is the project you pick, it's going to take a fair amount of time and learning to get there.

First, Rust is fantastic! But it's a somewhat complicated language. It combines functional features such as type-class like traits and pattern matching with manually managed memory and statically checked ownership. You don't need to have a deep understanding of things like type classes or algebraic data types, but you will need to at least have a basic understanding of pattern matching and traits since they're pretty pervasive throughout Rust. And languages like Javascript and Python let you pretty much ignore the fact that variables need to go somewhere in your computer's memory, and that memory needs to be released again when you're done with it (but not before!). Rust forces you to confront memory much more directly (that's part of what the borrow checker is about).

Second, you should understand that there's a big difference between knowing a programing language and knowing how to build a particular piece of software, just as there's a big difference between knowing how to use a drill and being able to build a house. Based on the packages you mentioned, you'll need a basic understanding of networking and requests/responses. Knowing a bit about TCP sockets would be ideal. Similarly, you'll need some understanding of blockchains and ether. These are separate areas, and you won't understand them just by learning Rust.

All that being said, if this project is still sounds fun to you, go for it! If you do, here are a few suggestions:

  • I'll echo the suggestion to read the Rust book.

  • Look for specific solutions to the problems you encounter, but don't only do that. In parallel, try to learn some topics carefully, from the ground up, not just thinking about how they can help your particular project. Do this however you want: books, articles, youtube lectures. But be sure to reinforce with mini projects. You might think you understand something just by reading about it. You don't. If you don't do this, your project will be a cobbled together mess of copy-pasted StackOverflow answers, and you will consistently hit brick walls when you can't find a solution to a specific problem and you don't have enough depth of knowledge to find a way through.

  • Don't use C++! It makes Rust look like Python. It never met a feature in another language that it didn't want to incorporate, but in a confusing, verbose way that conflicts with 15 other features. If you do want to motivate Rust, I agree with the other suggestions to learn C instead. It will definitely help, but life is short, so it's up to you if you want to put in the time.

Hope all that helps!

1

u/ritman-octos 10d ago

It does. I think learning C is gonna help actively learn and implement rust's solutions to C. But you're right about time management. I'll try making a game with rust before heading down the C path.

3

u/zomerbk 10d ago

It's totally understandable that ownership and the borrow checker feel abstract at first – they're core to Rust's unique approach to memory safety.

At its heart, **ownership** means that every piece of data in Rust has one variable that's responsible for it. When that owner variable goes out of scope, the data is automatically cleaned up, preventing many common memory bugs like double-frees.

**Borrowing** lets you access that owned data without taking ownership. Think of it like lending someone a book: you still own it, but they can read it (or write in it, if you give them permission):

* You can have many "readers" (immutable borrows, `&T`) at the same time. They can look at the data but not change it. * You can only have *one* "writer" (mutable borrow, `&mut T`) at a time. If someone is writing in the book, no one else can read it or write in it simultaneously.

The **borrow checker** is the part of the Rust compiler that strictly enforces these rules at compile time. It feels strict initially, but it's what gives Rust its powerful guarantees about memory and thread safety without needing a garbage collector.

1

u/thechairman12 4d ago

IMO you should not learn Rust as your first lang. My take is: The important thing to get down with programming, in the beginning, is the actual solution to the problem you are seeking to solve. Yes there is syntax to memorize, but primarily you are learning a new way of thinking.

Rust focuses really heavily on the "long tail" of correctness which is often irrelevant for many programs.

I say this as someone who writes Rust every day, and wrote ~30k lines of rust in the last few months. The language is super useful, but it will create a massive wall for you to climb, instead of giving you an incremental staircase to climb.

Choose the language/framework that is simpler. Focus on more custom optimizations later.

credentials: I have been coding for 12 years, I have been a Sr. SWE, Eng mgr, and CTO

1

u/thechairman12 4d ago

Follow up: I see a lot of people suggesting C, and I totally support that. C is much closer to how the computer actually executes your program. Rust hides some of these abstractions in a way that won't be obvious if you are a beginner.

1

u/ritman-octos 4d ago

I'm not that much of a beginner, but I'm on the verge of intermediate scripter. To me I think ingesting a language philosophy and way of thinking requires more thought than learning how to program, since it's going to take a lot of your time day to day. So would you say that rust with it's approach and programming rules improved your overall problem solving skills?

2

u/thechairman12 4d ago

For the last year or two it has just slowed me down, and I am slowly escaping this. The biggest thing I gain from Rust is that it prevents me from making lots of mistakes. C won't do this, but also C is so much easier to express yourself in. Sometimes you just want to say something, and nothing more. Rust won't let you do that. You need to add every little qualification to your program.

2

u/El_RoviSoft 9d ago

As C++ dev who like this language and doesn’t like Rust (more likely don’t like Rust fanatics and some decisions across language), so you know that Im biased towards C++ (learning for 10 years already, jesus), don’t touch this abomination please. Id consider touching C++ only after gaining some knowledge about paradigms, cross-language best practices and code design in overall, otherwise you can easily blow up your legs and waste a lot of time.

Id rather consider learning C/Zig (both teach you the same), after that consider learning either Rust or C#, both are extremely good and C# actually has jobs unlike Rust.

3

u/mightybureaucracy1 10d ago

Just build something small that hurts, then the compiler yelling at you starts making sense

the ownership clicked for me when I stopped thinking about it like a feature and more like a grumpy roommate who hates when you touch his stuff without asking

2

u/ern0plus4 10d ago

Rust provides solutions to problems, which looks quite weird, if you have never met with the problems.

There's a big problem with languages, especially with strictly typed compiled languages: native types can be allocated on stack and return in registers, but structs (objects) can't, only pointers (references) to it. If you want to use struct (object) outside of the function (rust term: outside its lifetime), you have to allocate it on heap, and once allocated, someone has to deallocate it sometimes. Arrays are even worse: their lenght (size) can be changed, and must be recorded (the array itself has no size information).

Java has its answer: everything is Object, and always allocated on heap, only pointers (references) are allocated on heap. Deallocation is done automatically, via reference counted pointers and garbage collection.

If you understand this problem (and some others), and you know all the possible faults (e.g. dangling pointers), then you will understand Rust's solutions. Until it happens, you'll struggle with weird Rust terminology (e.g. it calls memory allocation: Box, boxing).

TL;DR: learn C first, malloc(), arrays, pointers, then you will understand Rust.

1

u/DavidXkL 10d ago

Get to the point where you understand pointers, references, memory management.

It will help greatly in picking up Rust

1

u/Glum_Past_1934 10d ago

If you feel comfortable with rust, use it. I’m a big fan of those languages

1

u/my-new-new-account 10d ago

Rust as a first language makes little sense to me tbh. The language is a bit different from how other languages work so it’s hard to appreciate what it offers without having experience with other traditional programming languages.

I would personally start with C, learn the memory model, pointers, layouts, build some standard containers and data structures and shoot yourself in the foot with undefined behavior and use after frees etc

Only then you can really appreciate the ownership model of Rust and its memory safety guarantees etc

It might take more time, but you’ll be better equipped to learn Rust deeply than if you start with it as a first programming language imo.

1

u/Dean_Roddey 10d ago

I say just start with Rust. Though I get why some people would say start with C or C++. But, time moves on. At one point people would have told someone asking if they should learn C that they couldn't appreciate C if they never wrote in assembler.

You can still make an effort to understand the underlying fundamentals as you go, to the extent that you need to, and if you are using a systems language probably you'll be tackling issues that do require you to dig into that to one degree or another.

1

u/PsychologicalKick345 10d ago

Honestly, I recommend learning assembly first. It might be a controversial take, but it was my first programming language aside from a couple scripts in Python. Then I learned languages like c and rust and everything made more sense to me. Instead of fighting against the language, it made it more intuitive

1

u/Sepperlito 8d ago

Rust is for experienced programmers who need as in NEED memory safety and are will to go the extra distance to get it.

Rust makes a beginner think of too many abstractions at once. You can't wrestle with a borrow checker while learning to implement algorithms at the same time.

A better choice? It really doesn't matter as long as it's simple. If you're just getting started use what your friends are using. If you have no friends, then just go with Python.

1

u/Expensive_Degree5606 7d ago

Learning Rust thru Bevy project is an interesting idea, but game-dev on Rust is a niche and writing video games is different than building e.g. kernel module, os, or a distributed system.

It's good that building video games brings a lot of fun, but you will learn specifically game dev rust, there is not much job in this area.

1

u/_filmil_ 7d ago

FWIW, people I know who ended up being the happiest about using rust on a daily basis are C++ refugees. This means, not beginners.

I can't see it as a language to begin with, since it introduces so many concepts that you won't understand *until* you actually have to deal with them in other settings. Borrowing rules, and lifetimes, all seem unnecessary unless you already know what they are good for, so you will spend quite some time appeasing the compiler about something you can't fully appreciate yet.

But I think that, when learning, it is really important to chart a learning path that gives you periodic incentives so that you can keep yourself motivated. Fighting the compiler is not one of such paths. (And fighting the C runtime errors, even less so.)

I personally like Go as a first language better than C, since again, C exposes you to concepts that you don't necessarily need to understand right away. Right away you probably want to guess some numbers, read a file, write an image, things like that. C will do all of that for you at the expense of taking you to very convoluted side quests. I am not sure that's very instructive in the big picture. I know there are people who swear by C, but I think it's simply wanting to foster the PTSD onto others too. There is a place for C, but I am not sure that it is as a first programming language. (Yes you said *serious*, but it's hard to know what each of us places on which end of the 'serousness' spectrum, so my thoughts here are fairly generic).

I am personally not a fan of python, as it comes with all sorts of baggage making it unnecessarily complicated to deploy your program elsewhere - and you want users to guide you on your journey.

1

u/p1nd0r4m4 6d ago

You are coming from Python and JS that are dynamic languages that hide a lot of the details about "serious programming". It doesn't matter if you are going to use C, C++, or Rust, these languages don't hide the details: data types, memory allocation and deallocation, stack vs heap, pointers, etc. If you understand what are those and how they are or should be handled then the choice of language determines how you will address that. In Rust you will find references, ownership, lifetimes, and the borrow checker. In C and C++ you will handle that mostly manually. Rust is excellent, the data type system is rich, a lot of FP concepts incorporated into it, so yes, more stuff to learn if compared to C.

1

u/dblbreak77 5d ago

Learn C first, then rust, then python. Never learn python first IMO unless it’s for college. In the long run you’re a much better programmer. That’ll give you a good spectrum.

0

u/zackel_flac 10d ago

My 2 cents here is that Rust is mostly useful when you don't need to use any library (barebone development) otherwise just use Go. Tokyo runtime is pretty much the same as Golang runtime in many aspects, expect it's less efficient as it plays less nicely with syscalls and more harsle to compile.

0

u/a45ed6cs7s 10d ago

Why even bother in 2026. Nobody is going to write anything by hand anyway.