Learning Rust, my experience so far has been mixed
I have been lurking toward Rust for a couple of years now and have read the key parts of the documentation.
I love the idea of it, and so a few days ago I finally decided to learn it by starting to write code.
Now for the context, I'm a developer with more than 15 years of experience, on about a dozen various languages including Go, Java, PHP, JavaScript or TypeScript.
So far, my experience with the language and Rust itself has been overall very good. I love how strict it is, and the fact that it does not let me do any mistake while being very expressive and giving me more freedom (unlike Go, with which I have been quite frustrated lately). And contrarily to most people, I haven't struggled much with the language itself (yet?), but felt that things are quite natural and "right".
Cargo has been a blast as well, including the build.rs part. It is pleasant to have something simple, efficient and that just works.
That said, when using it for more concrete things, I have found myself disappointed and frustrated by the quality of the documentation and discoverability of the various crates.
More specifically, I found that more often than not the autocompletion is useless, especially for the discovery of methods or types. Because unless I already know about a specific trait or feature flag, it's not going to be shown. And except for the most basic use cases, the documentation always just shows a couple of examples and nothing much more.
A few examples in my mind on which I got frustrated and wasted a lot of time:
Finding how to manually navigate a json document and iterate arrays in it was a painful experience of trying to guess random things. Nothing in the documentation helps, and the documentation does not either.
Even with alternative crates like
json(https://docs.rs/json/latest/json/), which I heard is supposed to be more simple, I couldn't find how to iterate an array.Then I tried to get a json date to be parsed (in a struct) via Serde amd the
timepackage, and here again it has been a super frustrating experience. After wasting a lot of time, I ended-up discovering that I have to use the macrotime::serde::iso8601, and that to access this one it's not enough to add theserdefeature flag totime, but that I'm also supposed to addserde-well-known. And none of that is clearly documented anywhere.Trying to create a datetime+timezone instance from separate integers (
2023, 1, 1, 0, 0, 0, basically) has also proven to be very tiring because the namings and structure oftimeisn't very consistent or obvious, andchronois super complex, over-engineered and not well documented either.Trying to return an error enum that happens to include
reqwest::Error. This one just does not compile, and I didn't find the error message to be helpful. Instead I end-up having to writeResult<Foo, Box<dyn std::error::Error>>everywhere, which is terrible.
I realize that some of those issues may be due to my lack of experience in the language, but still, am I doing something wrong, or is it really the current state of the art in Rust?
I am curious to hear about different experiences, because as much as I love the language itself, I'm now unsure if I want to continue to learn it or not.