Teaching Programming Languages with Scala
This semester, I am teaching the undergraduate programming languages course
at SJSU, a required course for CS majors. The course has two objectives:
- To give students significant exposure to a programming paradigm other
- To make students understand the process of translating a high-level
language into machine (or VM) code
The canonical way to meet these objectives is to teach Scheme, and to build
simple interpreters and compilers. It is not the most popular course. Most of
our students just don't think Scheme is all that cool. When I want them to
admire the elegance of closures and continuations, they are still hung up over
style="float: left; margin-right: 1em;" />This semester, I am trying something
new. I am using Scala as my functional language. The syntax is accessible to
the students (they all know Java), and they see Scala mentioned on href="http://dzone.com">dzone.com, so it isn't just something of interest
to a bunch of pointy-headed professors.
In the first few weeks, I am restricting myself to the functional subset of
while, just recursion
- Immutable lists, just with
- The higher-order functions in the
I can do exactly the same as in Scheme, except without the parentheses. Does
it work? I had a few lectures, and here are my initial observations.
- The Scala interpreter is great. Students enjoy the immediate
style="float: right; margin-left: 1em;" />Students need to install the JDK and Scala on their laptops. The worst
part was setting up Java on Windows. If the installer must put the JDK into
Program Files, couldn't it at least add the
directory to the
PATH? It requires superhuman effort to get
the less talented students to edit the system configuration or to deal with
spaces in file names in the command shell.
- The DOS shell still sucks eggs,
just as it has ever since I first saw it in Windows 3.0. The better
students run Linux, Mac OS, or href="http://freemode.net/archives/000121.html">Cygwin with rxvt.
Microsoft sends a powerful signal to budding computer scientists. That
signal is: "We don't give a !@#$ about you!".
- The biggest hangup so far has been the strong typing, somewhat to my
x : Intinstead of
int x, but one
quickly gets used to that. However, typing
append(lst : List[Any], a : Any) : List[Any]
into an interpreter window is no great joy. I expect this will get
better when we move to Eclipse, where the IDE can take advantage of the
/>Interested in following along? Click on the links of
href="http://horstmann.com/sjsu/cs152/schedule.html">this schedule. There
are lab assignments in each lecture. If you need a hint with one of the labs,
leave a blog comment.