brainbaking/content/post/2023/10/whats-the-best-programming-...

4.9 KiB

title date categories tags
What's The Best Programming Language For A CS1 Course? 2023-10-15T21:50:00+02:00
education
programming
cs1
programming languages
c++
java
python

That's a good question! CS1 courses, or Computer Science 1, are typically the first computing courses in higher education where students are exposed to a programming language. They traditionally teach concepts such as variables and scoping, control blocks, code flow, and some, like in our own faculty, even immediately introduce object-oriented programming. Whether or not that's a smart move is another matter.

For every single language, there are odd features and easy problems that are hard to explain to newcomers, and simply hiding these has backfired often:

Python

def add(one, two):
  result = one + two
print(result)
  return result

add("1", "2")

Error: Unexpected indent. Upon fixing that, the result is "12". Woah? Not Python, then?

Go

func add(one int, two int) *int {
  result := one + two
  return &result
}

Woah, what's that *? Not Go, then?

C++

template<typename T> class Thing {
private:
  T x, y;
public:
    friend ostream& operator<<(ostream& os, Thing t);
}

Woah, what's the difference between a template and proper inheritance? Hey, diamond inheritance works here, Good Luck Have Fun? Not C++, then?

Kotlin

class Calc(val one: Int, val two: Int) {
  init { println("oncreate") }
  fun add(): Int {
    return one + two
  }
}

Once you realize this is just Java: Woah, not Kotlin, then? And so forth.


What's the solution here, then? According to Tew and Guzdial, sidestep the problem by developing a FCS1 (Foundational CS1) language-agnostic test instrument. This means it doesn't matter, as long as the basic features in introductory courses as tested by FCS1 are present. That feels a bit cheap to me, as I've seen students trip over certain languages more easily than others, meaning the choice of the language still matters.

Siegfried et al. analyzed current programming language trends in CS1 and CS2 courses. Guess what, Java and Python are the most popular choices. More shockingly, perhaps: is that in 88% of the surveyed schools, they only ever teach Java, Python, C++ and C---with the adoption of Python growing steadily at the expense of the other languages. For CS2, that's typically an object-oriented heavy course, Java is the most popular, closely followed by C++.

That's a recent study of 2021, of which out of 409 schools, only 2 use JavaScript or Scala, 1 uses C# or Haskell, and 6 use Racket/Scheme. Completely absent languages that are present in IEEE Spectrum's Top Languages of 2023: Go, TypeScript, PHP, Ruby, Swift, Rust, Kotlin.

The Spectrum's top 5 is Python, Java, C++, C, JavaScript, which apart from JS neatly overlaps with Siegfried's findings. This is not to say that academia should follow the whims of the ever-changing preferences in industry, but I'm a bit surprised by the low adoption rate of Go. Then again, to get to know Go well, you should really know C, and for our operating systems courses, it still makes sense to reach for C instead of Go.

In 2001, in a report called CS1: Perspectives on Programming Languages and the Breadth-First Approach by Close et al., the authors look back at the adoption rates of languages from Fortran to Java and beyond. It's funny to read these by now ancient perspectives:

The C++ craze, however, may have been short-lived. The emergence of the Internet must be acknowledged and reflected in our courses. Recent conferences have produced an impressive number of papers on the use of Java at the introductory level. C++ is often represented as a better C. In that sense, Java may be viewed as a (slightly) simpler version of C++. While its overall utility for Internet programming may be somewhat specious, Java does project the aura of modern practice and with the implication that jobs may be available for the cognoscenti.

According to them, Pascal is didactically speaking the soundest language, but it became unfashionable due to the C++ emergence, and the explosion of the World Wide Web caused Java to rapidly grow in popularity as well. Funny, as I have the feeling that in 2023, the web and Java are trying very hard not to know each other.

The evolution towards Python is also visible in the "Reid List"---Richard Reid who tracked programming language usage in computing courses in the early nineties which was kept alive by colleagues up to 2015. In 2011: Java (50%) #1, C++ (21%) #2, Python (11%) #3. In 2015: Java (46%) #1, Python (20%) #2, C++ (19%) #3. The trend watchers also note the apparent movement both away from Java and to Java. I guess the order doesn't really matter?

Perhaps Java and Python are still the most sensible choices.