Short answer: plan your solution and write a first attempt yourself, then use AI to explain errors, give hints and quiz you on concepts, not to generate the whole answer. In studies of beginners, students who already knew what they wanted to build used AI to go faster, while struggling students leaned on it and came away overestimating what they could do. Test yourself regularly without the AI, because that is the condition of most exams.
What does research say about learning to code with AI?
The results are mixed in a way that is useful to understand.
It can help with writing code. Kazemitabaar and colleagues (2023) ran a controlled experiment with 69 novices aged 10 to 17 working on 45 Python tasks, where half had access to an AI code generator. With AI, the completion rate on code-writing tasks was 1.15 times higher and scores were 1.8 times higher, and performance on follow-up tasks where students had to modify code by hand did not drop. On a test a week later, the AI group scored only slightly higher, and the difference was not statistically significant. Students with stronger prior skills gained more.
It can split a class in two. Prather and colleagues (2024) watched 21 university novices solve a programming problem with AI tools, using observation, interviews and eye tracking. Twenty of the 21 finished the task, but the way they got there differed sharply. Students who did well used AI to produce code they already intended to write and ignored unhelpful suggestions. Students who struggled kept their existing difficulties, which AI could compound, and they tended to overestimate their performance, finishing with an illusion of competence.
Unrestricted help can harm exam performance. Outside programming, Bastani and colleagues (2025) found that high school maths students with a standard ChatGPT-style tutor did better in practice but scored 17% worse on the exam once the AI was removed, compared with students who never had it. A tutor that gave only hints largely avoided that harm.
Why does AI help some students and not others?
The difference in Prather's study came down to who was in charge. Students who had a plan used AI as a typist. Students without one let it decide what to write, and then could not tell whether the code was right or why it worked. Finishing the task gave them a feeling of success that their understanding did not match. Our post on the illusion of competence explains why that feeling is so convincing.
The practical lesson: AI amplifies whatever you bring. If you can describe the steps of a solution before you write it, AI speeds you up. If you cannot, it hides that gap until an exam or interview reveals it.
Habits that keep you learning
- Plan in plain words first. Before touching code or AI, write the steps of your solution as a short list. If you cannot, that is the part to learn.
- Write a first attempt yourself. Even a broken one. Then use AI to explain the error message or point to the line that is wrong, not to rewrite the function.
- Turn off inline suggestions for practice. Autocomplete that writes the next ten lines is helpful at work and harmful when the goal is to learn. Keep it for projects, not exercises.
- Explain every line you keep. If AI wrote something, you should be able to say what each line does and why. If you cannot, ask it to explain, then close the chat and explain it back in your own words.
- Rewrite from memory. A day later, write the same solution again without looking or asking. That is retrieval practice for code.
How do you revise for a programming exam?
Most written programming exams test things AI cannot do for you in the room: tracing what code outputs, spotting the bug, ordering the steps of an algorithm, explaining a concept such as recursion or complexity, and writing short functions by hand.
- Trace by hand. Take short snippets from your lecture slides and predict the output before running them.
- Put the steps in order. For each algorithm on the syllabus, write its steps from memory, then check against your notes.
- Test concepts, not only syntax. Ask yourself "why is this O(n log n)?" or "when would this loop never end?" and answer in a sentence.
- Space it out. Short sessions across several days beat one long session the night before. Our guide to studying for exams covers the basics.
Prompts that teach rather than solve
- "Here is my code and the error. Do not fix it. Tell me which line is causing the problem and give me a hint about why."
- "Ask me five questions to check I understand how this function works. One at a time, and wait for my answer."
- "Give me a short snippet using recursion and ask me to predict the output. Do not show the answer until I reply."
- "I have described my plan below. Point out any step that is missing or wrong, without writing code."
For lecture-based modules, Ace turns your own slides, PDFs or lecture notes into practice questions written from that material only. Where your material describes a process, such as the steps of an algorithm, questions can include put-the-steps-in-order, and every answer shows the sentence from your file that backs it. You can see the steps on the how it works page.
Frequently asked questions
Should beginners use AI to learn to code?
Yes, with limits. In Kazemitabaar and colleagues (2023), AI helped novices write code without hurting their manual skills in the short term, but gains a week later were small. Use it for explanations and hints, and write first attempts yourself.
Is using ChatGPT for programming homework cheating?
That depends on your course's rules, which vary. Check the module guidance. Even where it is allowed, submitting code you cannot explain leaves you unprepared for exams and interviews.
Why do I understand code when AI writes it but cannot write it myself?
Reading working code feels like understanding, but writing it requires recalling the steps yourself. Prather and colleagues (2024) observed students finishing tasks with AI while overestimating their own performance. Practise writing from memory to close the gap.
How do I study for a written programming exam?
Trace code by hand, write algorithm steps from memory, explain key concepts in a sentence, and space short sessions across the days before the exam.
Sources
- Prather, J., Reeves, B., Leinonen, J., MacNeil, S., Randrianasolo, A. S., Becker, B., Kimmel, B., Wright, J., & Briggs, B. (2024). The widening gap: The benefits and harms of generative AI for novice programmers. ICER 2024 (arXiv:2405.17739).
- Kazemitabaar, M., Chow, J., Ma, C. K. T., Ericson, B. J., Weintrop, D., & Grossman, T. (2023). Studying the effect of AI code generators on supporting novice learners in introductory programming. CHI '23 (arXiv:2302.07427).
- Bastani, H., Bastani, O., Sungu, A., Ge, H., Kabakcı, Ö., & Mariman, R. (2025). Generative AI without guardrails can harm learning: Evidence from high school mathematics. Proceedings of the National Academy of Sciences, 122(26), e2422633122.



