|
|
|
|
|
by gmandx
2903 days ago
|
|
1- Why I didn't start sooner?
2- I should have (fully) read the book first: I dismissed it at first thinking "yet another half baked piece of documentation". Not the case at all. It has help me understand why my code doesn't work and why are things done this way, the reasoning behind the decisions and the compiler's rules.
3- I shouldn't have been so eager to integrate external crates into my projects (I mean, during the learning phase); while most of them are good, have nice APIs and `cargo` makes it incredibly ease to use them, they sometimes abstract away concepts that (IMO) I should understand well first, then use the external crate, knowing what it does and more or less how it does it. The evidence for me was that I had to spent some time reading the crate's code just to make my code work.
4- I should have keep going at it (eventually, I did). Speaking from myself, with a background of years using Python/JS, the compiler/borrow checker/lifetimes are important concepts that I just simply fail to understand at first (and I can't yet claim that I understand them now). It actually depressed me a bit for a while. But I kept going until I realized that for some aspects, I still was trying to use Rust like I would use Python. Learning Rust has changed how I think about Python, which I still love, but now I'm aware of a lot that can go wrong now, but I have no control in Python code. Rust made me aware of that because is constantly making you aware of all the possibilities, (this could succeed or not, this could be something or not). Finally understanding why the error and how to make it work was a huge payoff.
5- I should have been more aware of all the methods of the Result/Option enums. Returning these enums everywhere feels like I'm going to have an explosion of boilerplate code, but actually, the `match` syntax is really concise, the `?` operator cuts down a lot, but, their methods provide a lot of useful ways of "chaining" transformations between them that really cuts down on boilerplate and code nesting. Something I like to do a lot now, is running Clippy in "pedantic" mode to learn more. IMO, the pedantic rules are not there to follow them to the letter, but I do read them in case the might hit to some improvements. Clippy in general is great, and have learn quite a bit about idiomatic Rust thanks to it. PS:
7- For the Linux folks that have `/tmp/` mounted using `tmpfs` with `noexec`, Cargo (for some reason) likes to put and execute a few build scripts for the crates being installed, and it took me a while to realize why Cargo installs where failing, I simply didn't remenber about my `/tmp` setup, because `ls` still reports that the execute is set for the script. I know have this (Fish) alias to tell Cargo to use a different temp directory: `alias cargo='env TMPDIR=$XDG_RUNTIME_DIR cargo '`. |
|