Learning to Code With AI Without Your Brain Checking Out

In a 2024 study, a student finishes their programming exercise. They succeeded: 95% of the task done, the code runs. In the interview right after, they admit: "Honestly, I really don't understand code at all." They had just produced it. With AI, they finished everything, and learned nothing.

That sentence captures the most insidious trap of our era. AI makes writing code so frictionless that you can sail through an entire learning experience without your brain encoding a single thing. You feel like you're learning, you produce, and nothing sticks. I built an entire course section (Learn with AI) around this problem, and the deeper I dig into the literature, the more I see how underestimated it is. Here is what the neuroscience actually says, and how to learn to code in the age of AI without getting fooled.

Cognitive debt, or why you remember nothing

In 2025, Nataliya Kosmyna's team at the MIT Media Lab wired electrodes to the skulls of 54 students while they wrote essays. Three groups: brain only, search engine, and ChatGPT. The result is brutal. In the AI group, 83% of participants could not quote a single sentence of what they had just written. Not vaguely: nothing at all. The EEG showed collapsed brain connectivity, and the lowest sense of authorship over their own text.

Researchers call this cognitive debt, by analogy with technical debt. When you outsource your thinking to a machine, you save time now and pay later in the form of knowledge that never formed. The mechanism is simple and unforgiving: long-term memory is built through the effort of retrieval. If information arrives pre-chewed and no effort goes into producing it, the hippocampus consolidates nothing into the neocortex. The code passed before your eyes, never into your head.

The counterintuitive rule of learning: the smoother it feels in the moment, the less it stays afterward. Felt ease is not learning, it's just ease.

The illusion of competence

The second danger is sneakier, because it disguises itself as success. In 2024, a study titled The Widening Gap watched 21 novices solve a problem with GitHub Copilot. Completion rate: 95%, versus 65% in a comparable study without AI. On paper, a triumph. Except nine of the ten struggling students would never have finished without AI, and believed they understood the solution far more than they did.

This is the illusion of competence. Your brain confuses "I recognize this code, it looks right" with "I can produce this code." Recognizing is infinitely easier than generating, and AI constantly puts you in recognition mode. You read a solution, it seems obvious, you nod, you move on. The feeling of mastery is real. The mastery is not. And since you feel competent, you never feel the need to actually practice.

Why it's worse for beginners

The study's title, the widening gap, is no accident. AI does not benefit everyone the same way. Already-solid developers use it to produce what they already knew they wanted, and crucially they reject bad suggestions. Researchers call this negative expertise: knowing what not to do, spotting a smelly suggestion at a glance.

Beginners lack that filter. They accept Copilot's suggestions 34% of the time, versus 24% for the more comfortable ones, including when they are wrong. They dive into debugging dead ends, drifting further from the solution, convinced the AI must be right. The result: AI accelerates the strong and drowns the weak. The gap between those who already knew how to reason and the rest widens instead of closing.

The lesson is harsh but clear: AI is an amplifier, not an equalizer. It multiplies what you already know how to do. If you can judge code, it makes you formidable. If you can't yet, it gives you the illusion that learning is no longer worth the trouble.

The 4 mechanisms to actually learn

The good news is that the remedies are known, measured, and old. The science of learning calls them desirable difficulties (Robert Bjork): deliberate frictions that make learning harder in the moment and far more durable afterward. Four matter most when learning to code with AI.

Two learning paths: delegating to AI leads to fast forgetting, while active retrieval and effort lead to durable memory. Delegate to AI Actually learn AI writes the code you read, it looks clear You try first you retrieve from memory You copy, it works zero mental effort Effort, sometimes failure desirable difficulty Nothing encoded forgotten in 24h Memory consolidated it sticks
Same time spent, opposite outcomes. The friction on the right is the price of memory.

1. Active retrieval

Pulling a piece of information from your own memory strengthens it far more than rereading it. It's the best-established effect in all of cognitive psychology. Concretely: before asking the AI, try to answer yourself. Before running a snippet, predict what it will print. Close the tab and rewrite the function from memory. Every time you force your brain to produce instead of recognize, you carve it in.

2. Spaced repetition

A concept reviewed once is forgotten. Reviewed three times at growing intervals, it settles for good. The counterintuitive part: you must let forgetting begin before reviewing. Reviewing while it's all still fresh does nothing; reviewing as it fades is where consolidation happens. Revisiting a notion the next day, then three days later, then a week, beats any cramming.

3. The generation effect

Attempting to solve a problem before seeing the solution improves retention, even when the attempt fails. It's Manu Kapur's productive failure. The failed effort primes the brain to encode the explanation that follows. This is the exact opposite of what AI does, serving you the solution before you've had time to struggle with it. Flip the reflex: struggle for five minutes, then ask.

4. Negative expertise

Learn to say no to the AI's code. The core skill in the age of LLMs is no longer writing code, it's judging what you're handed. Read each suggestion asking "do I accept this, and why?". Hunt for the security flaw, the side effect, the forgotten edge case. Remember that a significant share of generated code contains vulnerabilities. The reviewer's reflex is what separates whoever drives the AI from whoever gets driven by it.

How I build my courses around this

This is exactly the philosophy of Coding with AI and the applied projects: AI cranks out code fast, you read it slowly, you send back precise instructions. Each project shows the real prompts, the shaky first draft, then the review that hardens security, accessibility and contrast. We don't teach delegation, we teach critique. That's negative expertise turned into a habit.

But rereading the research, I saw my own blind spots. My quizzes fire right after the lesson: that tests working memory, not durable memory. My examples often show the solution before the effort. I had no real spaced repetition. So I'm adding: a "predict before you run" in the editor, free-recall questions where you re-explain in your own words, the return of older notions across later lessons, and a teach-back after each exchange with the AI. In short, I'm deliberately injecting the frictions my own courses, too smooth, had sanded away.

Conclusion

The irony of all this is that the tool meant to democratize learning to code can widen the gap between those who already know how to think and those still learning. AI won't turn you into a developer in your place, any more than a calculator makes you a mathematician. It amplifies a reasoning that must already exist.

The real question was never "can AI write this code?". Of course it can. The question is: "after reading it, could I rewrite it alone?". As long as the answer is no, you haven't learned anything, you've only borrowed. And debt, one day, comes due.

Comments (0)