Earlier quoted context omitted.
Rust makes hard things easy and easy things hard. Also reading Python code is easier (less syntax noise) on the eyes. The article above is very beginner Rust, and I won't rely on that to look at actual Rust code in the wild. If you want to take a look at what actual Rust code in the wild, take for example, a web server Actix, and try to figure out what the documentation says.
"Rust makes hard things easy and easy things hard." Disagree here. Like article Rust 2018 is very nice and ergonomic. Iterators, Lifetime Elision etc are nice to work. Regarding noise many people consider those noise but I find noises like return types etc very useful. Because I can be sure the return type. Regarding actual code actix doesn't look that bad from examples also. I use warp and its pleasant to work. The…
A half-hour to learn Rust
241–250 of 342 posts
Re: A half-hour to learn Rust
#242Earlier quoted context omitted.
Rust makes hard things easy and easy things hard. Also reading Python code is easier (less syntax noise) on the eyes. The article above is very beginner Rust, and I won't rely on that to look at actual Rust code in the wild. If you want to take a look at what actual Rust code in the wild, take for example, a web server Actix, and try to figure out what the documentation says.
> Rust makes hard things easy and easy things hard. I don't agree with this, and, if anything, this reads very biased. Insofar, Rust has made my life a lot easier, and I have not run into any major issues aside the borrow checker. And this was early on. Two years now playing with the language and I barely run into it anymore.
Majority of people will probably want to use Rust for web? Which makes async needs to be ergonomic enough if it wants consider wide adoption.
Re: A half-hour to learn Rust
#243Earlier quoted context omitted.
Rust makes hard things easy and easy things hard. Also reading Python code is easier (less syntax noise) on the eyes. The article above is very beginner Rust, and I won't rely on that to look at actual Rust code in the wild. If you want to take a look at what actual Rust code in the wild, take for example, a web server Actix, and try to figure out what the documentation says.
"Rust makes hard things easy and easy things hard." Disagree here. Like article Rust 2018 is very nice and ergonomic. Iterators, Lifetime Elision etc are nice to work. Regarding noise many people consider those noise but I find noises like return types etc very useful. Because I can be sure the return type. Regarding actual code actix doesn't look that bad from examples also. I use warp and its pleasant to work. The…
let re = Regex::new("(?P[0-9]+)-(?P[0-9]+) (?P[a-z]): (?P[a-z]*)").unwrap();
re.captures_iter(&contents).map(|caps|
Input {
password: caps.name("password").unwrap().as_str().to_string(),
letter: caps.name("letter").unwrap().as_str().chars().next().unwrap(),
min: caps.name("min").unwrap().as_str().parse().unwrap(),
max: caps.name("max").unwrap().as_str().parse().unwrap()
}
).collect()Re: A half-hour to learn Rust
#244Earlier quoted context omitted.
Pretty sure if you’re deserializing a structure with borrowed references you need lifetime annotations. Copying things around to pacify the compiler hardly seems elegant.
Sure, but that's a performance vs ease of use decision. Often you don't need to care about the extra allocations and can just deserialize to owned types. The code for owned deserialization certainly ends up looking more elegant.
Re: A half-hour to learn Rust
#245As a Python programmer with limited experience with compiled languages, Rust code was more intimidating to read or look at than C++, Java or Go. After only an hour, I am overwhelmed by the sheer beauty and mature design of this language - it almost reads like Python or as well as any compiled language can. I cannot believe that I am smitten by Rust within an hour. Its features seem, obvious. My experience with Go was…
Re: A half-hour to learn Rust
#246 fn make_tester(answer: &str) -> impl Fn(&str) -> bool + '_ {
move |challenge| {
challenge == answer
}
}
why is there `move` needed, if both `answer`, and the arg of `Fn`, seem to be references (`&str`)? To a layman, this sounds like as if both "challenge" and "answer" should be borrowed - so why "move"? what's even to move here?Re: A half-hour to learn Rust
#247Earlier quoted context omitted.
Most languages just clone all day long, it's not that bad, rust clones (like most languages) are just to the first reference counted pointer after all.
Well, yes and no. Eg cloning a string leads to an extra allocation and a memcopy. If you want to get a similar performance profile to GC languages, you have to stick your types behind a `Rc >/Arc ` or `Rc > / Arc >` if you need mutability. But modern allocators hold up pretty well to a GC, which amortizes the allocations. The extra memcopying can be less detrimental than one might think.
Re: A half-hour to learn Rust
#248Earlier quoted context omitted.
My only bone to pick with this commentary is that it is 2020 and people are still complaining about Python as being unstable because of 2 -> 3. It was a rough transition, to be sure. Python2 was released 20 years ago, and Python3 12 years ago. It is a pretty stable language.
My housemate was just rolling back from python 3.8 to 3.7 yesterday due to a backwards incompatible change breaking a library... it's not just 2 -> 3 that makes python relatively unstable compared to rust.
Re: A half-hour to learn Rust
#249Earlier quoted context omitted.
To be clear, JS doesn’t require cloning because it has a gc. Not sure what you’re getting at with reusing variables names...
What I mean is, if one does: const obj1 = { a: 32, b: 42 }; function foo(ref) { ref.a = 0; } foo(obj1); console.log(obj1); in JavaScript, one is just using the variable name as a "holder" of some value. One doesn't have to designate that that variable is being passed by reference. If one wanted to actually copy that object, they'd have to devise a mechanism to do so. In Rust, if someone doesn't specify, using the & s…
Re: A half-hour to learn Rust
#250https://gist.github.com/ityonemo/769532c2017ed9143f3571e5ac1...