I read an interesting article the other day about how CS is taught in school now.   The article basically argues that you can’t learn real computer science skills in Java.  Without debating his attitude towards the Java language itself (and by extension, the C# language), I thought I’d take a moment to write some thoughts regarding the article.

I went to Rice University, and while I don’t think it is exactly what he describes so disparagingly as a “Java School,” Java was the primary language that I used while there.  At Rice, the introductory programming course is taught in Scheme; computer organization is taught in some combination of C and SPARC assembly; programming languages and compilers are taught in some combination of C, Java, and Scheme; of course, operating systems is taught in C; however, intermediate programming, algorithms and data structures, and most software engineering courses are taught in Java (some of the newer ones in C#, but the two are effectively the same for the purposes of this discussion).  Oddly enough, I knew almost nothing about C++ until my summer internship after junior year, where I spent the entire summer getting a painful crash course in how C++ programming is not like Java programming.  But I digress.

You’ll note a preponderance of non-Java languages in that laundry list of courses and languages, and I think that’s important to have.  It is important for computer scientists to be able to write real code in C, using pointers and hacking bits for all they’re worth, because there is a lot of real-world code that needs that level of control.  It’s equally important for computer scientists to be able to think about programs at a functional level:  functional programs teach you the important lesson that code and data are really the same thing.  So what, then, are we even doing teaching people silly object-oriented languages like C# and Java?

In my opinion, we are teaching those languages precisely because they are “easier.”  It’s easier to express your intent in a good OO language than it is in C.  You gain the powerful abstraction of classes, which, in addition to the usual yadda yadda about polymorphism and various OO patterns, come with nearly everything you wanted from functional closures (though I won’t claim that you get the same elegance and power as Lisp/Scheme macros—but OO vs. Scheme as a language of choice is not the topic today).  Thanks to the managed environment, you don’t have to worry about corrupting some random part of memory or blowing your stack to smithereens, nor do you have to allocate memory with careful precision so that you can remember to free it later.  You have all the tools you need to write your code while decreasing the overhead involved.

I think he’s right that Java isn’t the be-all and end-all of computer science (neither is C#, much as I’d love to claim that it is).  He’s absolutely right that the sort of “mental flexibility you get from learning about” pointers and functional programming makes you a better programmer in any language.  Still, he has a certain elitism about his article that rubs me the wrong way.  I think I understand pointers, but I wouldn’t want the fact that I hate working with C-style linked lists to keep me out of a job that itself required no C programming.  Even if CS departments at universities should be training their students for real programming, they shouldn’t have a responsibility to “weed out” students who can’t grasp the entirety of Scheme in a single day.

In the end, I suppose that you do have to understand pointers because all of your programs run on real computers with code that, somewhere underneath, is using those pointers.  Despite having to understand them, I don’t think anyone should be required to like them.