April 25, 2009

Teaching Programming

I think there is a lot of debate about how programming should be taught, and I think the debate basically centers on how to teach it to freshmen in college. I say "I think" because I don't really know anything about this. But, it's been my MO lately to talk about things I know nothing about, so eff it.

The complicated thing about this (as I perceive it) is that there don't appear to be only two sides, because there isn't only one issue. There's the issue of functional versus imperative programming style. Then there's a several-way split about historical versus newer versus popular programming languages. It seems there's even a debate about what kinds of programs to begin teaching with.

Well, here are my thoughts. Someday when I have influence we can look back on this and decide it's smart. And by then I will have changed my mind.

Some principals

Agreed: choosing a language based on its historical significance (C++) or its usage in "the field" (Java) is BS. If teaching were about practicing for the real world, high school teachers wouldn't make you read Jane Eyre and write analytical essays on it. Very few people end up actually writing analytical essays about literature for a living.

Granted, it's different in programming. Java is very widely used and lots of languages are similar to C/C++. But I think it's assumed that, if we can figure out how to teach programming well, we can either teach how to write Java/C later or we can depend on the student to pick it up when they need to.

Wait, how is that different? Anyways...

Starting out writing GUIs is ridiculous. That means no making desktop calculators until semester two. It is a waste of time to start out writing GUIs just so students can feel like they are actually doing something cool. You won't be successful in programming unless you think that figuring out how to write a tough function is cool, sorry. And anyways, the time spent writing that calculator is mostly spent learning how to use the particular GUI library you have chosen, which seems like a big waste.

Functional versus imperitive? One, then the other. And it doesn't matter the order, in my opinion. Having a good understanding of loops and having a good understanding of recursion are both really important. I think a really effective programming program (sorry, trying to refrain from saying "computer science program") stresses that recursion and iteration are both commonly-used tools, both simple once you get to know them, and both dangerous in different situations. Of course, it seems the most reasonable way to teach both is to chose one, teach it, and then teach the other with the first in mind.

On object-oriented programming: definitely leave that junk for later. Understanding object-oriented paradigms is obviously important, but for people who are trying to understand for the first time how to make computers do stuff, it's a mind fuck.

Tests on paper. I actually don't think this is debated too heavily, but it's worth saying. At Northeastern, I've realized that writing a program on paper during an exam can only be done if you have learned how to program. More on this later.

My perspective

I have a fairly unique perspective on this issue given my age and lack of time spent in the real (or academic) world. I've had the opportunity to semi-teach some material from Northeastern's CS program, which uses SCHEME and focuses on functional programming to begin with. The first time, I was teaching it to seventh graders after school. Don't ask. The second time, I was tutoring freshmen CS students at Northeastern, grading their homework, and proctoring their lab exercises.

I like Northeastern's program a lot, and it's at least tripled my skill at programming in my first two years. But I had been programming for years before going to college, so learning in SCHEME was both easy for me and really different and interesting. So, I don't know how it felt for newbies (or, how it felt for the newbies after they learned SCHEME and went to try something else).

One thing I learned from watching freshman (a full year younger than me!) and seventh graders writing SCHEME is that new programmers are good at remembering keywords. I don't know how many times I went over to help a student who had written simply (define or in the body of their function (cond (uhm, I'm sure somebody will yell at me for calling those keywords, but you know what I mean). I'm not exactly sure what this keyword-recognition ability means to a programming program, but it exists.

The other thing I learned, as I mentioned before, is that on-paper quizzes and tests are great for teaching programming. Programming homework assignments and projects is supposedly good practice, so fine. But college students cheat. You simply can't write a program down if you don't know how to program. On another level, even for students who don't cheat on homework, getting a program on paper is a different experience than coding it on your computer where you can get in the habit of testing it every fifteen seconds. Paper doesn't compile code (yet).

The Language

I think it's Python.

I swear it's not because it's trendy! It's just the language that best fits how I think programming should be taught.

For one, you can easily teach iteration and recursion in it. Both the functional and imperative programming style come very easily in Python. In fact, I would have chosen Perl were it not for the fact that in Perl you can't pass functions by their exact name. There's no funky syntax involved in Python.

Again, I loved learning SCHEME at Northeastern. But aside from the iteration thing, here's my main beef.

I think that students can pick up programming faster if the syntax they are using is just right. There are too many parenthesis in SCHEME. Sure, it's beautiful to me. But to a first-time programmer, I think it helps to see some colons, some equals signs, and some keywords. Like return, for example.

Python programs can really look any way you want. If you want to start by teaching functional style, do it. If you want to start by teaching iteration, start writing loops. The only thing that Python forces on you is good indentation practices, and I don't think anyone's complaining about that. What better way is there for freshman to learn good style than to program in the most inheritly stylish language out there?

I feel like if my Northeastern professors read this they would probably beat me with a keyboard for not sharing their obsession with SCHEME, and that's fine. They have a great program and I think it's okay for them to defend it (as I've seen several do in heated conversations). All I'm saying is that I think some of my classmates and I could be even better programmers right now if we had begun learning in Python and had learned iteration early on.

Then again, I know nothing about this.

No comments:

Post a Comment