The Role of Working Memory in Program Tracing
Open accessThe DOI matches its Crossref record; 35 of the 36 references it cites were found in a registry or an index.
Abstract
Program tracing, or mentally simulating a program on concrete inputs, is an important part of general program comprehension. Programs involve many kinds of virtual state that must be held in memory, such as variable/value pairs and a call stack. In this work, we examine the influence of short-term working memory (WM) on a person’s ability to remember program state during tracing. We first confirm that previous findings in cognitive psychology transfer to the programming domain: people can keep about 7 variable/value pairs in WM, and people will accidentally swap associations between variables due to WM load. We use a restricted focus viewing interface to further analyze the strategies people use to trace through programs, and the relationship of tracing strategy to WM. Given a straight-line program, we find half of our participants traced a program from the top-down line-by-line (linearly), and the other half start at the bottom and trace upward based on data dependencies (on-demand). Participants with an on-demand strategy made more WM errors while tracing straight-line code than with a linear strategy, but the two strategies contained an equal number of WM errors when tracing code with functions. We conclude with the implications of these findings for the design of programming tools: first, programs should be analyzed to identify and refactor human-memory-intensive sections of code. Second, programming environments should interactively visualize variable metadata to reduce WM load in accordance with a person’s tracing strategy. Third, tools for program comprehension should enable externalizing program state while tracing.
Overview
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Integrity signals
Registry
Cites
Statistics
Verification
Claims the paper makes
The claims and statistics of this paper haven’t been checked yet.
Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.
Self-check
Percentages, sums and reported differences re-computed from the paper’s own numbers.
The self-check needs the paper’s full text.
Citations
Cites
The magical number seven, plus or minus two: Some limits on our capacity for processing information.
Miller, G. A. (1994) · Psychological Review · doi:10.1037/0033-295x.101.2.343 · Cited by 17,161
Hutchins, E. (1995) · doi:10.7551/mitpress/1881.001.0001 · Cited by 10,801 · cited 1×
“Consistent with the theory of distributed cognition [18], code comprehension tools should consider how to enable programmers to externalize their thought process to the environment without needing to print out code.”
BackgroundThe magical number 4 in short-term memory: A reconsideration of mental storage capacity
Cowan, N. (2001) · Behavioral and Brain Sciences · doi:10.1017/s0140525x01003922 · Cited by 6,779 · cited 1×
“The universal limitations of WM have been studied since the early days of cognitive psychology [23]: WM has a capacity of roughly 4 ± 1 chunks [9], and chunks are forgotten”
BackgroundCousot, P., & Cousot, R. (1977) · Proceedings of the 4th ACM SIGACT-SIGPLAN symposium on Principles of programming languages - POPL '77 · doi:10.1145/512950.512973 · Cited by 6,279 · cited 2×
“We focused on tracing with concrete inputs and outputs, but one can imagine tracing over symbolic values, akin to the method of abstract interpretation in static analysis [8].”
MethodIncreasing Transparency Through a Multiverse Analysis
Steegen, S., Tuerlinckx, F., Gelman, A., & Vanpaemel, W. (2016) · Perspectives on Psychological Science · doi:10.1177/1745691616658637 · Cited by 1,372 · cited 1×
“This number was selected by inspecting the noise in the data, but in the spirit of multiverse analysis [30] we confrmed that all signifcant results still hold with p < 0.”
MethodThe Case for Motor Involvement in Perceiving Conspecifics.
Wilson, M., & Knoblich, G. (2005) · Psychological Bulletin · doi:10.1037/0033-2909.131.3.460 · Cited by 818 · cited 1×
“However, cognitive psychologists have repeatedly demonstrated the close relationship between action and understanding in comprehension of language [28] and gestures [34].”
BackgroundMemory updating in working memory: The role of the central executive
Morris, N., & Jones, D. M. (1990) · British Journal of Psychology · doi:10.1111/j.2044-8295.1990.tb02349.x · Cited by 734 · cited 1×
“The cognitive action of updating WM in a running memory task is coordinated by central executive WM [24], therefore we hypothesize that participants should have a lower efective WM capacity for variable/value pairs than in the prior experiment.”
ResultCognitive dimensions of notations
Green, T. R. G. (1990) · Cited by 645
Do people use language production to make predictions during comprehension?
Pickering, M. J., & Garrod, S. (2007) · Trends in Cognitive Sciences · doi:10.1016/j.tics.2006.12.002 · Cited by 642 · cited 1×
“However, cognitive psychologists have repeatedly demonstrated the close relationship between action and understanding in comprehension of language [28] and gestures [34].”
BackgroundProgram comprehension during software maintenance and evolution
Von Mayrhauser, A., & Vans, A. M. (1995) · Computer · doi:10.1109/2.402076 · Cited by 575 · cited 2×
“However, most popular models of program comprehension focus largely on schemata/plans as a mechanism of comprehension, e.g. the seven models in the survey of von Mayrhauser and Vans[33].”
MethodThe role of working memory in mental arithmetic
DeStefano, D., & LeFevre, J. (2004) · European Journal of Cognitive Psychology · doi:10.1080/09541440244000328 · Cited by 543
Benchmarks for models of short-term and working memory.
Oberauer, K., Lewandowsky, S., Awh, E., Brown, G. D. A., Conway, A., Cowan, N., Donkin, C., Farrell, S., Hitch, G. J., Hurlstone, M. J., et al. (2018) · Psychological Bulletin · doi:10.1037/bul0000153 · Cited by 447 · cited 1×
“from WM as a function of time and interference [26].”
BackgroundThe role of short-term working memory in mental arithmetic
Hitch, G. J. (1978) · Cognitive Psychology · doi:10.1016/0010-0285(78)90002-6 · Cited by 421 · cited 5×
“Graham Hitch[17] first found in 1978 that a working memory analysis of mental arithmetic could explain many observed calculation errors.”
BackgroundMethodInfluentialThe Lean Theorem Prover (System Description)
de Moura, L., Kong, S., Avigad, J., van Doorn, F., & von Raumer, J. (2015) · Lecture Notes in Computer Science · doi:10.1007/978-3-319-21401-6_26 · Cited by 416 · cited 1×
“For example, the Lean interactive theorem prover [10] in Emacs (Figure 14, left) will show all the variables in scope at the current line based on the editor’s mouse position.”
BackgroundRelationships between reading, tracing and writing skills in introductory programming
Lopez, M., Whalley, J., Robbins, P., & Lister, R. (2008) · Proceedings of the Fourth international Workshop on Computing Education Research · doi:10.1145/1404520.1404531 · Cited by 363 · cited 1×
“Students who could correctly trace programs performed better on program comprehension questions [21, 22].”
BackgroundSeparate roles for executive and phonological components of working memory in mental arithmetic
FÜrst, A. J., & Hitch, G. J. (2000) · Memory & Cognition · doi:10.3758/bf03198412 · Cited by 344 · cited 2×
“So next, we consider: how does WM capacity for variable/value pairs change when interleaved with mental arithmetic? Within the multi-component model of WM [4], prior work has found that three-digit mental arithmetic interferes with simultaneous tasks that use central executive WM, but not phonological WM [14].”
BackgroundCognitive processes in program comprehension
Letovsky, S. (1987) · Journal of Systems and Software · doi:10.1016/0164-1212(87)90032-x · Cited by 327 · cited 1×
“Expert programmers use tracing to understand code when its structure is not similar to a previously observed pattern (schema) [12, 20].”
BackgroundNotional machines and introductory programming education
Sorva, J. (2013) · ACM Transactions on Computing Education · doi:10.1145/2483710.2483713 · Cited by 319
A representational analysis of numeration systems
Zhang, J., & Norman, D. A. (1995) · Cognition · doi:10.1016/0010-0277(95)00674-3 · Cited by 229 · cited 2×
“Zhang and Norman[35] use a representational analysis to justify why Arabic numerals are an ideal number representation for performing mental multiplication.”
BackgroundEye Movements in Code Reading: Relaxing the Linear Order
Busjahn, T., Bednarik, R., Begel, A., Crosby, M., Paterson, J. H., Schulte, C., Sharif, B., & Tamm, S. (2015) · 2015 IEEE 23rd International Conference on Program Comprehension · doi:10.1109/icpc.2015.36 · Cited by 176 · cited 2×
“[6] found that the gaze path of expert programmers was more similar to following control fow from top-to-bottom than to reading line-byline like a book.”
BackgroundCode bubbles: a working set-based interface for code understanding and maintenance
Bragdon, A., Zeleznik, R., Reiss, S. P., Karumuri, S., Cheung, W., Kaplan, J., Coleman, C., Adeputra, F., & LaViola, J. J. (2010) · Proceedings of the SIGCHI Conference on Human Factors in Computing Systems · doi:10.1145/1753326.1753706 · Cited by 174 · cited 9×
“For example, if a person tries to remember x = [1, 5, 7], the list is a more complex object to be stored in WM than a single digit.”
BackgroundMethodInfluentialSystematic Mathematical Errors and Cognitive Load
Ayres, P. (2001) · Contemporary Educational Psychology · doi:10.1006/ceps.2000.1051 · Cited by 165
Retrieval processes in recognition and cued recall.
Nobel, P. A., & Shiffrin, R. M. (2001) · Journal of Experimental Psychology Learning Memory and Cognition · doi:10.1037//0278-7393.27.2.384 · Cited by 133 · cited 3×
“For the frst question, our hypothesis is that participants should hold about 5 variable/value pairs in WM, consistent with prior work on cued recall in paired-associate learning [25, 31].”
BackgroundMethodResultNovice LISP Errors: Undetected Losses of Information from Working Memory
Anderson, J. R., & Jeffries, R. (1985) · Human–Computer Interaction · doi:10.1207/s15327051hci0102_2 · Cited by 131 · cited 3×
“• Students solving basic Lisp programming problems make more errors attributable to working memory when the problem uses a more deeply nested expression [1].”
BackgroundLister, R., Fidge, C., & Teague, D. (2009) · Proceedings of the 14th annual ACM SIGCSE conference on Innovation and technology in computer science education · doi:10.1145/1562877.1562930 · Cited by 118 · cited 1×
“Students who could correctly trace programs performed better on program comprehension questions [21, 22].”
BackgroundEye Movements in Code Reading: Relaxing the Linear Order
Busjahn, T., Bednarik, R., Begel, A., Crosby, M. E., Paterson, J. H., Schulte, C., Sharif, B., & Tamm, S. (2016) · Cited by 111
An empirically-derived control structure for the process of program understanding
Détienne, F., & Soloway, E. M. (1990) · International Journal of Man-Machine Studies · doi:10.1016/s0020-7373(05)80122-1 · Cited by 102 · cited 1×
“Expert programmers use tracing to understand code when its structure is not similar to a previously observed pattern (schema) [12, 20].”
BackgroundLocus of Difficulty in Multistage Mathematics Problems
Ayres, P., & Sweller, J. (1990) · The American Journal of Psychology · doi:10.2307/1423141 · Cited by 65 · cited 1×
““to compute angle X, that’s 180 - Y, so now I compute Y”) make errors most commonly within sub-goal stages where WM load is highest [2].”
BackgroundLister, R., Fidge, C., & Teague, D. (2009) · ACM SIGCSE Bulletin · doi:10.1145/1595496.1562930 · Cited by 62
A tool for tracking visual attention: The Restricted Focus Viewer
Jansen, A. R., Blackwell, A. F., & Marriott, K. (2003) · Behavior Research Methods, Instruments, & Computers · doi:10.3758/bf03195497 · Cited by 62
What Drives the Reading Order of Programmers? An Eye Tracking Study
Peitek, N., Siegmund, J., & Apel, S. (2020) · International Conference on Program Comprehension · doi:10.1145/3387904.3389279 · Cited by 61 · cited 1×
“[27] further found that more linear programs (e.”
BackgroundFactors in novice programmers' poor tracing skills
Vainio, V., & Sajaniemi, J. (2007) · Proceedings of the 12th annual SIGCSE conference on Innovation and technology in computer science education · doi:10.1145/1268784.1268853 · Cited by 58 · cited 5×
“• The top-left and top-center participants with the linear strategy traced linearly in the set of binary operations, but looked up constant values on-demand (consistent with Vainio and Sajaniemi [32]).”
BackgroundInfluentialAge-related declines in working-memory skills: Evidence from a complex calculation task.
Campbell, J. I., & Charness, N. (1990) · Developmental Psychology · doi:10.1037//0012-1649.26.6.879 · Cited by 55 · cited 8×
“Consistent with Campbell and Charness[7], we found that over half of mistakes can be attributed to substitution in WM. Specifically, errors could be explained by accidentally swapping the association between variables in WM, as opposed to forgetting them entirely.”
BackgroundMethodInfluentialExamining variation in working memory capacity and retrieval in cued recall
Unsworth, N. (2009) · Memory · doi:10.1080/09658210902802959 · Cited by 46 · cited 2×
“For the frst question, our hypothesis is that participants should hold about 5 variable/value pairs in WM, consistent with prior work on cued recall in paired-associate learning [25, 31].”
BackgroundResultFactors in novice programmers' poor tracing skills
Vainio, V., & Sajaniemi, J. (2007) · ACM SIGCSE Bulletin · doi:10.1145/1269900.1268853 · Cited by 39
Research works printed but not linked: 1
- [4] Alan Baddeley. 2010. Working memory. Current biology 20, 4 (2010), R136-R140. -
Cited by
Prather, J., Reeves, B. N., Denny, P., Becker, B. A., Leinonen, J., Luxton-Reilly, A., Powell, G., Finnie-Ansley, J., & Santos, E. A. (2024) · ACM Transactions on Computer-Human Interaction · doi:10.1145/3617367 · Cited by 256
“One example of a programming activity that includes both the cognitive and metacognitive aspects is code tracing with concrete inputs, something constrained to working memory [28].”
BackgroundCrossCode: Multi-level Visualization of Program Execution
Hayatpur, D., Wigdor, D., & Xia, H. (2023) · CHI Conference on Human Factors in Computing Systems · doi:10.1145/3544548.3581390 · Cited by 43
“…the effects of tracing on working memory, Crichton et al. found two primary strategies: linear tracing following the control flow from the beginning to the end, or on-demand tracing, starting from the end with variables of interest and tracing back through the code that affected the variable [12].”
BackgroundBlocklyVR: Exploring Block-based Programming in Virtual Reality
Hedlund, M., Jonsson, A., Bogdan, C., Meixner, G., Ekblom‐Bak, E., & Matviienko, A. (2023) · International Conference on Mobile and Ubiquitous Multimedia (MUM) · doi:10.1145/3626705.3627779 · Cited by 28
RustViz: Interactively Visualizing Ownership and Borrowing
Almeida, M., Cole, G., Du, K., Luo, G., Pan, S., Pan, Y., Qiu, K., Reddy, V., Zhang, H., Zhu, Y., et al. (2022) · IEEE Symposium on Visual Languages and Human-Centric Computing (VL/HCC) · doi:10.1109/vl/hcc53370.2022.9833121 · Cited by 12
“Based on the studies above, we identified the key challenge: the user must learn to mentally simulate the logic of the borrow checker, which is known to be challenging [17–19].”
BackgroundBarriers in Front-End Web Development
Samudio, D. I., & LaToza, T. D. (2022) · IEEE Symposium on Visual Languages and Human-Centric Computing (VL/HCC) · doi:10.1109/vl/hcc53370.2022.9833127 · Cited by 12
“Previous studies have shown that developers struggle recognizing the concepts they commonly use [36], and remembering vast amounts of details as they determine the behavior of their code [46].”
Background
Metadata
- Authors
- Crichton, W., Agrawala, M., & Hanrahan, P.
- Affiliations
- Stanford University (US)
- Venue
- Proceedings of the 2021 CHI Conference on Human Factors in Computing Systems
- Publisher
- ACM
- Published
- 2021-05-06
- Pages
- 1-13
- OpenAlex
- W3124089355
- Cited by
- 13
- References
- 36
- Citations by year
- 2026: 1 · 2024: 2 · 2023: 5 · 2022: 3 · 2021: 2
- FWCI
- 2.49
- Type
- conference paper
- Language
- en
- Open access
- green
- arxiv.org
- Locations
- CHI Conference on Human Factors in Computing Systems (publishedVersion)
- arXiv (Cornell University) (submittedVersion)
- arXiv (Cornell University)
- Topics
- Physical Sciences › Computer Science › Information Systems › Software Engineering Research
- Physical Sciences › Computer Science › Computer Science Applications › Teaching and Learning Programming
- Physical Sciences › Computer Science › Computer Graphics and Computer-Aided Design › Data Visualization and Analytics
- Keywords
- program tracing, working memory, program comprehension, short-term memory capacity, data dependencies, call stack, programming environment design
About these checks
Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.
Statistics and arithmetic are recomputed, not judged.
Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.
What counts as a claim ›How we measure confidence ›How we check this ›
Are you an author, or do you see a problem with this page? Request a review
Data sources
Bibliographic data: Semantic Scholar, OpenAlex, Crossref.
Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).
Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.