6 ms·
The error messages are indeed _mostly_ marvelous (and there's an ongoing effort to make them even more marvelous). Often working with `rustc` feels like pair pr
by stevedonovan 9y ago
The error messages are indeed _mostly_ marvelous (and there's an ongoing effort to make them even more marvelous). Often working with `rustc` feels like pair programming for introverts. But here's a question: `rustc` often gives _actionable_ advice - how far can can you get just following that advice? You can make `rustc` happy by following suggestions, but may end up puzzled as to the reasons for the changes it suggests.
- aaron-lebo 9y agoElm is like the next level of this.
- exikyut 9y ago> But here's a question: `rustc` often gives _actionable_ advice - how far can can you get just following that advice? You can make `rustc` happy by following suggestions, but may end up puzzled as to the reasons for the changes it suggests. Not-crazy suggestion: add a `--why` option to rustc that doesn't just shout (helpful) error messages at you but actually explains the architectural theory of why the error is occurring and provides documentation links that help outline the canonical "right way" to do whatever it is you're trying to do. The idea being that rustc applies a ton of heuristics and intelligence (perhaps by analyzing nearby code) to guess what your high-level goal is. There have been a couple of "programming helper" AI-type apps float past here recentlyish; that's what I'm getting at. The reasons I think this would be a good idea is that a) this would be really really hard to get right, but AI R&D is pretty much at the point where you could put something like this together and build it into the compiler and pull it off really well b) rust seems to have a ton of energy behind it so if any language was going to implement this, it looks like rust has a fighting chance to actually get it done c) rust hasn't stabilized yet so _now_ is exactly the time to fold something like this in. it would need to be integrated as early as possible as a bolt-on afterthought would never work the same way
- hateduser2 9y agoI like the idea but Rust has so many issues in front of it I’m not sure it has the energy to invest in something like hay.
- stevedonovan 9y agoYes, the compiler is a permanent construction zone and there can only be so many projects on site, let alone workers. So this feels like something that _should_ be doable outside the compiler, but using its metadata. (BTW, "rustc --explain <error-code> does at least give you some nice text)
- e12e 9y agoSounds like having --why output --explain for each error might be the 80% fix?
- Karliss 9y agoHaving some understanding of difference between value and reference types types (from c or c++) and reading documentation a bit might be necessary. Error messages sometimes also contain links to documentation in case you have no understanding of the topic. The most common problems I had so for was due to incorrect level of indirection. In such cases the cause is quite clear function returned/expected reference/value/Option<val>/Option<&val> and you tried to assign it to something else. Suggestions help learning how standard library API behaves without opening API reference. In case of unwrapping Option or limiting borrows lifetime the code may get a bit messy. In such case I recommend reading documentation/searching internet as there might language or standard library feature (sometimes even in the link given by error message but not message itself) that helps writing it cleaner without brute forcing the code. Due to type checking it is difficult to mess up worse than making ugly code or moving away object you didn't want(which will be pointed out by compiler if you try to use it afterwards).
- pjmlp 9y ago> value and reference types types (from c or c++) Applies to other languages as well.
- continuational 9y agoMany languages handle this internally; essentially all functional languages and all dynamically typed languages.
- jankins 9y ago> You can make `rustc` happy by following suggestions, but may end up puzzled as to the reasons for the changes it suggests. This is how I felt, but it wasn't bad: I think you start to pick up on the patterns. In other words, learning isn't short-circuited after you've made rustc happy, even though you're still a bit puzzled - you'll carry the experience along with you and continue to learn from it later.
- rcthompson 9y agoI've seen at least a few articles to the effect of "I wrote the code I wanted, then kept running rustc and changing whatever it told me to until it finally compiled, and it worked."
- steveklabnik 9y agohttps://github.com/killercup/rustfix https://github.com/killercup/rustfix is an experiment in exactly this.