Teaching Intro to Programming

So I’m on leave now, officially, but that doesn’t mean I won’t be working. I’m probably going to start teaching the intro to programming courses at my institution and, me being me, I’ve already started planning for how to do that. Why? Because even before I decided to go on leave I’d started writing my own book for the subject. I worry that seems arrogant, but I’ve looked at a number of intro to programming books and I don’t really like most of them? Basically, I want to emphasize the fundamental algebraic nature of programming and teach not just a particular language but also explain how to learn programming languages in general by way of understanding both syntax and semantics. I’m probably going to take an approach of explaining small step operational semantics without ever actually saying that’s what I’m doing. I want to emphasize that with any program you can in principle evaluate it all by hand. Now, that’s not exactly feasible for anything non-trivial but it’s a perspective that can help when learning to program. When I was first learning to code, I felt like most introductory resources made programming feel like a form of incantation. You appease the Divine Computation by using particular patterns of supplication to get the kinds of results you want and, if your prayers don’t work, you really don’t have the skills to figure out why.

I really want to try and explain, in a principled way, how every syntactic construct can be evaluated by hand and thus how to predict accurately what any piece of code is doing. I’m planning to do all of this in Python since, despite my PL-nerd ways, I want to pick a language that has a lot of local traction and, thus, community and job opportunities. Since Python isn’t referentially transparent it’s a little harder to explain how to think in terms of an operational semantics, but I have this whole approach that I used over this past summer of having the students draw out a table of values based on

  • all the variables in scope
  • the line number

and filling it out as you attempt to evaluate the program. We can introduce iterative constructs through loop unrolling forms, give functions by substitution, etc. I know that Python doesn’t have a formal semantics, but we can at least give something close enough for intuition.

Of course, that’s not all I want to try and explain in a three quarter intro sequence. I really want to explain how to read code, how to write code by figuring out the invariants that should hold and how to classify the types of variables even in an untyped language, and how to test and debug code. One of the skills that I think is important to learn is how to read a library’s, often sparse, documentation, look at the code, and thus learn how it works.

It’s going to take a couple of months to pull together a rough draft of this, but I’m planning on making it extremely example and exercise driven and I’m hoping to get a chance to refine it by having students use it once I’m back from leave.


One thought on “Teaching Intro to Programming

  1. Book idea sounds really interesting. I just (days ago) picked up a copy of How to Design Programs, by Felleisen, Findler, Flatt, and Krishnamurthi. I haven’t read it yet, but it seems similarly intentioned.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s