| > I love the semicolon rule, I think that distinction is extremely important and too often gets muddled Yes, the distinction is important. That's why it's extremely annoying that this distinction is almost invisible if you don't look very close on the code using magnifying glasses. Like I said: Marking such an important distinction through something almost invisible like a (missing) semicolon is pure craziness. Usually nobody reads semicolons! They are usually just line noise coming form a time as parsing code was actually still some kind of science and people made syntax with the explicit intent to be easy readable by archaic computers (and not humans in the first place). I think `return`s are superfluous but given the choice between some more line noise in the form of a `return` statement and this semicolon brain-fart I would clearly prefer the `return`… > (though in Rust's case I think it's more accurate to say it distinguishes between "statements and expressions" than "procedures and functions") Since when? Did I miss something? (This could be, I'm looking only occasionally into Rust). AFAIK leaving out the semicolon is only an option on the last expression of a procedure, turning that "procedure" into a function. Leaving out (the completely unnecessary!) semicolons elsewhere is a syntax error to my best knowledge. fn main() {
let baz = if false {"bar"} else {"foo"}
println!("Hello, {baz}!", baz = baz);
}
The above code would not compile, afaik, because the semicolon is missing on the first line of the procedure.The completely unnecessary semicolons are just one of the examples that make the Rust syntax heavyweight and needless noisy for no good reason. I don't get how a modern language can fall back to such antique syntax. The very rare use-case where you really want to write some comprehensive one-liner could have been easy supported by optional semicolons. But in the general case one just doesn't need that line noise. Rust is a great language, really! But they obviously didn't put any effort into the syntax. The result is that the language reads partly like C++, and I guess almost everybody could agree that C++ has one of the most terrible syntax out there. Rust is "modern" language with a stone age look & feel. That's a big missed opportunity, imho. |
This is an incredibly arrogant and ignorant statement to make, especially for someone who self-describes as "looking only occasionally into Rust". A whole lot of thought has been put into Rust's syntax.
> The result is that the language reads partly like C++
My impression is that a certain amount of this was intentional; if their goal is to attract C++ developers, they can't scare them off with syntax that's wildly alien. Rust took the parts of C++ syntax that made sense to keep and that fit into Rust's semantics, refined/modernized/distilled them, sanded off the rough edges and ambiguities, and presented something cohesive that's still familiar.
The syntax isn't without warts - turbofish comes to mind - but overall I find it pleasant and comfy (and I'm not even a C++ developer). I appreciate that it makes a lot of things explicit that should be explicit. Fewer characters doesn't automatically mean better readability; in many cases it can mean the opposite.