As a tribute in honor of Dennis Ritchie’s passing, I’d like to invite you to share your thoughts in this post’s comments about your first C program – either the code if you remember it approximately, or a story about when you wrote it.

Here’s mine.

I wrote my first C program in 1988 as a lab assignment for a fourth-year course in computer graphics at the University of Waterloo. In the first day or two of the course, our prof gave us our first assignment: Write a program that displays and controls a 3D animated robot with moving head, arms, and legs. Successive assignments would let us swoop around him, controlling point of view and zoom with a mouse, and other nifty features, but the first assignment was just to get him on-screen and capable of a little basic motion.

Oh, and the program was to be written:

to run on one of the lab’s four brand-new SGI IRIS workstations (oh, here’s the manual);

using a custom UofW internal library (oh, here’s the manual);

in C (we assume you know it, use man to learn this compiler’s command line switches if you need to);

and it’s due in a few days. I can’t remember exactly now, but I think we had something like five days. After all, this was just a warm-up initial exercise for the course.

Here’s the thing: I had never used C. Never even seen it.

Oh, I’d used many different languages in my undergrad career, from Cobol to Pascal to Prolog to 6809 assembler and many points between, but just never C. Don’t get the wrong impression, C was already used widely at UofW at the time and most of the other undergrads in the class knew it, but by some freak of course selection combined with professor allocation I somehow had managed to come across pretty much everything but C so far for the first three years.

Fortunately, there was K&R.

Armed with K&R and a printed-out C tutorial, I had a few days to learn a new language (huh? whaddayamean #include? oh, okay…), an unfamiliar compiler, an unfamiliar graphics library, and the quirks of this particular flavor of Unix – to produce a working program in an unfamiliar domain with unfamiliar concepts (graphics). And only that last bit was the actual topic material for the course. The language, compiler, library, etc. was just uninteresting scaffolding you were expected to know or just pick up on the fly, don’t bother the professor with questions about those when you can look it all up yourself.

I don’t remember what mark I got on the assignment, but the code worked.

I was glad that C was easy to learn, and that its manual in the form of K&R was so clear to read and understand. Thanks again, Dennis.