On learning to Program

This essay is dedicated to Joel on Software. And is specifically inspired by Joel's post about: The Perils of JavaSchools

The value of concrete programming (in C)

I learned a lot of what I know about programming from the Operating Systems course I took in college.

What I learned was C (pointers), data structures and algorithms.

I must have learned a bunch of other things, but the most important of them came through using C to design the data structures and then implement the algorithms. And it was always in that order.

You didn't start with the data structures, because you had to implement them yourself and that was hard work. So you would use a data structure because it was the only way to solve the problem. (or at least the easier way)

You didn't start with clever or efficient algorithms because you were marked on functionality and not on performance. You only sat down and thought about the algorithms because you eventually realized that was the only way to make sure your program would work.

And I don't think the benefit is merely pedagogical, it is extremely practical. In my last essay I railed against teaching scheme or lisp as the basic programming language for CS students. What advantage did I gain from doing things in C? I developed abstractions that were a good fit to reality.

In C arrays were easy to program, because memory is a huge contiguous (albeit virtual) array. Linked lists were the next easiest thing, but you could really understand what they were.

The problem with that scheme book was that it forced this great big List abstraction on you. And you didn't really ever understand what it meant. It was magic. And you can't tell from the book where the magic lies. Maybe it's in the parentheses?

The value of a good debugger

I learned the rest of what I know about programming from TA'ing (being a teaching assistant) for the same course (at least twice).

What I learned was very different. I learned to use a debugger, and I learned to explain "broken" code. And I learned how to explain why a certain data structure or algorithm would be better.

To this day when I have debug someone else's C code I reach for the debugger and lo-and-behold I can find the bug quick enough, which to be fair is not always that quick. But at least it's somewhat systematic.

But when working on my own code the debugger is almost the last thing I reach for. I only dust it off when I'm starting to think that the OS is playing tricks on me.

This site best viewed with Lynx or Mozilla or Konqueror or any standards compliant browser!

Valid HTML 4.01! This Site is Powered by vi and Powered by Emacs also. The all-powerful ed has also contributed!.