whats the best cs1 prog language"

This commit is contained in:
Wouter Groeneveld 2023-10-13 11:44:07 +02:00
parent fd5e19acff
commit ae3a272393
1 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,87 @@
---
title: "What's The Best Programming Language For A CS1 Course?"
date: 2023-10-16T09:00:00+02:00
categories:
- education
- programming
tags:
- cs1
- 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**
```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**
```go
func add(one int, two int) *int {
result := one + two
return &result
}
```
Woah, what's that `*`? Not Go, then?
**C++**
```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**
```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](https://spectrum.ieee.org/the-top-programming-languages-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](https://home.adelphi.edu/~siegfried/SIGCSE2019Poster.pdf)"---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.