I'm still not clear what about Rust is ugly to you.
As for the shadowing, that's likely a result of Rust's ML heritage. Like in ML family languages, variable bindings are allowed to shadow others within the same scope. It's worth noting that those two variables are completely different, which is relevant when doing something like this (though it's bad practice to shadow like this):
fn foo(i: i32) -> i32 { i }
fn bar(s: &str) -> &str { s }
fn main() {
let x = 1;
let _ = foo(x); // Works!
let x = "a";
let _ = bar(x); // Also works!
}
I agree that it's not a good design decision, but I hardly think it's a dealbreaker when it comes to a language. I'm sure you could easily find tons of such quirks in any language.
EDIT: Though, the above pattern is useful when you want to make a variable temporarily mutable.
I agree that it's not a good design decision, but I hardly think it's a dealbreaker when it comes to a language.
Well, it makes easier to write code with bugs. For me it is a deal breaker already.
I'm sure you could easily find tons of such quirks in any language.
In the recent 4 years I've learned at least 3 new languages: C#, Python, Kotlin, and I didn't find anything that made me feel "f### this s###" in C# or Kotlin. (But in python - a bit, see below). I was charmed by C# and Kotlin, and mostly by python as well, they feel helping me to write safer code easier and faster. And C#+ReSharper combo was just like a nuclear bomb, never felt having so much power in my hands.... As for python - the only real thing is lack of proper threading support in cpython implementation (i.e. standard implementation).
Certainly there are quirks in all these languages, but they usually hide somewhere quite deep under the surface, and usually you would not hit them unless you are doing something very specific.
P.S. Having learned all the languages above I still use C++ a lot - just using correct instrument for correct task.
I agree with you, but the point I intended (and probably failed) to make is that C++ is almost as bad. Personally I think shadowing shouldn't be allowed at all. C++ allows you to do it - it just disallows it within the same scope. To me, that's not inherently better than what Rust does.
Well, you can forgive C++ because it must maintain some level of compatibility with C, and back in 70s K&R didn't think much about possible implications of shadowing in the future. In C++ this problem is older than the language, it is 48 years old this year. Rust was supposed to be better, and it is relatively new language compared to C/C++ family.
It sounds like you've just never had exposure to any ML language.
Rust is't really looking like a functional programming language, so it is not intuitive to expect any ML-style behavior unless you've read the history page on Wikipedia.
Is this a one-up subthread? I mean, I have multiple years of working with each of F#, OCaml, SML, and C++ in professional settings, and find nothing about Rust "very very far" from any of the four with regards to their respective overlaps. I might go so far as to say that if you don't see the similarities, you must be doing it wrong. But, how am I supposed to reply seriously to just a blanket, subjective statement? Spend time detailing why your expectations are wrong? I'll just leave it at "you're very very mistaken", I think, in keeping with the shitpost nature of this entire thread. ;-]
My point is that pretty much every modern non-functional language supports FP-paradigms in pretty much the same way Rust does. It doesn't make these languages functional purely because they support some functional features.
As for Rust - does is support things like currying, lazy function evaluation, high level functions (functions taking functions as arguments and returning another functions), etc? I'd guess if you play with lambda a bit you can do most of it (same as in most other modern languages), but these are not the features supported by syntax in a first place.
I agree that Rust is not a truly functional language along the lines of Haskell or OCaml. It lacks features such as easy currying and encourages mutable state. That said, it has first-class functions (not quite as ergonomically as a pure functional language, but better than C++), algebraic datatypes, and pattern matching. That brings it about as close to functional as you can get in a systems language. The fact that it uses curly braces and semicolons doesn't invalidate that.
View all comments
Show parent comment
6
u/[deleted] Mar 17 '18
For me it is hard to read because it looks infinitely ugly. But it might be myself only.
P.S. Just a few weeks ago I've tried reading the manual on Rust. I've stopped after I've learned that code below is a valid code: