{"id":86622,"date":"2024-03-25T14:25:56","date_gmt":"2024-03-25T14:25:56","guid":{"rendered":"https:\/\/www.raspberrypi.org\/?p=86622"},"modified":"2024-03-25T14:25:56","modified_gmt":"2024-03-25T14:25:56","slug":"using-an-ai-code-generator-with-school-age-beginner-programmers","status":"publish","type":"post","link":"https:\/\/www.raspberrypi.org\/blog\/using-an-ai-code-generator-with-school-age-beginner-programmers\/","title":{"rendered":"Using an AI code generator with school-age beginner programmers"},"content":{"rendered":"\n

AI models for general-purpose programming, such as OpenAI Codex<\/a>, which powers the AI pair programming tool GitHub Copilot<\/a>, have the potential to significantly impact how we teach and learn programming. <\/p>\n\n\n

\n
\"Learner<\/figure>\n<\/div>\n\n\n

The basis of these tools is a ‘natural language to code’ approach, also called natural language programming. This allows users to generate code using a simple text-based prompt, such as \u201cWrite a simple Python script for a number guessing game\u201d. Programming-specific AI models are trained on vast quantities of text data, including GitHub repositories, to enable users to quickly solve coding problems using natural language. <\/p>\n\n\n\n

As a computing educator, you might ask what the potential is for using these tools in your classroom. In our latest research seminar, Majeed Kazemitabaar (University of Toronto) shared his work in developing AI-assisted coding tools to support students during Python programming tasks.<\/p>\n\n\n\n

\"\"\/
Evaluating the benefits of natural language programming<\/figcaption><\/figure>\n\n\n\n

Majeed argued that natural language programming can enable students to focus on the problem-solving aspects of computing, and support them in fixing and debugging their code. However, he cautioned that students might become overdependent on the use of \u2018AI assistants\u2019 and that they might not understand what code is being outputted. Nonetheless, Majeed and colleagues were interested in exploring the impact of these code generators on students who are starting to learn programming.<\/p>\n\n\n\n

Using AI code generators to support novice programmers<\/strong><\/h2>\n\n\n\n

In one study<\/a>, the team Majeed works in investigated whether students\u2019 task and learning performance was affected by an AI code generator. They split 69 students (aged 10\u201317) into two groups: one group used a code generator in an environment, Coding Steps<\/a>, that enabled log data to be captured, and the other group did not use the code generator.<\/p>\n\n\n

\n
\"A<\/figure>\n<\/div>\n\n\n

Learners who used the code generator completed significantly more authoring tasks \u2014 where students manually write all of the code \u2014 and spent less time completing them, as well as generating significantly more correct solutions. In multiple choice questions and modifying tasks \u2014 where students were asked to modify a working program \u2014 students performed similarly whether they had access to the code generator or not.\u00a0<\/p>\n\n\n\n

A test was administered a week later to check the groups’ performance, and both groups did similarly well. However, the \u2018code generator\u2019 group made significantly more errors in authoring tasks where no starter code was given. <\/p>\n\n\n\n

Majeed\u2019s team concluded that using the code generator significantly increased the completion rate of tasks and student performance (i.e. correctness) when authoring code, and that using code generators did not lead to decreased performance when manually modifying code. <\/p>\n\n\n\n

Finally, students in the code generator group reported feeling less stressed and more eager to continue programming at the end of the study.<\/p>\n\n\n\n

\"\"\/
Student perceptions when (not) using AI code generators<\/figcaption><\/figure>\n\n\n\n

Understanding how novices use AI code generators<\/strong><\/h2>\n\n\n\n

In a related study<\/a>, Majeed and his colleagues investigated how novice programmers used the code generator and whether this usage impacted their learning. Working with data from 33 learners (aged 11\u201317), they analysed 45 tasks completed by students to understand:<\/p>\n\n\n\n

    \n
  1. The context in which the code generator was used<\/li>\n\n\n\n
  2. What learners asked for<\/li>\n\n\n\n
  3. How prompts were written<\/li>\n\n\n\n
  4. The nature of the outputted code<\/li>\n\n\n\n
  5. How learners used the outputted code <\/li>\n<\/ol>\n\n\n\n

    Their analysis found that students used the code generator for the majority of task attempts (74% of cases) with far fewer tasks attempted without the code generator (26%). Of the task attempts made using the code generator, 61% involved a single prompt while only 8% involved decomposition of the task into multiple prompts for the code generator to solve subgoals; 25% used a hybrid approach \u2014 that is, some subgoal solutions being AI-generated and others manually written.<\/p>\n\n\n\n

    In a comparison of students against their post-test evaluation scores, there were positive though not statistically significant trends for students who used a hybrid approach (see the image below). Conversely, negative though not statistically significant trends were found for students who used a single prompt approach.<\/p>\n\n\n\n

    \"\"\/
    A positive correlation between hybrid programming and post-test scores<\/figcaption><\/figure>\n\n\n\n

    Though not statistically significant, these results suggest that the students who actively engaged with tasks \u2014 i.e. generating some subgoal solutions, manually writing others, and debugging their own written code \u2014 performed better in coding tasks.<\/p>\n\n\n\n

    Majeed concluded that while the data showed evidence of self-regulation, such as students writing code manually or adding to AI-generated code, students frequently used the output from single prompts in their solutions, indicating an over-reliance on the output of AI code generators.<\/p>\n\n\n\n

    He suggested that teachers should support novice programmers to write better quality prompts to produce better code.  <\/p>\n\n\n\n

    If you want to learn more, you can watch Majeed’s seminar: <\/p>\n\n\n\n

    \n