Culture / Development

What Should Be a Student’s First Programming Language?

4 Jul 2021 6:00am, by

It’s a question that’s fascinated educators for decades. When students first begin to learn computer science — which programming language should they start with?

One person who’s given it a lot of thought is Mark Guzdial, a computer science professor at the University of Michigan who has also conducted his own research in the fields of computer science education. And two different colleagues had recently suggested it didn’t matter which language was taught first to CS students, which got him thinking.

“I have a hypothesis that this belief once was true when the field was younger,” Guzdial wrote in a recently-published piece in Communications of the ACM, the house organ of the Association of Computing Machinery (ACM). But that was back in the late 1960s when the curricula were first being established — while today, students of all ages and experience levels are learning how to program, and they ultimately have different needs.

Different universities still have different answers for the question, reflecting both their teaching philosophies and their sense of which language will prove most important to their graduates in the wider tech industry. But it’s also interesting to note the changes happening over the years, with computer science departments gradually evolving their choices for their students’ crucial first programming language.

Maybe it all gives us our first glimpse at the next generation of programmers — and some clues as to how we’re envisioning our future.

Stanford vs. Harvard

In 2017, Stanford University made headlines with some changes to its introductory computing course for computer science majors. Eric Roberts, a Stanford emeritus professor of computer science, had spent five years working on transitioning the course from Java to JavaScript, according to Stanford’s student newspaper, and he’d finally created a new JavaScript-based pilot version of the course. (So instead of CS106A, the course was named “CS106J.”) The change involved creating a new textbook and assignments, as well as training new teaching assistants, and Roberts himself came out of retirement to teach the class.

Previously Stanford’s introductory classes had been based on the C programming language (and before that, Pascal). Hailing JavaScript as “the language of the internet,” Roberts had helped switch the classes to Java back in 2002, writing textbooks and working with the other faculty to restructure the courses and assignments. But 15 years later, he’d told the student newspaper that “It’s 2017 now, and Java is showing its age.”

Yet if you peek in on their syllabuses today, you’ll find CS106A now appears to be using Python (and the PyCharm IDE), while the CS106B syllabus indicates they’re using C++.

Meanwhile, Harvard University’s own introductory course CS50 has for years stuck with a multilingual approach. In the first week, students actually write a program in Scratch, the block-based visual programming language developed to teach younger learned by MIT Media Lab, before switching over to C — and then switching again in later weeks to Python, and then JavaScript. “Rather than teach just one language, CS50 introduces students to a range of ‘procedural’ programming languages, each of which builds conceptually atop another,” explained the course’s official FAQ.

The explainer continued, “The goal, ultimately, is for students to feel not that they ‘learned how to program in X’ but that they ‘learned how to program.’”

Scratch_Hello_World - by Mberry via Wikipedia (Creative Commons)

But why start them off with C? The class’s instructor, professor David J. Malan, once wrote on Quora that “C is just about as close to a computer’s hardware as you can get before you have assembly language, (which would be too arcane, I think, for an introductory course like CS50). In C, there’s no magic. If you want something to be somewhere in memory, you have to put it there yourself. If you want a hash table, you have to implement it yourself.”

Malan, according to his Quora comments, believes that the weeks of C give students an opportunity to understand some of the fundamental building blocks of all programming languages (while also providing an opportunity to explain the crucial security concept of buffer overflows).

“It’s a powerful thing, too, I think, to go from implementing a hash table (or trie) in C in one week, and then just a week or so later implement the same in just one line of PHP or JavaScript code,” he wrote. And in addition, C is also a relatively small language, so “by mid-semester, students have seen nearly all of it (except for, e.g., unions and function pointers).”

The downside? Malan acknowledged that it might be harder to create engaging problem sets early on than it would be using a higher-level language like Python or Java. Harder, maybe, “But not impossible!”

Yet by 2014 Python was reportedly already the most popular language in introductory courses in America’s top-ranked computer science programs (including MIT and University of California, Berkeley), according to an article in Communications of the ACM. “Specifically, eight of the top 10 CS departments (80%), and 27 of the top 39 (69%), teach Python in introductory CS0 or CS1 courses,” wrote Philip Guo in the publication. Java was still close behind Python at the time (followed by MATLAB, C, C++, and then Scheme and Scratch.)

A program written in Scratch_3.0_GUI (MIT photo - Creative Commons via Wikipedia)

In 2016 three U.K. researchers performed a survey of their own, finding that, in U.K. universities,  Java was used in more than twice as many classes as Python — “despite the fact that Python is perceived, by the same respondents, to be both easier to teach as well as to learn,” the researchers wrote. (One possible explanation the researchers cited is “longstanding industry popularity as measured by community indices.”)

It’s a topic that comes up frequently. One 2019 paper from a trio of University of Winston-Salem State University researchers for the ACM’s Computer Science Education group even argues that every computer science student should also be equipped with “foundational knowledge” in big data and cloud computing, “and to possess some hands-on experience in deploying and managing big data applications in the cloud.”

The paper proposes that rather than separate cloud-computing courses, the material should be integrated into multiple undergraduate computer science courses. It describes the researchers’ own successful experience in creating “modules” to add cloud and big data topics into existing classes.

Not Just Mathematics

What’s taught to beginning programmers still remains an important question, according to the U.K. researchers. “Failure to grasp programming readily almost certainly implies failure to progress in computer science,” their paper argues, noting the question of which language to teach first has thus “been fiercely debated since computer science teaching started in universities.”

Guzdial, the University of Michigan professor, still believes it matters which language we start students with — but he also wants educators to re-examine one formative assumption.

In his ACM article, he recalls a 1979 study that had argued that once a student learns the broader semantic concepts, they can apply them to any subsequent language (needing only to master the relatively easy differences in syntax). But Guzdial points out that, in that era, most computer-science students were traditional college students — who presumably had had more math than, say, liberal arts majors or the K-12 students of today. So, back in the late 1970s, educators may have overestimated the ease of switching programing languages, since they’d ultimately just been teaching programming based on what was already understood about math, where, as Guzdial put it, “a new syntax is just a new formalism for the mathematics.”

The professor added, “We might be able to teach a lot more people about programming if we don’t expect students to know mathematics first, which we may have been able to expect 40+ years ago.”

Photo by Clemens van Lay on Unsplash. 

A newsletter digest of the week’s most important stories & analyses.