3 ms·
Rust is a starkly different vocabulary and syntax than other languages I've learned. The error handling is different than both Python, C, Matlab, etc. Objects s
by PennRobotics 3y ago
Rust is a starkly different vocabulary and syntax than other languages I've learned. The error handling is different than both Python, C, Matlab, etc. Objects suddenly have ownership that has to be respected.
If I see Java source, it makes sense even though I don't know Java... at least up until how javax.swing layouts are constructed or I see a really obscure annotation without comments. If I had to add something to the Arduino 1.0 IDE, I'm confident I could figure it out in a day or two, because a class is a class, lines end with semicolons and comments look /* like this */, I can guess the existence of sort() or random() or an int being either int, Int, or Integer.
In contrast, a Rust "trait" being roughly equivalent to a C "struct" would not have been in my top 20 guesses. I can't recall trait being a keyword in ANY language I've used. I have no idea what Box and Arc are, because to me, those are "what you put tools in" and "plasma from too much potential difference".
Yes, I can check the reference (constantly) but at some point looking up every word or tick mark gets in the way of absorbing the story. The punctuation in particular bothers me, because it's not searchable via engine. There's no special Google result for
rust '
I can't be more clear. My ability to read/write code extends beyond pseudocode. Rust is just not an easy transition for a "primarily C" user, in my experience and opinion.
- steveklabnik 3y agoJust so you’re clear about it, a Rust trait is not like a C struct. It is like a Java interface. Rust’s struct is like a C struct. “Trait” is used for similar features in Scala and PHP. https://en.wikipedia.org/wiki/Trait_(computer_programming) https://en.wikipedia.org/wiki/Trait_(computer_programming) Box is used in Java and many functional languages. https://en.wikipedia.org/wiki/Boxing_(computer_science) https://en.wikipedia.org/wiki/Boxing_(computer_science) Arc is the most confusing name out of these for sure; most folks talk about “reference counting” in general and assume the count is atomic; with Rust’s performance and safety focus, Rc is the non-reference counted version and Arc is the atomically reference counted version. Additionally, there is a feature called “automatic reference counting” that some languages use, that uses atomic reference counting in the implementation. > There's no special Google result for rust ' If I google for “rust apostrophe” this is my first result, which is pretty comprehensive: https://stackoverflow.com/questions/22048673/what-are-the-identifiers-denoted-with-a-single-apostrophe https://stackoverflow.com/questions/22048673/what-are-the-id... While this syntax is unusual it is also not unique, OCaml uses it for similar purposes. Nobody loves this one, but also nobody was able to come up with something that could be agreed upon to be better.
- tialaramex 3y ago> Rc is the non-reference counted version and Arc is the atomically reference counted version. Typo here I think Steve, Rc is reference counted, but it's not atomically reference counted. Hence the lack of an A. You've managed to instead say that it's not reference counted.
- steveklabnik 3y agoThank you, yes. I think my phone was messing with me. Too late to edit now. I appreciate it.