(Coursenotes for CSC 313 Teaching Computing)

Learning a Second Programming Language

đź“– Readings

[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)

  • Carryover concept: concept with similar meaning in the old and new contexts (PLs)
  • Changed concept: concept is similar to a known concept but has a different meaning in the new context (PL)
  • Novel concept: concept not already known to the learner

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

  • Similarity relation: item or pattern in L2 is perceived as similar to a form or pattern in L1. For example, mine (English) and mein (German)
  • Contrast relation: Underlying similarities between items, but important differences. For example, lecturer (English) and lektura (reading; Polish).
  • Zero relation: Little-to-no perceptible relation between an item in L1 and L2. For example, talk (English) and rozmowa (talk in Polish)

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:

  • Syntax level: Knowledge of the syntax of a known programming language. For example, int mark = 4;
  • Semantic level: The “meaning” of the syntax. For example, the variable mark is being declared as an integer and initialised to 4.
  • Conceptual level: Higher-level concepts known by the programmer. For example, variable introduction.

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

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

The paper suggests in the Prior Level, there’s no branching between the syntactic and semantic level. But this is an idealised notion—recall that there can be issues of transfer between the learner’s prior knowledge from other domains with similar tokens or notation (e.g., math). This conceptualisation largely ignores those issues, focusing only knowledge of a programming language.

When learning the second language, relationships between concepts in the two languages are formed.

  • True carryover construct (TCC): Similar syntax and same underlying semantics in PL1 and PL2. (E.g., a while loop in Python and Java)
  • False carryover construct (FCC): Similar syntax, but different semantics. Negative transfer! (E.g., integer division in Python and Java).
  • Abstract true carryover construct (ATCC): different syntax by same semantics. (E.g., objects in Java are kind of like dict in Python).1

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]).

How does this affect PL knowledge transfer?

The authors make three predictions:

  1. When a TCC is encountered (i.e., a concept which has similar syntax and semantics in PL1 and PL2), the learner correctly perceives the similarity between the concept in the two languages. Positive knowledge transfer takes place.
  2. When a FCC is encountered (i.e., a concept which has similar syntax, but different semantics in PL1 and PL2), the learner incorrectly perceives that there is a similarity between the concept’s semantics in the two languages. That is, the learner thinks this is a TCC. Negative knowledge transfer takes place.
  3. When an ATCC is encountered (i.e., a concept with similar semantics but different syntax in PL1 and PL2), the differing syntax between PL1 and PL2 masks the concept’s similar semantics from the learner, and they fail to transfer that understanding from PL1 to PL2. They therefore perceive the ATCC as a totally new concept. No knowledge transfer takes place.

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?


  • H1: No difference in quiz scores for concepts involving TCC between PL1 and PL2
  • H2: PL2 scores will be lower for concepts involving FCC between PL1 and PL2
  • H3: PL2 scores will be lower for concepts involving ATCC between PL1 and PL2

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. I’m a bit skeptical of this example for ATCC. But maybe with the introduction of Records in Java, this example holds a bit better. A better example might be the map function in, say, JavaScript, and list comprehensions in Python.