Sep 22

Should a Computer Science Degree Require Learning C?

Just to add to the discussion started by Bijan and picked up by Marco:

The first programming language I learned was Logo. Being seven at the time, I had no idea I was using a functional language. I didn’t care what was going on under the hood—I just liked being able to write programs that turned my Apple II screen into a phosphorescent spirograph.

Over the next ten years I programmed in BASIC, VisualBasic, JavaScript, C, a little bit of C++, and Java. I thought that the differences between languages were just syntax.

Once I started taking college-level CS courses, I began to get the differences between languages. I was in over my head taking an Artificial Intelligence course as a freshman, and using Java didn’t make writing A* search any easier than using C. But when the professor told us to write a program to simulate how a robot might rearrange stacks of alphabet blocks, and told us to use a funny little logic programming language called CLIPS, suddenly everything was easy! I could represent the world with rules and facts, and I didn’t need to worry about pointers or objects because they didn’t mean anything in a world where everything was an alphabet block. The only things that mattered in this world were concepts like “move” and “on-top-of.”

That was my first exposure to a situation where matching the language to the problem made a huge difference. Yes, I could have written the program in C. But it would have taken ten times the effort to get the same result.

Over the course of four years, I was introduced to functional and logic programming. I programmed in machine code. Yes, machine code—I spent a week flipping DIP switches with the tip of my pen, implementing multiplication and division algorithms in the Z80 instruction set. I’m not a good programmer simply because I learned C. Yes, some of my courses happened to use C, but it was learning about computation at all different levels of abstraction that really made me a good programmer.

My computer science professors weren’t teaching specific languages, they were teaching different ways of thinking about problems. Now, if I’m writing for speed and efficiency, I use C. If I want to do rapid prototyping, I use Python or Java. And if I’m building a simple embedded system, I might not use a programming language at all, I might just burn state transition tables into an EPROM.

We need to be careful not to dictate which languages to learn. Why should someone learn C instead of Pascal? Who gets to say it’s better to teach Lisp than SML? If the answer to why we should be teaching C is, “it was good enough for me so it’s good enough for you and here’s a nickel, kid, buy yourself a real computer,” we need to seriously ask ourselves where the new ideas in computer science are going to come from.

While the trend of dropping C in favor of Java or (shudder) C# is turning some schools into nothing more than flavor-of-the-month clubs, requiring one specific low-level language is no better. Sure, if I had to chose a single language that would teach students as much about computation as possible, it would be C. But the best computer science programs teach concepts, not languages. Graduates need to understand pointers, recursion, automata, regular languages, and computational complexity, and this is best done by exposing students to a number of different languages that excel at each of those concepts.