Learning to code: AI is not your friend
If you are learning to code, asking AI to write your programs will make you a worse programmer. It gets you working code much faster, but it removes the loop of errors, searching and fixing that makes programming one of the easiest subjects to teach yourself. The better use of AI is as a hint-giver that sends you back into that loop, not one that skips it.
Who am I to say this?
The last time I made videos on my YouTube channel, three and a half years ago, I was a teacher. I spent ten years in computer science education. Since then I have been working as a software engineer, and I am now a mid-level engineer at an experience-design company, working mostly in Python and Django on the back end.
So learning to code alongside AI has been my life for the past three and a half years, and so has living with the changes AI is bringing to the industry. These conclusions come from that experience, and they have some basis in recent research.
Are developers really learning with AI now?
Yes, and quickly. The Stack Overflow developer survey asks, "In the past year, when you learned to code, what was your primary learning tool?" Over the last four surveys, AI has gone from 0% to 37% to 44% to 52.6%.
That still leaves a lot of people learning without AI. It turns out they are probably making a wise decision.
What does the research say?
Two recent studies are worth knowing about: one from Munich in Germany, and one run by Anthropic. Neither has a huge number of participants, so they are by no means conclusive, but they are definitely interesting.
The Anthropic study gave two groups of junior engineers a unit of work that required some learning. One group used AI and the other did not. The AI group finished faster, of course, but both groups spent a similar amount of time on the task before a quiz, and the group without AI scored better. They learned more.
The Munich study used three groups: one with an open-ended chatbot (essentially ChatGPT, not on any rails), one with a chatbot that only gives hints, and one with no AI. The learning results were broadly similar, with one interesting caveat: the group with the hint bot was the most motivated and enjoyed the process the most.
That caveat is what I am taking away from it, because I have been working on AI hints since 2023.
Why is programming so easy to learn on your own?
For years I ran computer science competitions, and again and again I met high school students who were better than university level. When I talked to colleagues in other subjects, that just doesn't happen in maths, English, biology or physics.
The reason is what I call the learning loop. Programming gives you a constant stream of meaningful, instant feedback:
- You have a goal, say a Python script that does something.
- You write some code and run it.
- It produces an error. Now you have something to search for: what does this mean? You read the docs, Stack Overflow, Google the message.
- You go back and make changes. Maybe you get another error, but it is a different error, so you are moving forward.
- Eventually it runs, and you are closer to your goal. Maybe the output isn't quite right, so you refine it, or refine the goal itself.
Compare that with an English essay, where you wait three, four or five days for the teacher to mark it before you get any feedback at all. Students in other subjects get far less feedback than developers do, which is why, once you start enjoying programming and doing a lot of it, you learn so fast.
I used to be a mechanical engineer, and the digital systems I work on today are a hundred times more complex than the mechanical systems I worked on then. I think that is the learning loop at work: it is so efficient that people learn to a higher level and can manage far more complexity.
What happens when AI enters the learning loop?
You have a goal. You ask AI to do it. You press run, and it just works. If you want to understand it, you ask AI and it gives you an explanation. None of the searching, the unpacking of errors, the reading of documentation needs to happen.
Picture the same goal tackled both ways. Without AI, you might take a hundred iterations: mostly errors at the start, refinements towards the end, and 80 or 90 trips to the docs, Google or Stack Overflow to understand something. With AI, you generate it once, refine it once, polish a couple of steps, and it's over.
That is much, much faster. But it is not a good learning loop.
- With AI, you produce more code. You could argue about whether it is better code. It is certainly less human-readable, but it works, it is robust and it is fairly defensive.
- Without AI, especially at the beginning, you produce less, but you learn more.
So if you are learning and leaning on Claude Code or Codex, it is making you worse at understanding code.
How can AI help instead?
This is what I am trying to build with Agent Games, the site I have been building since 2022. It started as a coding competition platform, and I have since generalised it so you can learn to code independently or use it in a classroom.
The core idea is the AI hint, and it puts you back into the learning loop. Say you are working on an exercise or writing an agent for one of the games: you are running a program with a goal, and you hit an error. Instead of a stack trace, which is very intimidating for beginners, you get a hint: "Look at line eight. And by the way, read this lesson." It points you straight to the right learning resource, you read it, and you are learning.
It reproduces the original learning loop, just more efficiently. Coding isn't really that difficult. It is that, compared with most subjects, it takes a lot more patience and perseverance at the very beginning. Hints should smooth out that start and speed it up a little.
What's next?
I have created high school level courses so far, and I will be making more on my YouTube channel. I already plan to cover some advanced Python I want to master myself: context managers, data classes and generators. I will put the content for them into Agent Games and go through the learning loop myself, so you can watch, and hopefully come along for the journey.
Links to the studies and resources are in the top comment on the video. And of course, I hope you check out Agent Games.
Teacher comments
No comments yet.
🛡️Comments are restricted to teachers only and moderated for child safety reasons.