4 ms·
Ask HN: Does ChatGPT Understand Rust?
And if not, what does that mean for learning Rust with a ChatGPT copilot?
- PaulHoule 4y agoChatGPT doesn't understand anything but it does recognize and repeat common (and not so common) patterns. It sometimes gives the right answers and sometimes gives the wrong answers but it using the same process in either case.
- sebzim4500 4y agoIf you have to be pedantic about the wording of the question, it is normally good manners to answer the intent of the question afterwards.
- andrewstuart 4y agoThis isn't really a helpful answer.
- PaulHoule 4y agoThen the answer is "no" but I'd say that no computer program can truly understand a computer program in a general programming language, see https://en.wikipedia.org/wiki/Halting_problem https://en.wikipedia.org/wiki/Halting_problem
- sebzim4500 4y agoIt definitely knows some Rust. Not as well as it knows Python or JS/TS, but easily well enough to be useful. Obviously don't expect it to know any libraries released in the least year.
- andrewstuart 4y agoIt seems to me that ChatGPT is a critical tool to assist developers in learning programming languages. Thus ChatGPT needs to be able to write reasonably good code in a given language and answer in depth questions about the language. I read somewhere recently that ChatGPT isn't able to explain in detail or give examples for some of Rust's more sophisticated concepts. This seems to me to be a big problem, especially when Rust is known to be so hard to learn that an AI assistant would be a huge help. How can this be addressed?
- PaulHoule 4y agoThe A.I. assistant has to use "old A.I." techniques that explicitly model the difficult things about Rust, particularly, the borrow checker. It's the same way there is a well-defined theory of how to do arithmetic and if you want do arithmetic you use that theory, you'd don't screw around with other things. There was a lot of hand-wringing about the difficulty of software reuse in the late 1980s, retrospectively a big part of the problem is that memory management is a global concern. How does a library get access to memory it needs to do its job and how do you know when to free it when possibly the library might need to use it later or possibly the application does. From that viewpoint the garbage collector was more important than object-orientation, inheritance and such for code reuse in Java because with the garbage collector the interface for managing memory between libraries and applications doesn't need to be defined. Buffers just go away when you don't need them anymore. When you look at people struggling with Rust this is one of the major problems: you can compose two systems that use garbage collection and it "just works", but put together two systems that use borrow checking and it may or may not work. It's easy to look at "fighting with the borrow checker" as a local problem but it is really is a global problem of having a consistently correct strategy across your application and its dependencies. It is where ChatGPT goes to die because it is always going to use heuristics that work locally but doesn't have any "understanding" (a theory) of the borrow checker. People were talking about building "expert systems" for this kind of task circa 1980 and a modern approach might combine an LLM with a theorem prover much like the way AlphaGo combines an old A.I. search algorithm with a neural heuristics.