5 ms·
You can write very simple Rust, it's worth trying it out if you haven't already. I'm not a rust developer, but I've ported over a handful of python or golang p
by EwanToo 6y ago
You can write very simple Rust, it's worth trying it out if you haven't already.
I'm not a rust developer, but I've ported over a handful of python or golang projects to see how it works. I managed to write the code without understanding much about things like the borrow checker.
I'm certain my code is not as performant or elegant as it could be using some of the more complex tools and concepts in the language, but it is possible.
- adrianN 6y ago"You can write <adjective> <programming language>" is an answer that usually get rebutted by pointing out that a) you need to read a lot more code than you write and b) other people might not write <adjective> code or c) other people might have a different definition of <adjective>.
- genuine_smiles 6y agoThis is true. It’s also true that team using languages with more feature then they need can just take the parts that they need. It’s not quite as ideal as having a language that’s perfectly suited to your use cases, but it works well enough. For example, I’ve been writing JavaScript for 3+ years. I have yet to use the prototype chain directly, only through the use of the `class` keyword, and I’ve only reviewed code using it once. I hear C++ is similar in that teams use a slice of the available language features.
- pansa2 6y ago> I'm certain my code is not as performant If you don’t need maximum-possible performance, though, why use Rust/C/C++ at all? Wouldn’t a better choice be Go/Java/C#?
- GrayShade 6y agoBecause even slow Rust code might have better performance or memory usage characteristics than idiomatic code in these languages. Or because it still protects you from race conditions. Or because you like cargo more than, say, maven. Or because you want to learn the language.
- hu3 6y agoI was recently surprised that idiomatic Go can be faster than idiomatic Rust: https://news.ycombinator.com/item?id=26463967 https://news.ycombinator.com/item?id=26463967
- GrayShade 6y agoI haven't read that article yet, but I wouldn't really call the simple Rust version idiomatic. Stdin::lines() incurs a string allocation for each line (fixing this takes three lines of source code), which can be quite significant. And garbage-collected languages will have faster allocation, so I'm not too surprised. Of course, I know who the author of that code is. I just wanted to point out that it's not such a trivial comparison to make.
- littlestymaar 6y agoRe-usability is a important feature: if you write a Rust library you can reuse it from most runtime-based language with “native modules” (or whatever they are called in the said language), exactly like a C library.
- edflsafoiewq 6y agoJava and C# typically require a VM, and not everyone thinks Go is "easier to write" than Rust.
- pjmlp 6y agoThey can also be compiled to native code and as such it is a plain language runtime, just like Go.
- afavour 6y agoIt’s all a matter of opinion but I actually find Rust a wonderful language to write in, given the right circumstances. Which usually means “without having to deal with lifetimes”. I tried Go, I wanted generics and errors. I like C#, but not the ecosystem that comes along with it. And so on. So for me personally, Rust is a a valid choice even when performance isn’t a first concern.
- IshKebab 6y ago> You can write very simple Rust Technically true, but only really true if you don't use many dependencies. At some point you're going to use some dependency that uses async/await all over the place or really goes wild with generics and then it is definitely not simple. Two examples: * Heim (https://docs.rs/heim/0.0.11/heim/ https://docs.rs/heim/0.0.11/heim/) is a great crate for getting system info, but it only uses async/await so you are thrown into that rather painful world even if you don't need it. * Plotters (https://github.com/38/plotters https://github.com/38/plotters) is a pretty great graph plotting library for Rust (the only one as far as I know), but they have definitely gone a bit overboard with the generics. Want to draw a scatter graph? I tried simply calling `PointSeries::new()` and got a basically impossible-to-follow error about Rust not being able to infer the type `E` here: https://github.com/38/plotters/blob/master/src/series/point_series.rs#L24 https://github.com/38/plotters/blob/master/src/series/point_... Very simple it is not!
- moltonel3x 6y agoasync/await doesn't have to be painful: Slap a `#[tokio::main]` in front of your `main()` and a `.await` after your heim functions. Done.
- IshKebab 6y agoIn the most perfect of perfect situations that's all you need. In reality it isn't nearly as simple as that. There's been a lot of discussion about the pitfalls of async Rust recently, highlighting the issues. Here's a good one: https://tomaka.medium.com/a-look-back-at-asynchronous-rust-d54d63934a1c https://tomaka.medium.com/a-look-back-at-asynchronous-rust-d...
- Measter 6y agoWell now I'm (morbidly?) curious what your Rust code looks like.