5 ms·
> and started writing more code. The code did not compile. I was shocked. It’s quite an amazing feat, that, to have a recommended learning material that can mak
by j_m_b 2y ago
> and started writing more code. The code did not compile. I was shocked. It’s quite an amazing feat, that, to have a recommended learning material that can make your very first program not compile.
Yah I had similar problems and `cargo` didn't just work for me. I've had a tough time getting rust going.
I just don't see the appeal. Memory safe sure, but I rather draw on the wealth of C/C++ knowledge if I am going to be writing code where Rust is a good fit.
- n8henrie 2y ago> The problem was, of course, the fact that I didn’t copy-paste right the setup sequence Sounds like the author did not specify the correct version of a dependency. It should not be surprising to find an incompatible API if using a (presumably) different major version number of a dependency, right? I would say that failing to compile seems like a best-case scenario here. Serious question -- what would have been a better result in this situation?
- steveklabnik 2y agoYes, the situation that happened here is that the rand package would have made a breaking change. I haven’t heard of that being the case. The book’s code is tested in CI. I’m not saying it’s impossible, but I am saying it’s surprising. It’s certainly a bad experience, though, while the author is wrong about many things, he’s right about that.
- estebank 2y agoI wonder if it could be a new manifestation of the long living problem of older resources appearing linked from random blogs or surfaced in web searches. I haven't seen that problem in a while, but could be one explanation for that.
- steveklabnik 2y agoPossibly, yeah. I haven't heard of that in a very long time either, but even then, if they were following the same code as on that resource, in theory it should have worked? The current version of the book uses [dependencies] rand = "0.8.5" 1.31.0 (the oldest I could find with the same URL, I don't remember when exactly the book shipped so maybe it's slightly off but whatever) uses [dependencies] rand = "0.3.14" So yeah that's a lot of differences. But if they used the same code as the book, then it should have worked. So it's possible that: 1. they got an old resource but then used a newer version of rand, maybe by using `cargo add` instead? 2. rand had a breaking change somewhere along the way there, and they got unlucky Guess we'll never know...
- estebank 2y ago> instead of choosing a certain numbered version of the random library (if I remember correctly) I let cargo download the latest version which had a completely different API. Yeah, they didn't follow the instructions and got burned. I still think that multiple things went wrong simultaneously for that experience. I wonder if more prevalent uses of `#[doc(alias = "name")]` being leveraged by https://github.com/rust-lang/rust/pull/120730 https://github.com/rust-lang/rust/pull/120730 (which now that I check only accounts for methods and not functions, I should get on that!) so that when changing APIs around people at least get a slightly better experience.
- steveklabnik 2y agoAhhh nice catch. Yeah, I think that might help, but also, on some level, if people choose to not follow instructions, additional instructions don’t tend to help. Doesn’t mean it’s not worth trying in some circumstances, of course…