(Coursenotes for CSC 313 Teaching Computing)

Learning a Second Programming Language

[1] Understanding Conceptual Transfer for Students Learning New Programming Languages by Ethel Tshukudu and Quintin Cutts

Prior work on PL transfer focuses on transfer of problem-solving strategies as experts transition from one language to the next. But we don’t know much about how PL transfer happens during code comprehension.

We’ve previously talked about how students can face difficulties transitioning from blocks-based languages to text-based languages. We have some empirical evidence for the types of programming constructs (loops, conditionals, etc.) that might trouble them, but this empirical evidence doesn’t give us much in the way of a predictive theory of how this transfer takes place and is helped or hindered. Having such a predictive theory can give us clues about the cognitive difficulties that we should pre-empt while teaching a second or third programming language.

These papers propose and evaluate such a theory of transfer of knowledge between programming languages.

Mindshift learning theory (MLT)

Learning a second natural language

We know from fMRI studies that programming languages and natural languages are related; they activate the syntactic and semantic regions of the brain. These papers draw on this relationship.

Similarity relations between languages

Learning a second programming language

The paper suggests that knowledge of a programming language is organised into a network of interconnected knowledge structures. These knowledge structures are:

Notice that items #1 and #2 above are making a distinction between two skills: being able to read (trace) programming language syntax, and being able to understand the purpose of that syntax from a higher level. This hearkens back to the idea that introductory programming skills ought to be separated and sequenced.

Semantic transfer between PL1 and PL2

The figure below, reproduced from Dr. Tshukudu’s paper, depicts a theoretical model of a student’s understanding of a first programming language (PL1), and what their understanding might look like after an “ideal learning process” in which they learn an additional programming language (PL2).

The conceptual level depicts a programming concept, and the semantic level depicts “how it works” in the programming language. For example, in the figure on the left, a concept might be “conditional logic”. But there are multiple options for realising this same concept, that work slightly differently (for example, switch statements and if-else ladders). Finally, those constructs certainly look different from each other syntactically.

A model of PL transfer (reproduced from [1]).

After the “ideal learning process” in which the student learns PL2, the student is correctly able to:

With the above optimistic eventualities in mind, we can think about relationships between constructs in the two programming languages as follows:

Totally new (conceptually, semantically, and syntactically novel) constructs in the second PL will appear as brand new strands, unrelated to any known concepts.

An example of knowledge transfer between PL1 and PL2 (reproduced from [1]).

The figure above shows:

Of course, this is just a theory. But is this actually what happens? The authors tested it out.

Think about the first two programming languages you learned. For many of you, this will have been two quarters of Python followed by Java. What aspects of this model hold for you? What doesn’t hold?

How does this theory hold up?

The authors conducted two studies. First, for constructs in Python and Java, they labelled them as TCCs, FCCs, or ATCCs. Then, they recruited students with knowledge in one language and gave them some instruction and assessment in the second language.

They tested these hypotheses.

Study 1: Python → Java

Results largely hold up.

Predictions largely held up in study 1. (Reproduced from [1])

Example of inappropriate semantic transfer:

# This doesn't work in Python
print("Friday is no: " + 1)
// Participants expected this to not work in Java
System.out.println("Friday is no: " + 1);

Study 2: Java → Python (IT students; exposure to Java the prior semester; non-CS undergraduate degrees; more advanced level of learning Python than the Study 1 participants were at learning Java)

Results kind of hold up.

Predictions kind of held up in study 2, but not as strongly as in 1. (Reproduced from [1].)

It appears that transfer from Java to Python was easier than transfer from Python to Java. Why do you suppose this is?

  1. Note that the figure omits issues of negative transfer from other domains that might interfer with learning PL1 itself. This model is specifically focused on knowledge transfer from PL1 to PL2, not on the initial learning of PL1 itself.