3 ms·
One thing I wished was on this list, but wasn't, is syntax. I love many syntax decisions Rust made, but I wish Rust hasn't borrowed so much syntax from C/C++. T
by weinzierl 3y ago
One thing I wished was on this list, but wasn't, is syntax. I love many syntax decisions Rust made, but I wish Rust hasn't borrowed so much syntax from C/C++. The syntax of these languages was designed under (for todays standards) weird keyboard and encoding constraints and many choices are just odd.
To give you a few examples:
- = instead of == for equality would have been the natural choice
- := for assignment is similar enough to what is used in math for definition, so that languages like Pascal use it
- <> for inequality is something SQL got right
Smaller things that bug me are the ubiquity of the double colon (::) and the weird mixture of snake case and camel case conventions.
And not to leave the wrong impression, I think Rust got many things very right. My personal highlights are:
- -> for the return value
- concise keywords like `fn`
- `where` for constraints
In general more Algol/Pascal and Haskell - less BCPL and C/C++.
- jstx1 3y agoSyntax is mentioned in the article - it's under "Complex Grammar".
- epage 3y ago> - := for assignment is similar enough to what is used in math for definition, so that languages like Pascal use it I think its cppfront that is taking the approach of `:=` being a declaration with the type being inferred (ie shorthand for `: Type =`). Reading up on that has made me the most ok with applying this to functions (which I see coming up more these days) but I think i still prefer functions having a more distinct look as I process them differently when reading. Now, cppfront's approach to types I think is bonkers, making critical details hard to find except maybe through convention. https://github.com/hsutter/cppfront https://github.com/hsutter/cppfront > <> for inequality is something SQL got right Maybe I'm not recognizing the biases of my own learning background but this never reads right to me vs "not equal" / `!=`. > - concise keywords like `fn` In other discussions, it sounded like Graydon had an upper limit of 4 characters for keywords https://www.reddit.com/r/rust/comments/13oemrg/question_about_ret_being_replaced_by_return/ https://www.reddit.com/r/rust/comments/13oemrg/question_abou... For me, I had a "whoosh" moment for `fn` and always thought it a weird abbreviation, completely overlooking "fn" keys on laptops.
- weinzierl 3y agoMy very first programming language had fn, so maybe my love for it is just a form of nostalgia.
- pitaj 3y agoAssignment is more common than equality. Typing two identical sequential characters "==" is much easier than typing ":=" especially since on most keywords colon requires shift and equal does not. And having a two-character equality operator helps align things with "!=", ">=", "<=".
- weinzierl 3y agoEquality is so much more common than the other relational operators that it justifies the single letter.