Learning to Program

John R. AndersonIJCAI 1983

Abstract

This paper investigates the cognitive processes involved in learning to program, using LISP as a primary case study. It identifies the "instruction-application gap"—where novices understand rules but fail to apply them—and attributes this to the challenges of knowledge compilation and working memory constraints. Through computational modeling with the GRAPES system, the research demonstrates how mental representations and cognitive load dictate learning efficiency and error rates.

Introduction

Why do novice programmers struggle even after receiving clear instructions? Cognitive scientist John R. Anderson addresses this question by exploring how declarative knowledge is transformed into procedural skill. The study highlights that learning to program is less about syntax memorization and more about "compiling" problem-solving steps into efficient mental operators.

The Instruction-Application Gap

Anderson's observations reveal a significant disparity in how novices spend their time: less than 25% is dedicated to absorbing new knowledge, while over 75% is spent struggling with application. This "instruction-application gap" suggests that the bottleneck is not the acquisition of facts, but the process of turning those facts into actions. The paper examines how the mental "notation" used to conceptualize code affects error rates and how working memory failures lead to seemingly simple mistakes, such as forgetting a parenthesis or a subgoal.

Methodology

The research utilizes a dual approach:

  1. GRAPES (Goal Restricted Adaptive Production System): A production system that simulates human problem-solving by decomposing high-level goals (e.g., "write a function") into smaller, manageable subgoals.
  2. Protocol Analysis and Experiments: The researchers tracked the step-by-step progress of a human subject ("SS") and conducted controlled experiments to test the impact of different notations (e.g., standard list vs. dotted-pair) and varying cognitive loads on student performance.

Knowledge Compilation and Goal Structures

A key finding is the process of "knowledge compilation." When a learner first encounters a problem, they rely on slow, general-purpose reasoning. Upon success, the brain collapses these steps into a specialized operator. This explains the dramatic speedups observed in learners; for instance, the subject "SS" was 6x faster on a second task after the GRAPES model compiled operators from the first.

Figure 2: The goal structure for coding the ADDTWO function, showing the decomposition of the task into subgoals such as finding arguments and checking code.

As illustrated in Figure 2, the programming task is broken down into a hierarchy of goals. The learner must navigate this structure, managing multiple subgoals simultaneously. This decomposition is essential for problem-solving but places a significant burden on the learner's cognitive resources.

Mental Representation and Working Memory

Novices often employ fragile mental models, such as the "parenthesis-moving" trap, where functions like CDR are viewed as physical manipulations of marks on a page rather than logical operations. Such models are highly susceptible to error if a single mental "step" is forgotten.

Furthermore, "working memory spillover" occurs when the cognitive load of managing subgoals exceeds the learner's capacity. In experiments, adding a logically independent step like REVERSE to a task significantly increased errors in unrelated parts of the problem, such as function recognition.

Figure 4: An expanded goal structure illustrating the iterative process of checking code, identifying bugs, and redoing steps to refine the mental model.

Figure 4 demonstrates the complexity of the debugging process. When a "CHECK CODE" operation fails, the learner must localize the error and "REDO" specific subgoals. This iterative cycle is where knowledge compilation is most active, as the learner refines their procedural knowledge based on error feedback.

Key Results

  • Learning Efficiency: The subject "SS" showed a massive speedup after initial task completion, mirroring the "compilation" of mental operators.
  • Notation Impact: The perceived difficulty of functions like CONS was found to be a product of mental representation; changing the teaching notation could reverse the difficulty relative to other functions.
  • Quantitative Memory Load: Function recognition accuracy dropped from 60% to 48% when an extra processing step was added, confirming that working memory is a primary bottleneck.

Conclusion

The study suggests that experts do not necessarily have superior general memory, but rather have developed domain-specific "reliable extensions" of short-term memory. For novices, the challenge lies in managing the high cognitive load of programming subgoals. Future educational tools should be designed to alleviate this load, perhaps by managing subgoals for the student, to facilitate more effective knowledge compilation.

Summary updated

BibTeX
@inproceedings{anderson1983learning,
  author = {John R. Anderson},
  title = {{Learning to Program}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {1983},
}
Figure