How are novices' mental models of variable storage affected by programming language choices? Most Intro to CS teachers (I think) do not delve with breadth and depth into details of how variable names are tied to data and datatype. As a result, some students create pieces of their own mental model of how the computer is storing these variable names, data, and data type.
What mental models of memory storage in general (and for sequences in particular) are typical in students who learn Python first vs. students who learn another language first- one that treats arrays more like C does?
Background
Several single-university studies (e.g. Jayal et al. 2015) have found that a post-secondary sequence that starts out with Python and then transitions to Java performs as well as a sequence that starts in Java. Another question asks how to optimize that transition.
Python has particular elements that do not correspond well to Java, however. Negative indices (with which a=[1, 2, 4, 6]
means that a[-1]
is 6
) and slices (with which a[1:3]
is [2, 4]
) are commonly found in code students stumble upon on the Internet, making it somewhat useful to mention these language features when teaching about lists and strings.
Python's native types don't include a type in which pointer arithmetic can be exploited for speed, though the numpy
library offers an array. I suspect that when students learn about Java arrays, they probably build a mental model that fairly closely matches how arrays are stored in memory in C. Python does not actually store lists in a sequence of equally sized memory blocks; [3, 'a', 5.2]
is a perfectly valid list.
Does the mixed-type sequence or slicing or negative indexing in Python change a student's initial mental model for lists, arrays, and other sequences?