Sign In

Communications of the ACM

[email protected]

Teaching Two Programming Languages in the First CS Course


Mark Guzdial

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?

We have a lot of evidence that knowledge of blocks-based programming does transfer to text-based programming. Studies by Chris Hundhausen, Jill Denner, Shuchi Grover, and others point to the ease that students transfer knowledge (e.g., of variables, iteration structures, and conditionals) from graphical, blocks-based languages (like Scratch) to textual languages (like JavaScript, Java, or Python).

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.


Comments


Mark Liffiton

Certainly the specific languages involved make a difference. Prolog, Lisp, and Pascal are all substantially different not just in syntax but in the programming paradigm around which each is built. Block programming and text programming can be done in a single language, with the blocks providing an exact 1-to-1 map to the text syntax.

For whatever it's worth, I've been teaching CS 1 with two languages for nine years. I start in Python and move to Processing (Java) about halfway through. The learning students have done in Python clearly transfers without much trouble. Functions are still functions, loops are still loops, etc. We have to introduce the new concept of declaring types, but almost everything else is just a matter of putting different symbols on the concepts they've already learned. Students are far beyond starting from scratch when we start in Processing.

I can't make any claims that this approach produces better learning outcomes compared to sticking with a single language throughout, as I've not done any formal research. But I can say fairly confidently that transfer occurs readily in my experience and it does not present major difficulties. The approach was motivated by a lot of guesses about the benefits it might provide; if none of them are correct, it doesn't appear to cause any harm, and if any of those guesses are correct, it's a net positive. More research on the idea would be very worthwhile.


CACM Administrator

The following comment/response was submitted by Mark Guzdial on 6 June 2018.
--CACM Administrator

Hi Mark,

If you dont mind me poking a bit, how do you know that all the transfer is positive? Most CS teachers judge teaching innovations by student comments (see Lecia Barkers research: https://computinged.wordpress.com/2015/09/21/a-terrific-and-dismal-view-of-what-influences-cs-faculty-to-adopt-teaching-practices/), which only come from the most vocal students. Student comments arent representative of the whole student body. What evidence might you look for if you suspected that the two language approach wasnt working?

--Mark Guzdial


Displaying all 2 comments