Using AI to learn programming is not cheating, and it is not automatically helpful either. The same assistant can teach you a concept in ten minutes or let you finish a whole course without learning it. The difference is how you use it.
What the evidence says
In a small randomized trial published in January 2026, Anthropic had mostly junior engineers learn a new library, with or without AI help. The AI group scored lower on a comprehension quiz afterwards, and the gap was largest on debugging questions. The learners who did well had something in common: they asked the assistant for explanations and follow-ups. The ones who did badly handed over the work.
It is one study, on one task. But it matches what most teachers see.
Try first, then ask
Write your own attempt before you open the chat, even if it is wrong and even if it only gets halfway. Then ask the assistant to review it. An answer you compare with your own attempt sticks. An answer you copy does not.
When you are stuck, give yourself ten minutes with the error message, a print statement and a guess about the cause. Most of what you learn about programming happens in those ten minutes.
Ask for explanations, not answers
Some questions teach and some just finish the task. Ask the first kind:
- "Explain what this line does and why it is needed."
- "Give me a hint, not the solution."
- "What is wrong with my approach? Don't fix it."
- "Show me a smaller example of the same idea."
- "Quiz me on what I just learned."
When it does give you code, ask why it chose that approach over another, and what input would break it.
The three-question test
Before you move on from anything AI helped with, answer these honestly:
- Can I explain every line, out loud, without looking at the chat?
- Could I write it again tomorrow, from a blank file?
- Can I name an input that would break it?
If you cannot, you have a working program, not a new skill. Go back and rebuild the part you could not explain.
Two rules worth keeping
Check your course's rules on AI before you use it for graded work. They vary, and they matter more than any advice here.
And practise debugging without help. When code is cheap to generate, the scarce skill is knowing whether it is right. Debugging is where you find out whether you understood.
Our free Introduction to Codex for CS Students shows how to use an assistant for coursework while keeping the thinking yours. Debugging Is the Skill gives you sixteen planted bugs to practise on.