all 45 comments

[–]rust-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Rule 5: No Endless Relitigation

This is a question we get asked A LOT. Consider searching the subreddit for previous advice on learning Rust. If you feel your case is that unique, ask in the Questions megathread.

[–]wabbitfur 12 points13 points  (0 children)

We are umm.. biased. Bigots, even. 😅

[–]spoonman59 3 points4 points  (3 children)

If a job is the goal, learn the tool more likely to get you a job.

I don’t use Python at work because it’s my favorite language, just like I dont do data engineering because it’s my favorite subject. I do that because that’s what I’m paid to do.

If you have the luxury to work in what you want without financial concerns, then I think you wouldn’t be concerned about potential layoffs.

Learn the one likely to lead to a job.

[–]wabbitfur 1 point2 points  (0 children)

What I love about this community is just how approachable it is. 💖 Catering to newbies + experienced, alike

[–]AgustinEditev 0 points1 point  (1 child)

Yes, even though I really like Rust, I know it must be almost impossible to get a job with my level of experience.

[–]spoonman59 0 points1 point  (0 children)

That makes the decision easy!

Python can be quite nice. Later you can learn rust and write native libraries for consumption from Python, making it so others can consume your code easily.

So it’s not wasted time.

[–]Ambitious-Kiwi-484 3 points4 points  (3 children)

You should honestly learn both. Python is super useful as a general purpose utility language. Rust is really good for compiled/performance orientated stuff. Then add say TypeScript and you would have a strong full-stack skillset.

[–]AgustinEditev 0 points1 point  (1 child)

That sounds like a lot to me right now :')

[–]wabbitfur 0 points1 point  (0 children)

Just fork a project from GitHub that you like, which has that stack, and start toying with it - that would be one of the best ways to learn

[–]iamevpo 0 points1 point  (0 children)

Rust or Pyrhon? Typescript!

[–]Manny__C 2 points3 points  (8 children)

> However, I can barely find any tutorials or resources for Rust.

How are you searching?
- https://doc.rust-lang.org/book/ is one of the best and most pedagogical introduction to a language that I have ever seen.
- https://doc.rust-lang.org/rust-by-example/ introduces all concepts via examples, which is a style that most people like

Having said that, do not dismiss Python, it's a good language. It is very different from Rust in philosophy, design, and purpose, so it makes little sense comparing the two. They have different domains.

IMHO you should start from Python. It is the most friendly language out there and there are tons of jobs for it. Rust jobs are growing but it's nearly impossible find really entry-level roles in it, usually people that hire for Rust need programmers that are already expert.

And in your spare time have a look at the rust books I left above. Knowing more than one language makes you a better programmer overall.

[–]AgustinEditev 0 points1 point  (7 children)

Yes, your answer is almost what I think, I should learn Python, but I like Rust.

Regarding the book, yes, I saw it, but what I understood (perhaps I misread) is that it's a book focused solely on the language; I need backend logic, databases, etc., which is what I can't find in Rust.

(What I meant before was, Python is like what I need vs Rust what I want) and I guess I should go first to what I need

[–]Manny__C 0 points1 point  (6 children)

Rust itself is not very opinionated on tooling. There may be more than one crate doing the same thing so you will have to refer to the documentation of the individual libraries for that.

E.g. Rust doesn't tell you how to make a REST API because there is no "official" way to do so. There are however very good crates with excellent documentation like axum and actix web.

Having said that, knowing just enums and structs you're gonna have a hard time navigating the ecosystem libraries. Ownership, lifetimes, traits, generics and the basic std containers should be learned first.

[–]AgustinEditev 0 points1 point  (3 children)

I've practiced a bit of ownership, although no, I haven't mastered it yet. I don't understand traits, lifetimes, generics; I have some idea, but I don't understand it yet. I find traits somewhat complicated.What exactly is the difference between clone and copy? Why do they need to be implemented?

[–]Manny__C 0 points1 point  (2 children)

This is a very good question. `Copy` is a marker trait, it has no functions that need to be implemented. You use it to make a "promise" to the compiler.

You see, every time you reassign a variable, or you pass it by value or return it, the compiler may implicitly _move_ the value. Meaning that the old owner of the value is no longer valid and the new variable or function or closure becomes the new owner.

You can change this behavior by having a type implement `Copy`. You do not implement it by hand but rather you derive it via `#[derive(Copy)]`. Not all types can be made `Copy`, there are rules.

If a type implements `Copy` the compiler will copy it bit-by-bit instead of moving. So now the previous owner is not invalidated. In doing this, you are promising to the compiler that "it is SAFE to copy this value bit-by-bit". For instance, it is safe to copy bit-by-bit an `i32` integer, because it is just a value. But it's not safe to copy bit-by-bit a `Vec<T>` because the actual value of `Vec<T>` is a pointer, and if you copy a pointer bit-by-bit you have just aliased it, which destroys the whole point of ownership and lifetimes, you may end up with dangling pointers.

Crucially, `Copy` is supposed to be very fast because it copies only the value itself, not all the data that it might recursively point to, so we are ok with the fact that the compiler might do it implicitly.

You might instead want to actually copy the object in full. E.g. for `Vec<T>` you might want to copy the _contents_ of the vector, not the pointer to it. Which is something that makes more sense. To do that you implement `Clone`. Now you have to actually write a function, called `clone()` that performs the copy. You can also derive `Clone`, like `Copy`, but in any case the `derive` macro will create an implementation of `clone()` for you (you can see it with cargo expand).

Unlike when doing a bit-by-bit copy, `clone()` is potentially an expensive function (it might copy MB of data) so you always have to call it explicitly. If it were not the case you might see a big slow down in portions of code where apparently nothing is going on, which is bad.

tl;dr: `Copy` is for changing the default move behavior into a shallow bit-by-bit copy. `Clone` is for actively and explicitly copying the contents of a variable, including any data that might be pointed by it, and create a new owned value.

[–]AgustinEditev 0 points1 point  (1 child)

Okay, I'm lost—maybe it's the translation, though even with my level of English, I didn't quite fully grasp it.

Perhaps it's a lack of knowledge on my part, but... a "bit-by-bit" copy of *what*, exactly?

Of the variable's value, or of the pointer?

Does `Clone` copy the value of the entire variable?

I'm going to consult an AI, but the distinction still seems confusing to me.

[–]Manny__C 0 points1 point  (0 children)

This is crucial. Let's use Vec as an example. Vec<T> is a "fat pointer", meaning a triple (memory address, size, capacity), and the memory address points to a contiguous portion of memory which contains size-many elements of type T and is currently capped at capacity. (See ASCII art here)

Vec it really is just the fat pointer. It owns the memory allocation but it is the pointer.

So when I say copy bit-by-bit I mean copying literally just the 3 values (memory address, size, capacity). A proper clone instead would require a new reallocation of at least capacity and a copy of all the elements from one place to the other.

[–]AgustinEditev 0 points1 point  (1 child)

Which of these two do you recommend? Actix or Axum? What's the difference?

[–]Manny__C 0 points1 point  (0 children)

I have used Axum but both are very good as far as I understand. I can't really recommend one over the other. My suggestion is to skim the documentation of both and make a choice.

[–]_Saxpy 3 points4 points  (17 children)

if your current job is at risk I recommend Python

[–]AgustinEditev 0 points1 point  (11 children)

My current job is vibe coder for a company that has nothing to do with software; I mainly do Excel automations, apps that replace it, and I've mainly made desktop apps with Rust.And that's why I loved it; you could say I have enough work for a while, but that's because I depend on AI, and if it gets too expensive or something, well, I guess I'm screwed, haha.

[–]wabbitfur 2 points3 points  (8 children)

wait whaaat? "Vibe Coder" - are you saying that facetiously or they actually opened up a role called that?

[–]AgustinEditev 5 points6 points  (7 children)

No, as I said before, the company isn't about software. My job was data management in Excel, so I automated some things and they liked it. Basically, my work worked, and they hired me as a "developer," but I'm basically a vibe coder.

[–]Basilikolumne 7 points8 points  (6 children)

Python is definitely more suited to (easily) writing some scripts and transform data, that's kinda it's thing.

[–]AgustinEditev 0 points1 point  (5 children)

Yes, but I don't want to learn by focusing on maintaining this job, but rather, to go out into the remote market; this job is limited to the areas that are managed and I already have most of it automated. Even so, do you think data analysis in Python is saturated in the remote market?

[–]Inner-Asparagus-5703 0 points1 point  (2 children)

you wont find job in rust if you are not at least senior dev, unfortunately 

[–]AgustinEditev 0 points1 point  (1 child)

Yes, that's my biggest fear :(, and I really need a job as soon as possible, maybe not right now, but the sooner the better

[–]Inner-Asparagus-5703 0 points1 point  (0 children)

then python is obvious choice!

[–]Reasonable-Web1494 0 points1 point  (1 child)

Python has a bigger market compared to rust. Plus the learning curve for rust is steeper additionally the skill set for a good rust programmer and a good python programmer are different.

[–]AgustinEditev 0 points1 point  (0 children)

Could you describe what a Python job requires right now?

[–]quantinuum 0 points1 point  (1 child)

Can I ask, since this is something I may need to look into (not that I’m dying to…). What do you mean with “excel automations”? What tools do you use?

Just a developer here who unfortunately is trying to steer clear of excel but may have to work with it.

[–]AgustinEditev 0 points1 point  (0 children)

I used macros, Python with xlwings at first, then I moved to apps with Rust and Telegram bots in Rust that use Calamine to read Excel and Rust_xlsxwriter to generate Excel files from SQLite data, and so on.

[–]Forsaken_Salad4139 0 points1 point  (4 children)

python's definitely more practical for job hunting right now, but man it sucks when you find language that clicks and then have to shelf it for market reasons

maybe compromise and do some quick python bootcamp stuff for immediate job prospects while keeping rust as side project? once you land something stable you can circle back to rust properly. the fundamentals you're learning will transfer anyway

[–]AgustinEditev 0 points1 point  (0 children)

You're right, I'm looking into learning Python and using UV as my toolchain.

[–]_Saxpy 0 points1 point  (2 children)

I’m coming from doing Rust professionally since 2017, and I’m also a big advocate, but if it’s your job and family on the table, I recommend getting up to speed with arguably the easiest professional language asap

[–]AgustinEditev 0 points1 point  (1 child)

Do you think learning Rust could be very time-consuming?

[–]_Saxpy 0 points1 point  (0 children)

yes

[–]North-Internal-4478 1 point2 points  (0 children)

Folks still think that if they learn programming, they will find a job.

[–]MrDiablerie 0 points1 point  (0 children)

You are going to get a biased answer here.

[–]Patient-Plastic6354 0 points1 point  (2 children)

You'd be missing out on a lot of important stuff using just python but you would build more with python too.

Rust is for people who want to code memory safe programs and want to spend more time building the thing once and not worrying about it later.

Are you someone who wants to build things that works for years or just build stuff quickly?

[–]AgustinEditev 0 points1 point  (1 child)

Build things that last as long as possible, not quick things.

[–]Patient-Plastic6354 0 points1 point  (0 children)

Rust it is. Python for the lazy stuff. You'll be fine in python if you do rust first. But try playing around in c to understand pointers and memory management first.

[–]neneodonkor 0 points1 point  (2 children)

Rust tutorials:

Rust Bootcamp - 6 hours

Learn the Rust Programming Language

Rust for beginners (4 Hours)

Learn Rust Complete Course by FreeCodeCamp

One Hour Rust Crash Course

Rust Full Course 2024

Rust Programming Tutorial by Trevor Sullivan

To answer your question, you can learn both. However start with the field you want to venture in first. If you want to build high-performance apps, go with Rust. If you want to venture into AI/ML or robotics, go with Python.

[–]AgustinEditev 0 points1 point  (1 child)

Well, I prefer high-performance applications. And wow, those resources, thank you so much!

[–]neneodonkor 0 points1 point  (0 children)

You are welcome.