A colleague recently asked me, "What do we know about teaching two programming languages in the first computer science course? Does using more than one language help students to learn the concepts rather than the language?"
A "course" can’t be easily operationally defined, so let’s consider some variations of the questions. When should we teach a second programming language to students? Is it worthwhile to teach the second language sooner? Does teaching a second language sooner lead to better learning, transfer, or development of abstractions?
John Anderson’s group at CMU has done the most-cited work on transfer between textual programming languages. They studied transfer between Lisp, Prolog, and Pascal. Anderson wrote a summary report that is available here. Here’s the paragraph summary of the whole report:
The general picture that has emerged from this research is one in which programming skill is to be conceived as translation from one surface representation to another. While the successful student will have this surface representation annotated with a rich representation of its functionality, the skill is still quite specific to the notational details of the representations involved. Thus, we do not see transfer of coding skills among programming languages. On the other hand, these representations have a common functionalities involving things like variables, list structures, and iteration. An initial understanding of these functionalities and the natural language terms for describing them is something that can transfer among programming languages.
It’s hard for a novice to move from one programming language to another. Student knowledge of programming tends to be tied to the specific programming language and the textual details of that language ("surface representation"). Yes, students can transfer between programming languages the levels beyond syntax, e.g., students can transfer knowledge of algorithms and of how to plan programs. But first, they have to develop that other knowledge ("rich representation of its functionality"), but the reality is that that richer representation is hard to develop. Wu and Anderson found a lot of transfer at the planning/algorithm levels in their studies of programmers moving between languages, but only with experienced programmers, not students.
My colleague, Ashok Goel, has a model of design knowledge called Structure-Behavior-Function (SBF). Students get syntax (structure) pretty easily, and do learn how a particular design achieves a particular goal (function), but an understanding how code actually works to achieve that goal (behavior) is learned last. (See a discussion of the model applied to learning programming here.)
There aren’t a lot of studies of transfer between programming languages, so my answers to those questions are based on how I interpret the results I see in the literature.
- Student knowledge of programming is tightly tied to the syntax of their first language. You can teach concepts separate from the programming, but that doesn’t necessarily help with transfer. Knowledge of concepts like variables and lists will transfer, but only once they have that knowledge.
- Students are going to successfully transfer from one programming language to another only once they have developed deep understanding of the first programming language. By "deep understanding," I mean all the way down to the behavior level and includes the planning and algorithmic levels. That takes longer than most of us realize, and usually longer than a single semester class (see the 2013 replication of the McCracken Working Group study)
- If you move between languages too soon, students just struggle with the different syntax elements, and the switch may actually delay their development of the deeper levels of understanding.
Most of the modern work on these questions looks at modality. Does knowledge of blocks-based programming transfer to text-based programming? Which is better for starting out programming? What leads to the most conceptual learning, blocks-based or text-based programming?
My favorite study on these questions is by David Weintrop. His dissertation (found here) gives the big message in the first two words of his title "Modality Matters." Students learn more/faster with blocks than text languages. In his study, he had three conditions: text-first programming, blocks-first programming, and a hybrid kind of programming where students could move between blocks and text. Each of the three groups were different for the first five weeks of his study, then they all did text programming from there.
Here’s a key graph from his dissertation:
What we see is that blocks and hybrid students perform better on a measure of conceptual understanding after the initial five weeks. But then all three groups do the same at the end.
But here’s the part that’s interesting — notice the slopes between the initial, mid-term, and final assessments. The blocks-based group actually makes less progress when they move to text. (They may actually backslide a bit.) The text-based group has regular, steady progress throughout. Might the blocks-based group have learned even more if they’d stayed in blocks? Is there an advantage to making steady progress, rather than making students switch languages? I don’t know, but it is clear that there’s a cost in switching programming languages.
My answer to my colleague is that we don’t know enough about what happens to student learning when they switch programming languages. Transfer is hard to make happen, but it happens more often and more easily when students learn the first programming language well. There is likely a cost to student development when students switch to a new language. Teaching the conceptual material, and not the language, doesn’t help if you want students to actually learn to program. At some point, they have to learn the language.