Proper use of ChatGPT for learning to program
/You might be wondering about the best way to use ChatGPT (other large language models are available) to learn how to write programs. Here’s what I think.
Do not ask ChatGPT to write code for you
This is a great idea if you know how to do a job but are just too lazy to do it yourself. If is a bad idea if you want to learn from what ChatGPT will produce.
In my experience requests to make code usually result in something around 95% right. You can fix the first few faults by telling ChatGPT what it has got wrong. But there comes a point where this no longer works. ChatGPT will claim it has fixed things, but the program still won’t work. A skilled coder can have fun finding the remaining issues and fixing them. A learning coder will just get frustrated.
Do ask ChatGPT to explain things to you
You are on much more solid ground if you ask ChatGPT to explain something you don’t understand. Ask it what “NaN” means in JavaScript, and you will get a good explanation, some examples and suggestions of things that you might want to know about next. This can make for great learning journeys. And at any time, you can ask it to summarize what you have learnt so far or ask you some questions you can use to check on your progress.
When ChatGPT is asked to explain something, it just has to find the information it has obtained from lots of sources - including my writings ☹ - and then summarize it. ChatGPT doesn’t have to make anything original. You can be a lot more confident that what it says is correct, since it hasn’t really had to originate anything.
Do tell ChatGPT what you know
You can use ChatGPT to test your understanding of something. This is very useful for two reasons. Firstly it gets you used to explaining what you know. Secondly it provides useful confirmation or critique of what you understand and how you expressed it. Start with “As I understand it….” and then go on to set out what you think you know. If you have a question about this, add it on the end. This gives the AI plenty of raw materials to come up with a useful response.
Do show ChatGPT your code
It turns out that ChatGPT is very good at figuring out what code does. If you want some comments on your approach or better ways to do things, paste the lot into ChatGPT and see what it says. You can then ask ChatGPT to expand on its comments and make more suggestions. If you want to learn a new graphical framework or library (or even language), paste your code into ChatGPT and ask it to generate a new program with the required changes. You can even get ChatGPT to write documentation for you. Or at least produce a first draft you can fiddle with.