2 ms·
struct Foo<T> { t: T } Braces... one extra sign (and line) for nothing while indentation works fine. import foo::bar::baz; import foo.b
by JodieBenitez 3y ago
struct Foo<T> {
t: T
}
Braces... one extra sign (and line) for nothing while indentation works fine.
import foo::bar::baz;
import foo.bar.baz
4 times the dots, also useless comma.
Objectively less visual noise in Python. Of course the importance of it is subjective, I agree with that. But still, less cruft is good.
> minor things that barely barely impact readability
Of course, I don't agree :-)
- Ygg2 3y agoThese are subjective things. I don't consider Rust syntax perfect, but I don't these suggestions as way to improve it substationally. If you want to get rid of `::` and `;` and braces you have to look at the fallout of those decisions. Braces are imo much better at being robust than whitespace. def Foo[T]: t: T size: u32 // invisible error here because someone used tabs by mistake `;` disambiguate expression vs statement. If you remove it you need way to differentiate between them. Another problem with `import foo.bar.baz` is how will you distinguish between a method call or a type declaration? E.g. `std.option.Option.Some` what is this? Type? Method? Module? What is `std::f64::consts`??? Not to mention you kinda have to have compiler in mind, if syntax is ambigous you're going to have a very bad time.
- weinzierl 3y agoI agree with that and would not want to see braces and semicolons go because they are pretty conventional. In this case Python and Javascript/Typescript are the outliers. It's the opposite for the double colon syntax which, apart from Rust, to the best of my knowledge only exists in C++ (for good reasons) and some functional languages for a completely different purpose. Honestly curious question: What fallout would you see from replacing it with a dot in Rust. I immediately see no disambiguation issues, but I'm not a compiler writer.
- JodieBenitez 3y ago> // invisible error here because someone used tabs by mistake would not parse, so no invisible mistake.
- Ygg2 3y agoImplying every site you post code to will have correct syntax highlighter.
- insanitybit 3y agoRust's philosophy is "explicit over implicit" - braces fall inline with that. One extra line for a struct is really not a lot. That whitespace sensitivity also leads to having to escape newlines, with `\` trailing lines all over the place in Python. I find that far uglier than "4 times the dots" for import statements. > Of course, I don't agree :-) For sure, I think that's kind of my point. Like, this all feels very unimportant to me and extremely subjective. I think that rust's syntax fits into its philosophy, however. I would not mind unifying path syntax such that `:` became `.` however.
- JodieBenitez 3y agooh the irony... "Explicit is better than implicit." ;-)
- steveklabnik 3y agoIt's a fantastic example of how witty sayings don't necessarily lead to agreement, even among people who would agree in the truth of the saying.
- JodieBenitez 3y agoIndeed... "philosophy" is often a poor justification for technical choices.
- insanitybit 3y agoI don't actually see the irony?