News for hackers. Stuff that matters.
Re:Two Years with Rust by dgb23 on Monday March 23, 2020 @11:04AM (#22664768)
Disclaimer: I'm a big fan of Rust and I'm very hopeful about its future. This is why I spend a lot of time studying it.

As someone who is learning and comparing the language there are things that I think definitely suck about Rust:

* Syntax is ugly, unclean and overloaded. There are things like the ? operator which seem to have no purpose other than sugar in the sense of "you write a bit less code", which I find to be useless, obscure and even had restricting implications on async/await. Also the whole language suffers from being a weird mix of C-like statement syntax and FP-like expression syntax, which takes time to get used to. Function signatures are both verbose and arcane. I wish Rust just admitted early on, that it needed a different way of expression and went from first principles instead of superficially trying to mimic other mainstream languages.

* Rust being a very error driven language is a good thing, but make it less suitable for prototyping the happy path. This is fine but a constraint that one should keep in mind.

* powerful pattern matching, dataless programming with traits, FP-like API on iterators and option/result etc. make it very expressive on a higher level, but more basic things like string operations and array indices (possibly other things as well) are far less ergonomic than in other modern languages. Typically in other/older languages you'd struggle with abstraction but the basic stuff is easy, in Rust you struggle with the basic stuff and abstractions are ergonomic.

* all around (a bit) too much emphasis on structs over hashmaps as the default data structure for associative grouping.

Things I like about Rust but are not for everyone:

* Rust is very error driven, you tend to write a lot of code around errors, options, results.

* pattern matching/destructuring is the main way to write branching logic.

* a lot of emphasis on enums (tagged unions) to express configuration, state, variants and things like that.

Re:Two Years with Rust by hechang1997 on Tuesday March 24, 2020 @01:34AM (#22672259)
> Also the whole language suffers from being a weird mix of C-like statement syntax and FP-like expression syntax

I quite like this though. All other expression based languages like MLs and Haskell use indentation, making it very hard to parse. To me, Rust's syntax allows very granular control. I wish more things in the language can become expressions, like the let expression, for/while loop.

Re:Two Years with Rust by dgb23 on Tuesday March 24, 2020 @01:58PM (#22676934)
I agree that it is useful. But from the perspective of a learner it is a stumbling block. Rusts syntax seems to be a compromise to cater to c-likeness. Not a deal breaker at all, just something that I think is not as good as it could have been and will confuse adopters at least in the beginning.

On the flip-side it might attract more developers who are not familiar with anything that is not c-like.

As a side note, Lisps are expression based and have a very clean syntax where you don’t need to mentally construct an AST, it is literally there in front of you already.