Learning to code with AI: what the studies say

Is it still worth learning to code when AI writes the code? A randomized trial, the METR study and the 2026 Stack Overflow survey answer with numbers.

By
Published on

An assistant writes in ten seconds the function that would have taken you an hour. The question follows on its own: why learn to write it yourself? Strong opinions are easy to find, on both sides. Measurements are rarer, and they say more than a plain yes or no.

In short

Yes. In a randomized trial published by Anthropic in January 2026, 52 developers learning a new Python library scored 50% on a quiz when they had worked with an AI assistant, against 67% when they had coded by hand, with the widest gap on debugging. Those who used AI to understand, by asking conceptual questions, did much better than those who had it write the code. And in 2026, 48% of the developers surveyed by Stack Overflow say they trust AI output only when they can easily verify it: to verify, you have to know how to code.

What does Anthropic's randomized trial show?

That learning with an assistant able to write the code for you makes you retain less of what you just did. The study, run by Judy Hanwen Shen and Alex Tamkin and published on January 29, 2026, involved 52 participants, mostly junior developers. All of them had used Python every week for more than a year, had some familiarity with AI assistants, and had never touched Trio, a Python library for asynchronous programming.

Each participant had to build two features with Trio, then take a quiz, knowing it was coming. A random draw decided the group: one had an AI assistant in the sidebar, able to produce correct code on request, and the other coded alone.

Average quiz score after the task
Code written by hand
67 %
Code written with an AI assistant
50 %

Source: Anthropic, randomized trial with 52 developers (January 29, 2026)

A seventeen-point gap, and one that holds up statistically (p = 0.01). On the other side of the ledger, the AI group saved about two minutes on average, too little to be told apart from chance. The quiz mixed code reading, code writing, concepts and debugging, and debugging is where the two groups drifted furthest apart. That's not very surprising: when the AI fixes the errors for you, you get far less practice fixing them yourself. The authors draw a simple idea from it: effort, including being stuck for a while, probably plays a part in learning.

Which ways of using AI worked best?

The ones where AI served to understand rather than to produce. In a qualitative analysis, the researchers sorted the participants in the AI group into six patterns, and the scores split clearly:

How the AI was usedParticipantsAverage quiz score
AI delegation: it writes all the code4below 40%
Progressive AI reliance: a question or two, then hand everything over4below 40%
Iterative AI debugging: it debugs or checks your own code4below 40%
Generation then comprehension: generate the code, then ask questions to understand it265% or higher
Hybrid code-explanation: ask for the code along with explanations365% or higher
Conceptual inquiry: only conceptual questions, fixing your own errors765% or higher

The last group, the largest among the high scorers, was the second fastest of the six, just behind those who delegated everything. Trying to understand didn't make them slow. Keep these numbers in proportion, though: each group has between two and seven people, and the authors themselves state that this part of the analysis does not establish cause and effect. It gives you a lead, not a law.

Does AI make experienced developers faster?

Not necessarily, and above all, they misjudge their own speed. In July 2025, the research organization METR published a trial with 16 experienced developers who had worked for years on large open source projects. On 246 real tasks from their own repositories, randomly assigned to allow AI or not, they took 19% longer when AI was allowed. Before the study, they expected to save 24%. Afterwards, they still believed they had saved 20%.

That result has limits, which METR points out itself: 16 people, tools from early 2025 (mostly Cursor with Claude 3.5 and 3.7 Sonnet), a very specific setting. In February 2026, METR announced that its new experiment could no longer measure the current effect, because many developers now refused to take part, not wanting to work without AI. The organization thinks the speedup is probably larger than in early 2025, while acknowledging that its data gives only very weak evidence of it.

For you as a learner, the lesson lies less in the 19% than in the gap between perception and measurement. If seasoned developers believe they're faster at the very moment they're slowing down, your feeling that you "understand" while reading generated code deserves the same suspicion. An outside measure, such as tests that pass or fail, can't be talked into anything.

What do developers think of AI in 2026?

They use it massively and distrust it at the same time. In 2025, 84% of respondents to the Stack Overflow survey were using or planning to use AI tools in their development process, but 46% distrusted the accuracy of their output, against 33% who trusted it. The most cited frustration, from 66% of them: "AI solutions that are almost right, but not quite". And 45% found that debugging AI-generated code is more time-consuming.

The 2026 edition, published on October 6, 2026 with over 30,000 respondents in 169 countries, asked about trust differently:

Trust in the output of AI tools
When I can easily verify the output
48 %
Many tasks, but not important decisions
16,3 %
Low-risk tasks only
16,3 %
Not for most tasks
12,3 %
Including important decisions
6,6 %

Source: Stack Overflow Developer Survey 2026, 14,304 responses to this question

Nearly one developer in two sets the same condition: being able to verify. An "almost right" answer is exactly the kind of bug a beginner doesn't see: the code compiles, passes the example from the instructions and misses the edge case. Knowing how to code, in 2026, starts with being able to make that call.

How do you learn to code with AI without shortchanging yourself?

By copying what the most successful participants did, and by measuring yourself regularly without help:

  1. Write it on your own first, even a wrong version. Running into trouble with your own code is how you know which question to ask.

  2. Ask for explanations, not solutions. "Why does scanf leave the newline in the buffer?" teaches you something; "write the function for me" teaches you nothing.

  3. If you do have code generated, question it line by line until you could rewrite it without looking. Then rewrite it.

  4. Debug on your own before asking. Read the error message, run gdb(1) or valgrind(1), form a hypothesis. That's the skill where the gap was widest in Anthropic's study.

  5. Test yourself without AI. An exercise graded by tests doesn't judge your impression; it judges what your code does, edge cases included.

The fourth point deserves a concrete example. Faced with a crash, the question "what does this message mean?" teaches you to read a Segmentation fault; pasting the code and asking "fix it" teaches you nothing about the next one. The method for finding the faulty line yourself is in Segmentation fault (core dumped) in C.

C

fix-the-warnings

The starter file doesn't compile: three warnings, turned into errors by -Werror. Silencing them isn't enough, since (void)hi; erases one line of the diagnostic and leaves the tests red: the branch that was supposed to use hi was never written. Do it without an assistant: this is debugging, exactly.

Open the exercise

For a more candid test, challenges draw one exercise per level and give you limited time. Take them without an assistant: that's what makes them an honest measure of what you can do alone, on the day you take them.

Frequently asked questions

Will AI replace developers?

The studies cited here don't answer that question, and no serious measurement can today. They show something more concrete: used to delegate, AI reduces what you learn; and to rely on what it produces, most developers need to be able to verify it.

Can you use ChatGPT or Claude to learn programming?

Yes, as long as you use it like a teacher you ask questions, not like a classmate who does the exercise for you. In Anthropic's study, the participants who only asked conceptual questions got the best scores, without being slower.

Should you turn off AI autocomplete when you're starting out?

During exercises, it's the wiser choice. None of the studies cited measures autocomplete, but a suggestion that finishes the line before you've thought it through looks a lot like delegation, the pattern that produced the worst scores. Keep the assistant in a separate window, for questions.

Are these studies about C?

No. Anthropic's trial used Python and the Trio library, METR's used the participants' own open source projects, and the Stack Overflow survey covers every language. They measure a way of learning and working, not a particular language.

Sources

Now write it yourself.