President Obama talks about teaching everyone to code. This professor does it.

On Monday, President Obama kicked off computer science education week, encouraging every young person to acquire computer programming skills, even if they have no intention of becoming a software engineer. Someone who shares the president’s vision of universal computer science…

On Monday, President Obama kicked off computer science education week, encouraging every young person to acquire computer programming skills, even if they have no intention of becoming a software engineer.
Someone who shares the president’s vision of universal computer science education is Bob Sedgewick, the lead professor of Princeton University’s introductory computer science course, COS 126. I was a teaching assistant for the course in the 2009-10 school year, and at that time it was already one of the largest courses on campus, with about 200 students each semester. Since then, enrollment in the course has doubled; today, about 60 percent of students take the course.
Sedgewick believes that computer science should be considered a fundamental part of a modern curriculum, not only at Ivy League colleges, but in high schools across the country. When I reached him by phone Tuesday afternoon, Sedgewick had just completed the last lecture of the course for the fall semester. He told me about his vision for computer science education, how he has put that vision into practice at Princeton, and how he plans to make more computer science education materials available to students and teachers around the world. The transcript has been edited for length and clarity.
Bob Sedgewick (Bob Sedgewick)
Timothy B. Lee: What makes COS 126 different from other introductory computer science courses?
A typical course teaches people a lot of details about a particular programming language. There are a lot of toy problems to exhibit features of the programming languages. It’s usually fairly abstract.
We need a college course in computer science that can stand on its own along with courses in chemistry, biology, economics. I set out to create such a course. We teach everything in the context of scientific or commercial applications. We don’t do games; we don’t do hacker culture. Everything we teach students can see the importance. Maybe it’s a simulation of something from science or search for patterns in genomic data. Every example is a real example.
We also spend the last half of the course talking about the big ideas of computer science, which are some of the big ideas of the 20th Century: computability, intractability and universality are hugely important. Just as in introductory courses in biology, chemistry and physics, they teach the big ideas of those disciplines, that’s what we do.
That’s pretty rare in computer science courses around the country nowadays. There’s more of a tendency to make it seem easy, to make it seem like a game. My experience, now that we’ve gone in depth the other direction is that students like it because it’s hard, because it’s interesting, we get at the heart of the matter.
One of students’ favorite assignments in COS 126 asks students to write programs to produce complex graphical designs. The assignment teaches students about the principle of recursion. This image, of a single line that fills 2-dimensional space, was created by Xufan Zhang, who took COS 126 in the fall of 2010. (Xufan Zhang)
It might make sense for many Princeton undergraduates to take a computer science course. But is this really something that every student needs to, and can, learn?
[People used to talk about teaching the basics,] reading, writing, and arithmetic. Now it’s reading, writing and computing. Understanding computation is essential to understanding properties in the natural world. Being able to understand a computer effectively is essential to almost any endeavor nowadays — art, music, economics, science. Our students know that.
If you look at 18-year-olds today, they were 12 when the iPhone was introduced. They’ve been using pretty sophisticated computers all their lives. They all had laptops at home their whole lives. So they can see that they need to have a good grounding in computation before taking on really anything. That’s a huge change, I’d say, over a decade.
We have a lot of older faculty who are not grounded in computation who are a little confused about what goes on. I think these kids are going to blow right by them.
Can you give me some examples of how a grounding in computer science can be useful for someone who isn’t looking for a job at Facebook?
There are lots of examples in the sciences. The entire field of genomics started out as professors who don’t code looking for coders to do the work for them. And now it’s young scientists who are grounded in computer science who are working at the cutting edge, solving problems. If you look at any young professor in genomics, there’s your example. The next thing is going to be neuroscience. You’re not going to get anywhere in that field unless you’re really well-grounded in computer science.
And though I’m not bringing this up as the most important thing, but a lot of people are doing hedge funds and derivatives trading, some of Princeton’s best math majors are doing that kind of work.
And then there’s music and art. You can see it all over the place. Lots and lots of students that never would have contemplated using a computer actually finding that the computer is the way to fulfill their ambitions.
You think computer science shouldn’t just be taught at the college level, but at the high school level, too. But don’t you think this kind of material will go over the heads of many high school students?
That’s not right. Right now, the typical secondary school curriculum has three years of math, three years of science. Pretty much all of that stuff is as advanced or more advanced than computer science. If you were to take a half a year of math and half a year of science and give the secondary curriculum a year of CS instead, particularly integrated with math and science, you could have secondary students integrating CS into math and science and benefiting everybody.
The sooner they get the basic grounding, the more effectively they’ll be able to apply it. All these disciplines are trying to apply computation in a quick way, spending time with computation, but it’s wasted because it would be better to give students the firm grounding.
So sure, I’m talking about incoming Princeton students, but they’re 18-year-olds, they’re from all over. A lot of them are here because of their interest in the arts or sports or whatever. They’re all different, we get them all through. We don’t spend a lot of time with them. If you take the same material, give it to a secondary student every day, with all the online aids, it’s definitely not advanced compared to biology, physics and math.
What are the barriers to better high school education in computer science?
I think the biggest problem is the AP computer science course, which is really a teach-to-the-test kind of course. And students come in and they really didn’t get much benefit from that course.
Then there’s the problem of a trained teacher. All of these kids [who take COS 126 at Princeton], whatever they’re majoring in, are going to be qualified to teach CS. So if we can pump out hundreds and hundreds of kids a year qualified to teach CS, then there’s some hope to get CS properly injected into secondary schools. We’ll have our online content available, and then qualified teachers can take students in secondary schools through it. We’re already starting to see that. I think that’s something that’s just going to accelerate in a few years.
Kids want to learn it, they know they can learn it, a lot of them will go online to learn it. We have to find ways to make it [more accessible].
What about online education? Can people learn the material in COS 126 at their own pace?
Lots of people around the world do. We get millions of hits a year in our online material. The only thing that’s not there yet is videos of the lectures. And we’re just about ready to go into production on that. Our intent is to keep all this stuff freely available.
There’s a huge amount of material there. Our lecture slides are available, our problem sets. There’s code, lots of code, thousands of programs, data, there’s examples, there’s links to historical material, and other Web materials. Tens of thousands of pages.