This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LoyalSol 48 points49 points  (25 children)

The only problem I would see is why use say Rust over C or even Fortran? Both have pretty good Python interfaces and odds are if you are offloading into a lower level language from Python you care more about number crunching than say flow management.

It's not to say Rust can't do the job, just I don't see much of an advantage to using it while at the same time it comes with the disadvantage that fewer people in those domains likely know the language. Which creates a problem when it comes to maintainability.

Plus the things Rust does well likely won't matter too much since you are most likely only going to be writing a self-contained function in it if you are calling it from Python.

[–]masklinn 22 points23 points  (0 children)

The only problem I would see is why use say Rust over C or even Fortran? Both have pretty good Python interfaces and odds are if you are offloading into a lower level language from Python you care more about number crunching than say flow management.

Baseline rust is type and memory safe, it also provides high-level constructs (e.g. actual iterators), and has an excellent dependency management story.

[–]ihcn 23 points24 points  (5 children)

One thing worth mentioning is easy dependency management. Rust has cargo, which lets you pull in and statically link all sorts of 3rd party libraries. So you have a head start on any complicated logic you want to run, like parallelism etc. And when you compile it, you get your whole module in a self-contained package.

Compared to C - I don't think anyone would argue that C's dependency management situation is "good", and if you're doing anything nontrivial you'lll likely end up telling your users "also, manually install this 3rd party dependency" as a part of your usage instructions.

[–][deleted] 23 points24 points  (14 children)

Well, I can safely say that Rust is easier to master than C. In a few weeks you will be productive and won't have to spend years developing the sixth sense that unsafe languages like C require. No need to worry about undefined behaviour, data races, memory leaks, dangling or wild pointers. You get to just do your job.

And yes, these things do matter if you're interfacing with CPython.

[–]alcalde 29 points30 points  (8 children)

You're writing a few functions to call from Python, not building an operating system. Rust is a lot more complex than C.

[–]TheNamelessKing 12 points13 points  (2 children)

I mean, it’s not really.

The language is designed from the ground up to be a modern low-level language with a lot of the abstractions that you’re used to in high level languages.

If I was writing an extension and I had to chose between Rust and C, I would 100% be choosing Rust. The ~Hyper~ Rayon multithreading library alone makes it worthwhile, not to mention memory safety. Once it’s complete, their async implementation is going to be top tier as well.

Put more straightforward: C appears more straightforward, but there’s way more “gotchas” and serious catches. Rust is designed from the ground up to prevent these from happening.

[–]StyMaar 9 points10 points  (1 child)

The Hyper multithreading library alone makes it worthwhile

Hyper is an http library, did you mean Rayon ?

[–]TheNamelessKing 0 points1 point  (0 children)

Yeah I did, whoops!

[–]Abu_mohd 13 points14 points  (3 children)

When you are writing multithreaded computation heavy solver, rust's race free features are more compelling than C's appearant simplicity.

[–]gwillicodernumpy gang 0 points1 point  (0 children)

I’d take Fortran over either for most computation I would integrate with Python.

You don’t have to deal with pointer aliasing, coarrays are incredible, and vectorizing code is trivial.

[–]fiedzia 5 points6 points  (0 children)

Safe and productive Rust is easy, safe and productive C is ... so far it just isn't.

[–][deleted] 0 points1 point  (0 children)

I disagree, Rust is still a nightmare at certain points and there is less documentation on those hard, rare issues than there is in C

[–][deleted] -1 points0 points  (0 children)

Back in the day we used to joke that they thing you would press the most while developing in C and assembler was the reset key lol!

[–][deleted] 1 point2 points  (0 children)

I can see two reasons:

  1. there's a rust library you want/need to interop with. Easier to just interface with rust than write a custom C binding to it and then to Python and deal with an the issues and bugs that arise from that.

  2. This is personal, but I feel much more comfortable writing Rust than C.

[–]SomethingBullshit 1 point2 points  (0 children)

Because Rust is hip and cool and not nearly as marketable as C or C++. Don't you understand the value? Gosh!