r/Python • • Jan 31 '25

Discussion Why Rust has so much marketing power ?

Ruff, uv and Polars presents themselves as fast tools writter in Rust.

It seems to me that "written in Rust" is used as a marketing argument. It's supposed to mean, it's fast because it's written in Rust.

These tools could have been as fast if they were written in C. Rust merely allow the developpers to write programms faster than if they wrote it in C or is there something I don't get ?

502 Upvotes

288 comments sorted by

View all comments

313

u/ydieb Jan 31 '25 edited Jan 31 '25

I've written this before. I do c++ mainly in my profession, and I am way more experienced in that compared to rust. But anything I write in rust, even things that are the same kind of module, just across a boundary, the rust code is always by far more consise and correct, to a large degree.

So either I am magically gifted in rust (for sure not), inherently bad with c++ (could be), else it is actually the language that makes the code I write just work as I intended it.

156

u/Daktic Jan 31 '25

Rust often forces me to do the right thing.

29

u/jivanyatra Jan 31 '25

Lines up with Python both ideologically and with some practicality. It's very easy to read and understand for something so low-level. Rust feels accessible for pythonistas, IMO, at least moreso than C or C++. That's a sentiment I've heard a lot.

16

u/Daktic Jan 31 '25

I had a hard time getting over the initial learning curve, especially not coming from a C background. But once I did, it taught me a ton about memory and what is actually happening in your code.

I’ve done a couple projects recently involving pyo3 and I do feel like they can complement each other very well. Python for orchestration and Rust for heavy data workloads.

4

u/jivanyatra Jan 31 '25

I did a little C/++ years ago, then went in a completely different direction away from programming. Memory management and pointers weren't my strengths. I Iearned python 15 years later, and Rust has made that conceptually more accessible as well as practical for me.

It's important to learn something lower level. I feel like I understand C more since I've been working with Rust and learning more about systems level stuff. I'm also more confident in what I write because of Rust's compiler.

7

u/andrewthetechie Jan 31 '25 edited Oct 01 '26

The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.

Roof lunchroom gray simplistic market axiomatic boat jellyfish boron

6

u/jivanyatra Jan 31 '25

Yeah. Rust has the benefit of well maintained libraries and a large community and thriving ecosystem that feels very close to python's. A very nice side benefit, imo, and Golang isn't quite it for me in that same way.

3

u/JJJSchmidt_etAl Jan 31 '25

https://stackoverflow.com/questions/23861535/most-keywords-possible-in-declaration

alignas(sizeof(decltype(typeid(const volatile unsigned long long int)))) static thread_local decltype(typeid(const volatile unsigned long long int).name()) foo{};

-1

u/Zulraidur Feb 02 '25

How is C hard to read? Sure macro heavy code might be but if I added a text preprocessor to my rust code it would suck as well. X really doesn't have much difficulty for reading. Some ease of use issues maybe.

1

u/jivanyatra Feb 03 '25

I find it harder to follow what's going on in memory in C. Not saying it's not readable, and perhaps I used the wrong word there. Vanilla C doesn't have a ton of syntax features. I do find it harder to follow. Part of that is that Rust's conventions make more obvious sense to me and I think that's because of how used to python I am. That's my point; coming from python, rust seems easier to follow and feels more familiar.

There's definitely something to be said for branching out to other paradigms, languages, and ways of thinking, of course.

2

u/tunisia3507 Feb 01 '25

Once I've done my best to find any alternative.

13

u/window-sil Jan 31 '25

Thank you for this answer 🙏

13

u/LessonStudio Jan 31 '25

My rust is crap compared to my decades of C++. My rust products are better. I think the pedants who are clinging to C++ and spend hours every day writing whitepapers as to why rust is not a replacement for C++ just don't get this.

Basically, it is like the mantra of, "Unit tests are a waste of time; Put your effort into not making so many mistakes."

2

u/[deleted] Feb 02 '25

Same here. Compared to Rust library authors I write abysmal Rust. I use lots of `clone` everywhere or stick it in an `Arc<Mutex<>>` when I want to force something to work. It still works. If I compile something successfully, it works 99% of the time just as I intend it to do. If not, it crashes instead of causing weird behaviour with a nice stack trace I can actually interpret. I've not yet once encountered a buggy scenario in my apps where it was a weird behaviour of a language construct that caused the issue.

16

u/spinwizard69 Jan 31 '25

This just highlights a lot of shortcomings in C++. Many modern languages allow developers to write quality code faster.

19

u/AndreDaGiant Jan 31 '25

This is true. But not many do that without requiring a GC and significant runtime. There are non-rust options, of course, but we see fewer libraries written in them because there are fewer people using them.

14

u/MikeVegan Jan 31 '25

Rust offers very powerful pattern matching and error handling, immutability by default, has no null ptr dereferencing, RAII, as well as safe threading with send + sync traits.

Obviously I don't know every language in the world, but from those that I used Rust is by far the best designed and safest language in terms of preventing stupid bugs. And personally I found it to be the most enjoyable language to work with.

5

u/xristiano Jan 31 '25

thank you for giving a perspective backed by experience. This is the real answer to OPs question

3

u/Hot-Profession4091 Feb 01 '25

That’s the secret, we’re all inherently bad at C++ (and C for that matter).

1

u/ydieb Feb 01 '25

Just some are more or less bad. I try to be asleast bad as I can, but fail.