Uncovering principles of novice programming

It is widely known that programming, even at a simple level, is a difficult activity to learn. Why is this so? Are novice difficulties really inherent in programming or are they related, to the nature of the programming tools currently given to novices? To answer this question we have used novice Pascal computer programs collected from their terminal sessions, controlled clinical studies focusing on specific aspects of novice programming techniques, and video-taped interviews of novice programming [Bonar, 1982]. In each we focused on bugs and buggy programs. Bugs and errors illuminate what a novice is actually thinking -- providing us a window on the difficulties as they are experienced by the novice.In previous reports we presented evidence that current programming languages do not accurately reflect the cognitive strategies used by novice programmers [Soloway et al, 1981]. Instead, we have found that novice programmers possess knowledge about and experience with step-by-step specifications in natural language. This knowledge and experience gives them powerful intuitions for using a programming language. Programming languages, however, are, not designed to appeal to these intuitions. On a semantic and pragmatic level, there are incompatibilities between the way, natural and programming languages are used. Many novice programming bugs can be directly traced to an inappropriate use of natural language specification style or strategy.As an example of these incompatibility bugs consider the "while demon" bug. Novices with this bug assume that the actions in the body of the while loop are continuously monitored for the exit condition to become true. This interpretation is consistent with the English language usage of the word while: e.g."while the highway is two lanes, continue, north". In an earlier written study [Soloway et al, 1981] found that 34% of the students in an introductory programming course thought the test in a Pascal while loop was performed, as a demon. Furthermore, a later interview study showed that novices could even describe the implementation mechanism for such a demon:"… everytime I [the variable tested in the while condition] is assigned a new value, the machine needs to check that value …"In this report we describe our use of video-taped interview studies for understanding how novices use a programming system. Interviews provide valuable information not available through statistical analysis of written studies. Written studies allow us to manipulate specific factors and guage the results to performance or style. Furthermore, we can have statistical confidence in those results. An interview study, on the other hand, allows us to examine the source of performance or style differences uncovered. Interviews give us an "execution trace" while written studies give us the final output. We use both kinds of studies, depending on the kind of information needed.We have interviewed seventeen novice programmers. Four were interviewed regularly for the first 8-10 weeks of their introductory programming course. For these regular subjects we have about 15 hours of interviews tracing their learning and maturation through the course.In this report we show an example natural language specification and discuss strategies used in that specification. We then discuss two examples of novice programming difficulties stemming from an inappropriate use of natural language specification strategies. These examples are illustrated with video tape transcripts. We conclude with a brief discussion of the implications of this work.