Sunday, March 27, 2011

CMU -= OOP, CMU++;

I should have been a comedian. I have excellent timing.

I applied for Computer Science grad school during the irrationally exuberant dot-com boom, when much of my competition ran off chasing easy money. During the subsequent crash I was already a sheltered student. By the time I finished, the economy was up again. My lucky streak continued as I managed to secure a job before the global financial crisis struck.

However, I’m most thankful that I was amongst the last batch of students of my undegraduate CS program who were only taught object-oriented programming in an optional course.

It wasn’t just my alma mater. According to an interview with a CS professor emeritus at NYU, around that time, many universities bowed to pressure to switch to Java and focus less on fundamentals. This produced less capable programmers, or as the article puts it, “today’s Java-savvy college grad is tomorrow’s pizza-delivery man”. Again, my competition was decimated merely because of timing.

Apart from increased job security, I’m grateful I learned less object-oriented nonsense and more CS, as I’m deeply interested in the subject. In fact, this is why I chose to study CS; I’m just fortunate I happen to live in a time and place where coding is a marketable skill.

Now that I can afford to be less selfish, I wish universities would undo this injustice and remove object-oriented programming from introductory CS curriculums, so future students can benefit, just as Carnegie Mellon University is doing. CMU's decision inspired me to post this entry, and update my page denouncing object-oriented programming.

Business

While some applaud the move, others state that learning a language and programming paradigm rarely seen in industry leaves a student ill-prepared.

My own experience suggests otherwise. I have little trouble coding in new programming languages so long as they’re not too esoteric. Granted, the first few lines are painful, as I’ll have to constantly look up keywords in a reference while acclimatizing to error messages and other peculiarities of the development environment. But after a while, I’ll pick up the syntax for arithmetic, loops, conditionals, function calls, and so on, and that’ll be enough to keep me going. I might miss out on idioms, but I can get my point across.

The difficult part is designing the underlying data structures and algorithms. That’s where CS is most magical. Functional programming gives me an edge. It makes recursion less scary, and recursion is often a great approach to a problem: sorting, parsing, anything with trees. Also, experience with lazy evaluation increases my awareness of parallelism.

I believe it also makes my code cleaner, because treating functions as first-class citizens opens my eyes to design choices I might otherwise miss. It’s hard to say: a Java fanatic might be trained to spot perfect places for anonymous inline classes.

In interviews, I let candidates choose the language as I’m more interested in the idea being expressed. Some candidates write code comfortably, but struggle with relatively simple tasks because they can’t find the right algorithm or data structure. They’re like an author with perfect spelling but who only knows boring stories.

Others quickly find a good solution, but their code may have syntax issues here and there. These mistakes hardly bother me because after a week of seeing the same compiler error messages over and over again, their syntax will be as good as mine.

Personal

Although OOP was optional for me, I studied it with relish. I read “Design Patterns” cover to cover shortly after purchasing it. Bertrand Meyer’s words were gospel. Eiffel, a pure OO language, became my favourite. I promoted OOP more fiercely than I attack it now; back then I was even more obstinate. I believed the only path to virtues such as modularity, information hiding, and code reuse was through OOP, partly because I thought OOP folks invented these concepts.

Over the years, events caused me to pause and reexamine what I had been taught. Many lines of code later, I finally discarded OOP and freed myself. I felt cheated, which is why I’m more emotionally attached to this stuff than one might expect.

There’s no harm in learning OOP as long as you avoid my mistake and arm yourself with a healthy dose of skepticism (which you should do all the time anyway, including now).