AI for teachers

Why Teach Programming If AI Writes the Code? What Still Matters, with a Rubric and a Debugging Exercise

Cover "Why teach programming if AI writes the code? What still matters" with a card: +48% in practice and −17% on the exam without AI with an unrestricted assistant; a tutor with safeguards had no loss.

A tenth grader hands in a program that works perfectly. You ask how they did it and they answer: "I asked the AI." You ask them to change one line and they do not know where to start. What used to be a sign of learning (the program works) no longer is. And the question many teachers ask under their breath: why teach programming if a machine writes the code?

This article proposes an evidence-based answer: programming is still thinking, and what must change is how it is taught and assessed. It includes a downloadable Excel rubric (in Spanish) to assess understanding (not just whether the code runs), an AI-use log and a debugging exercise with code that looks right, tested with automated tests. Data verified on October 9, 2026.

Summary. The available evidence says AI speeds up programming tasks, but used without limits it can create an illusion of progress: in a study with about 1,000 secondary students, those who practiced with an unrestricted assistant improved during practice and did worse on an exam without AI. That is why teaching shifts toward understanding the problem, testing, debugging and explaining, and assessment toward process and understanding, with AI use declared. These are specific studies with limitations: they give signals, not laws.

What the evidence says (with its limits)

  • Help that can harm (Bastani et al., 2024). In a randomized trial with about 1,000 secondary students in Turkey (grade 9 to 11 math), those who practiced with a ChatGPT-like assistant ("GPT Base") performed 48% better during practice but 17% worse on the exam without AI than the control group. Those who used a tutor designed with safeguards (with the solutions and teacher notes, and instructions not to give the answer) performed 127% better in practice and had no loss on the exam compared with the control. It is a 2024 preprint and about math, not programming; but it shows the mechanism: using the tool as a crutch.
  • Help that speeds up (Peng et al., 2023). In an experiment with contracted programmers, those who had GitHub Copilot finished a scoped task (an HTTP server in JavaScript) 55.8% faster (a very wide confidence interval, from 21% to 89%). It measures speed on a task, not learning.
  • Help that deceives (Prather et al., ICER 2024). In a lab study with 21 students from a first programming course, 20 finished the problem with AI; but among the 10 who struggled, 9 reached the solution with AI and most believed they understood more than they did: the tool gave them an illusion of progress. It is a small, exploratory study. Students who already knew what they wanted to write used AI to speed up and discarded bad suggestions.
Four cards with the evidence: an unrestricted assistant improved practice by 48% and worsened the exam without AI by 17%; Copilot made a task 55.8% faster; 20 of 21 novices finished with AI though some believed they understood more than they did; and a tutor with safeguards had no loss.
AI speeds things up but can also create an illusion of progress.

The combined reading: AI benefits those who already understand and can harm those who do not yet, and a tutor with limits (one that guides instead of solving) mitigates the harm. Which tells us what to do in the classroom.

What changes and what still matters

Two columns: what changes in teaching programming with AI, such as syntax moving to the background and assessing the process, and what still matters: understanding the problem, breaking down and designing, testing and debugging and explaining why it works.
Programming is still thinking.

Writing syntax moves to the background; what rises in value is:

  1. Understanding the problem: inputs, outputs, constraints, edge cases. An AI responds to what you ask, and asking well requires understanding.
  2. Breaking down and designing: splitting a big problem into steps, which no syntax replaces.
  3. Testing: if you cannot say how you would know the code works, you cannot verify what an AI hands you.
  4. Debugging and reading other people's code: much of real work will be reviewing what someone else, or a machine, wrote.
  5. Explaining: if you can explain why it works, you understand it.

An exercise: the code that looks right

This is the kind of activity that develops those skills. An AI generated this function to compute the median of a class's grades:

def mediana(valores):
    ordenados = sorted(valores)
    n = len(ordenados)
    return ordenados[n // 2]

It works with the first examples tried (with an odd number of data points). But it has deeper flaws. I wrote six tests and ran them:

$ python -m unittest pruebas_mediana -v
test_cantidad_impar ... ok
test_un_solo_valor ... ok
test_no_modifica_la_lista_original ... ok
test_cantidad_par ... FAIL     AssertionError: 3 != 2.5
test_par_sin_ordenar ... FAIL  AssertionError: 3.0 != 2.5
test_lista_vacia ... ERROR     IndexError: list index out of range

Ran 6 tests: FAILED (failures=2, errors=1)

The student's task: run the tests, explain why each fails and fix the function without changing the tests. The errors are typical of code generated without judgment: with an even number of data points, the median must be the average of the two middle values (here it returns the upper middle one); and with an empty list it raises an unclear error instead of one that explains the problem. This is the solution (also included, commented, in the kit), with which all six tests pass:

def mediana(valores):
    if not valores:
        raise ValueError("La lista no puede estar vacía")
    ordenados = sorted(valores)
    n = len(ordenados)
    medio = n // 2
    if n % 2 == 1:
        return ordenados[medio]
    return (ordenados[medio - 1] + ordenados[medio]) / 2

Notice what the exercise demands of the student: reading tests, reasoning about edge cases, locating the cause and justifying the fix. None of those tasks is solved by pasting the prompt into an AI without understanding it. And if they use it, the log asks them to say what they verified.

The rubric: assess understanding, not just results

If you grade only that the program works, you are grading the tool. The workbook's rubric (four levels per criterion, with editable weights) changes the focus:

CriterionSuggested weightWhat evidence it looks at
Understanding the problem15%Inputs, outputs, constraints and edge cases
Design and decomposition15%Plan, functions, justification
Correctness and tests20%Tests of typical and edge cases
Debugging15%Locating and explaining errors
Explanation and understanding (oral defense)20%Explaining and modifying a line live
Responsible use of AI10%Log: what they asked, verified and changed
Readability and good practices5%Names, structure, comments

The workbook computes the score (with every criterion at level 3, for example, it gives 75/100, equivalent to 4.0 on a linear 1-to-5 scale, which you must adapt to your school's assessment system) and warns if the weights do not add up to 100. It also has the AI-use log and a sheet of AI-proof tasks: tracing code by hand, debugging given code, writing tests first, modifying live, explaining a line and programming without assistants in class. Consistent with the idea that assessment should measure learning and not compliance (see what grades measure) and with the institutional AI policy.

How to organize the classes

  1. Start without AI on the basics (variables, conditions, loops): they need the fluency to judge what an AI proposes.
  2. Introduce AI with limits: as a tutor that asks and explains, not as a provider of solutions; a tutor with safeguards is what mitigated the harm in Bastani's study.
  3. Teach how to ask well and to read critically: exercises on debugging generated code.
  4. Assess at two moments: a piece of work with declared AI use and a short test without AI (or an oral defense) that verifies understanding.
  5. Measure whether it works: compare with and without the strategy (see the four-week test).

Colombia, Latin America and the world

Worldwide, the discussion takes place in universities and in schools with computing curricula; several reports from the computing education community argue that AI forces a rethink of what is assessed and how. In Colombia and Latin America, programming instruction in schools is very uneven: some institutions have labs and projects, and many lack enough equipment or technology teachers with specific training. For technology and computer science teachers, the challenge is to assess understanding with large groups (short oral defenses and tests without AI help); for principals, defining clear rules (see pedagogical autonomy and platforms); for students, understanding that learning to program is learning to reason, and for families, that a program that works is not always a sign of learning.

Tools for the teacher

To plan the activities and produce short tests (on paper, without AI) with their solutions, the AI Exam Generator delivers the material for you to review, and the AI Kit for Teachers has recipes for planning.

Keep reading: does AI expand or replace student thinking? and schools' technology debt.

Frequently asked questions

Should AI be banned in programming classes?

Not necessarily. The evidence suggests that without limits it can harm learning, and that with design (a tutor that guides, a log, assessment of understanding) it can help. Define allowed, conditional and not-authorized uses.

How do I know whether the student understood or just copied?

Ask them to explain and modify their code live, trace an example by hand or debug given code. Those who understand can do it; those who just copied can hardly do so.

Is learning syntax still necessary?

Yes, enough to read, judge and fix the code you get, from AI or from another person. Basic fluency allows you to detect errors.

Which language should be taught?

One that lets you focus on reasoning: many schools use Python or visual blocks at the start. What matters is understanding, not the tool.

How do I assess large groups?

Combine short tests without AI, rubrics with evidence (tests, log) and oral defenses by sampling.

Try it in your class. Download the rubric (in Spanish) and the debugging exercise (with its tests and the solution) and apply them with a group.

Food for thought

If a machine can write the program, perhaps what we truly taught when teaching programming was always something else: how to formulate problems, how to doubt answers and how to explain oneself. Is school ready to assess that, or will we keep rewarding programs that work without asking who understood them? And if AI helps those who already understand a lot and those who do not very little, are we widening the gap between students when we put the tool in every hand?

Was this article helpful?

React and share it with someone who might find it useful.

Press and hold to choose another reaction

Be the first to react

Prefer to have it ready?

More guides in AI and technology for teachers

Use ↑ ↓ to move, Enter to open and Esc to close.