Sunday, January 9, 2011

Is programming the new math?

This past semester I taught a programming elective for seniors We used Python because it's already installed on all of the school computers and we have a resident Python expert who I could turn to for support.To be honest, I didn't have very much programming experience before the class began. I had taken a C class in grad school when I was too sick of math to care about my research, and that's the only formal programming I had done. This summer I taught myself some Python using this fantastic book by Michael Dawson, which teaches the basics through programming games. By the end of the summer, I knew enough to plan the first couple of months of class. I was unsure of my own programming abilities, let alone my ability to teach programming.

When all is said and done, this may have been my favorite class this semester. It turns out that programming is just so much fun that students can't help but get engaged, which is a far cry from what usually happens in math class. Sure, we can make math fun with activities, and once in a while you hit upon a topic or a problem that kids are naturally drawn to. But much of the time I would loosely equate teaching math with pulling teeth, and programming couldn't be more different.

There was certainly a learning curve to my teaching. I'll spare you the messy details and cut to the chase:

I learned to minimize lectures. Kids (and all people) learn programming by doing. Giving them a few examples to follow and execute on their own is much more effective than parsing code as a class in lecture format (at least with my group, which tended to get squirrelly really quickly).

When I did lecture, I used PowerPoints that the students could upload onto their laptops so they could follow along at their own pace. I also tried to include as many opportunities as possible for them to try out commands along the way. I finally started getting the hang of this when we were doing Visual Python; see my lecture notes here if you are interested.

Tiered programming assignments rock. There are easy, medium, and hard programs in a single assignment. Students choose whichever ones they want and aim for a certain total point value. Harder programs are worth more points. See my programming assignments here if you are interested.

Something that became obvious very quickly (and was integral in quelling my fears that I was under-qualified to teach a UC-approved programming class) is that almost every student in the class was into it. This was bizarre, having a class where 25 out of 27 students were really trying to figure out a problem and would literally groan when I told them they had to shut down their computers at the end of class. This shouldn't have been a surprise; I also find myself so engrossed in programming that I don't even notice that several hours have passed. I guess I forget that students are just like us - they like things that are inherently interesting, and dislike things that aren't.

Programming is great - it's hands-on, there's the "wow" factor (even early on, when kids can add up all the numbers from 1 to 1000 in a second!), and most importantly there's an element of immediate gratification. Oftentimes with math there's this fuzzy feeling students have when solving a problem ... ["Am I doing this right?" / "Do you think you're doing it right?" / "I thought so, but it looks really weird."] or ["Is this the right answer?" / "Looks like it!" / "Oh, so that's it?"] ... of course there are exceptional problems whose answers are so beautiful as to be undoubtedly correct, even from students' perspectives, but for the most part students struggle with knowing whether they are on the right track and whether they have solved a problem. In programming, there is no such ambiguity. They are "right" when their program does what it's supposed to do, and they can check their steps along the way simply by executing their code.

Moreover - and this is risky for me to say, because if this sentiment went viral I'd no longer have a job - it seems pointless to be teaching kids math en masse when we could be teaching them more programming instead. Our "justification" for making kids suffer through 12 years of math when most of them will never "use" math beyond algebra (of course this is a gross oversimplification. Statistics, for example, should and could be used by everyone and it's not clear whether this comes "before" or "after" algebra ... Despite what the state standards would have you believe, there is no total ordering on the set of math concepts) is that in enhances their quantitative thinking skills, teaches them creativity, and gives them experience solving difficult problems using out-of-the-box thinking. I buy that, I really do. I love math and I've seen the amazingness that happens when students collaborate on a challenging math problem. However, this can be a rarity in the math classroom. So much time is spent on skills that some find interesting and some find worthy of eye-gouging, yet whatever you believe you have to admit that fewer than 1% (an admittedly unfounded estimate) of adults will ever use any of the algebraic manipulations or shortcuts they learn in math class. Do they use the creativity and problem solving? Maybe. But programming might be a better way to go about cultivating those less black-and-white skills. It involves all of the logical thinking, all of the precision, all of the creativity -- yet without the tedious rules and algebraic manipulations that many students (rightfully) find mind-numbing.

I don't think we should cancel all math classes tomorrow. But I do think there's something behind the following observation: even those kids in my programming class who are not mathematically-inclined and/or completely disengage in math class, were engaged for a majority of the time in programming. And over the course of the semester, I saw a definite improvement in their ability to think logically and focus for long enough to try several strategies for solving a single problem. This is something I tried to get them to do in math last year, yet never felt terribly successful. In programming, I didn't even have to try very hard for them to accomplish those things.

One more thing: I was absolutely amazed by what my kids were able to do by the end of the semester. Most of them literally had no idea what programming was when the semester began, yet for their final projects they created programs that were pretty complex! Some examples of student work follow. All of these are interactive games made in VPython (Visual Python). (In retrospect, I might have taught VPython from the beginning. Even the few stragglers who weren't really engaged in programming at the beginning couldn't help but get into it when we started the visual stuff.)

A soccer game where the player controls the blue goal and the
ball moves randomly about the field

A classic 2-player game of dots & boxes (one
surprising challenge associated with this game is having
the computer recognize when a player has won)

A car game where the user has to navigate the red
"car" around a series of moving obstacles

An asteroid field where the user controls the
space ship and tries to avoid oncoming asteroids

If you have any say in this whatsoever, teach your kids programming! (Even if that means you teach yourself programming along the way.) Python is free and open-source and available for download here. Also check out a bunch of great resources for teaching programming.

44 comments:

Love it, love it, love it! What an awesome testimony to the power of 21st century learning. Having followed you from the beginning of the semester and hearing your concerns, I am so happy that the class ended up working out with amazing results.

Your conclusions about the future of math and what the classroom will hopefully look like are inspiring as well. We spend so much effort teaching that which is irrelevant to their lives and expel so much energy trying to motivate.

I saw your student's code and know that they were learning vectors, forces, kinematic equations, arrays/matrices, etc all by teaching themselves and through intrinsic motivation.

I spent a few days ruminating on this topic too http://brokenairplane.blogspot.com/2010/12/math-and-curriculum-reform-for-21st.html

This is one of my favorite posts that I have read in a while because it is everything that is right about education. Keep up the amazing work and thanks for putting all of the effort you did to make this class great!

You continue to blow me away with your enthusiasm for teaching and your thoughtfulness. I have no doubt that this may be the needed shift math education needs and I cannot think of a better individual to lead the charge!

You might also take a look at http://www.seas.upenn.edu/~cis500/current/. With modern proof assistants it's possible to make intro to abstract math classes just as fun. The interactive nature of proof assistants like Coq gets rid of the fuzzy feeling that you mentioned and allows the students to get immediate feedback as they are working on proofs.

Maybe you should change the 'adding numbers from 1 to 1000' example, you can also do that in a second with math. Oh oh, more constructively, you can show them how math helps them in programming by simply using the summation formula as an alternative implementation.

I have a real problem with these two statements: "I taught a programming elective" combined with "I didn't have very much programming experience before the class began."

Imagine if I said, "I taught a class in physics but I don't have much experience in math." Would you think that wise? What if I said I wanted to teach music but I've only taken a course a few years ago in college?

While I appreciate your efforts to teach programming to kids I also have to firmly plant forehead in palm. Teachers should be experts in the subject they teach, not novices themselves.

Pretending to "teach" a subject of which you have no real knowledge not only disrespects the field in which you are "teaching" but it does a disservice to the student.

Lets look at the K-12 landscape for a second - this story is exactly how many computer science teachers get started.

It would be great if we all came to the field with this kind of training, but it doesn't exist.

Nationwide we have no teacher prep programs in cs, no "methods of teaching cs" pedagogy classes. I only know of ONE person in the US with a cs/education PHD. We do not even have any research on exactly what methods work best in cs instruction.

Yet our kids need exactly this type of classroom experience. So it is up to teachers with no formal training to step in and teach.

It sounds like this was a great experience for every one. And if teachers without "real knowledge" of cs are not willing to do this, most kids in the US would have no exposure at all.

First off I'd like to say that, from what you describe here, you're succeeding in a very significant way at a very key part of education: Inspiring the students to find a passion in a truly amazing subject like computer science.

However, I have to agree with the concern of the combination of "I teach Math and Computer Science" with "I didn't have very much programming experience before the lass began."

I'm not accusing anyone of anything here, because I don't know the full situation. But have you considered things like this:

What if a students comes up and asks you a question relating to a more advanced computer science subject, several years down the line? Could you confidently answer and steer the student towards resources that would help them satisfy their interest?

"We always look for doctors but sometimes we're lucky to find a frosh."

What's better: a teacher with just enough skill to get some kids started at programming, which they end up finding extremely engaging; or, someone with a mastery of a subject that is forgotten about as soon as the class is over?

You mention the artificial ordering of math concepts forced on us by standards bodies. I think if we did a better job of teaching math (step one might be ignoring that artificial ordering), there'd be less suffering and dread, and more enjoyment and learning.

I'm a programmer with 23 years experience and I still get the WOW factor when something comes together. Programming is normally seen as a very mathematical, technical subject but in truth it is one of the most creative ways to engage your brain. You get to manipulate concepts that you create, unrestrained by the laws of physics and free to undo/redo those concepts when they don't fit with the problem. I'm glad your students have been introduced to the art.

BTW, for those complaining about a non-programmer teaching programming:1. This is clearly an introduction to programming. Advanced skills/knowledge not required. This sort of thing happens the world over in all subjects.2. IME, someone who is new to programming is much more likely to convey the WOW factor to their students than "expert" CS lecturers who have seen/done it all already.3. The experts prefer to teach arcane outdated material, whereas this class just looks like plain fun. Guess which one engages the students more ...

Awesome story, but to nitpick: I tried to click on the word "amazed" in the sentence "I was absolutely amazed by what my kids were able to do" because it's underlined for emphasis. On the web, underlining suggests hyperlinking. You should something else for emphasis (such as italics).

I must say that I loved Maths and Physics as a student but only because at the same time I was an avid programmer. While the other students in the class would ask "Where on Earth would that be useful?" I was already doing a face-palm thinking about all that time I wasted doing unnecessary calculations for no good reason; I could see a use for the Math immediately and that made me want to learn so much more. When you can see what you are learning empower you to make cool things you cannot help but be engaged. People like knowing that their time is not wasted and more to the point maths can be taught through programming...imagine the entire course being about completing different programs. But completing those programs required mathematical knowledge to do properly. Now that would be a course! I have often thought that the ability to write programs should be taught like the ability to read. Computers are too important for people to be powerless to write for them.

Perhaps the way that Maths is taught is incorrect. I like that you enjoy teaching programming. I don't understand why you are comparing programming TO maths though.

These are two very different disciplines. Maths is often not an interesting subject because, in itself, it is not a means to an end. In most cases, you can't solve a problem with "maths" alone. You USE maths to solve problems with real world problems. You illuded to statistics, they are valuable when combined with perhaps finance, and most other maths with Engineering. Binary, Hexedecimal etc maths in Computing. But, fundamentally Maths is necessary to do these things. Even if you are a programmer, eventually you have to hit a problem that requires maths. Even lowly Excel users require maths.

I don't see how you have provided any insight into how Computing has replaced maths, because if you didn't teach children maths "en masse", you would have a significant population of complete retards... more so than we do now.

I'm so sorry for the abysmal quality of comments you've received. It's disheartening to read so much trite negativity and petty criticisms after reading about how programming has had an overwhelmingly positive affect on you and your students.

The fact that your class had fun and your students were inspired enough to teach themselves vectors tells me you're onto something. I can tell you from first hand experience that most CS professors don't typically inspire that level of motivation, and you should absolutely ignore any blow-hard who tells you you're not qualified to teach CS.

Enrollment in CS is a big problem these days, especially with young women, but it wasn't always the case! (http://www.ultrasaurus.com/sarahblog/2008/11/declining-number-of-women-studying-computer-science/). As you can see from the graph in this article, enrollment rates for women in the early 80's was relatively on par with the men, compared to today's rates.

I hope you seriously consider enrolling yourself in a few computer science classes yourself, if you haven't already done so. Also, maybe you can share some of your success and consider posting some of your lectures on YouTube.

While I think it's all well and good that your students found programming fun, I must say that I am left unconvinced with your conclusions. You're comparing something that is taught to kids over a period of 10 years or so (math), to a one-off excursion into the world of programming. What I want to say is that should we be teaching kids 10 years worth of programming/computer science/whatever name you'd want to give to that subject, we'd hit that point where things get sufficiently complicated that you can't just "see for yourself on the computer whether it works alright" and the puzzling feeling you mention will come back crawling. In the same way, some students will start thinking that what they're learning is useless.

All in all, I think it is only a matter of how advanced the class is, rather than what it is about. I think it is difficult for us to really imagine what it would be to have a full junior high and high school cursus in CS, and I have no proper experience teaching, but well, that's my opinion.

I learned math through programming. BASIC type-ins to be exact. And I've lamented the fact that kids don't have that these days. I've even tried reviving it to limited success, and I'm going to try again.

I think there are other things to take away from this:1) Kids do not need some simplified programming environment to learn in. They can handle the real stuff. (Mind you Python is pretty "high level" but they still have to type, they still have to debug in the traditional sense, etc.)2) Games! As teaching tools! Teachers use game-like activities all the time, but sometimes kids want the brain-dead games. Fine. Even the most brain-dead game becomes a learning challenge when you're the one programming it.

I'd love to see more study in this. What if it weren't an elective? Would a disinterested student become engaged? What about boys vs girls? Will this help fix the female CS enrollment problem by starting them early?

I really appreciate the post about getting kids into programming... though don't you think you'd have the same proportion of disinterest if you forced students into programming classes the same way kids are forced into math classes?

I am pretty experienced in C/C++, but since all of my courses have taught this (Computer Engineering at Virginia Tech), I want to learn Python as a second language for its versatility. I plan to complete your assignments as a path to learn the basics of Python. Looks fun.

I'm working for a client who has a new curriculum that accounts for networked nodes and programming the computer to crunch data to get meaningful results. "Mapematics" by James Bailey should be available later this year, I hope!

I was the one who posted earlier about it being perhaps sub-optimal for a non-expert in programming to teach programming. However I was wrong:

I assumed that this was for university students, in which case I think it's rather important for a teacher to be well educated in the field they're teaching. This is due to my own experience, perhaps, of intro teachers stumbling in class when a student asks a question of a border-case inconsistency that even I knew the answer to at the time.

For high school students, however, it's far more important to inspire a passion of learning... and clearly this teacher is amazing in that respect. I only wish there were more of teachers like her today.

It gets way better! The Sage package http://sagemath.org/ is an open source mathematical software package that is scripted with Python.

From their "Sage Tour" page.

"Sage is built out of nearly 100 open-source packages and features a unified interface."

It "... includes a huge range of mathematics, including basic algebra, calculus, elementary to very advanced number theory, cryptography, numerical computation, commutative algebra, group theory, combinatorics, graph theory, exact linear algebra and much more."

No it's not. The idea that programming is the new math is in fact one of the major things that is ruining the field of CS and programming. There are too many students in CS that think it's all about building some stupid little programs just for fun who don't really know what the hell they are doing. Usually these people never grap the fundamentals and end up at some god forsaken place writing javascript web monkey code.

There is no doubt that if Computer Science was made compulsory that it would experience the same issues that are found in every class. This class was highly successful in part because students chose to be in her class.

However, there are very few opportunities for students to create and apply their mathematical knowledge outside of pseudo word problems. The satisfaction that comes from creating a successful algorithm or model in my opinion, must be similar to the pleasure the ancients similarly derived from mathematical play.

Whether it is creating games, building robots, or sitting through data, I applaud any effort to increase students' exposure to CS.

As for her knowledge of Python beforehand, it is my observation that it had no ill effect on the class and in fact allowed her students to see her joy in learning along with them. Contrast this with any teacher reiterating content for the umpteenth time.

I am so excited that this conversation is happening and that so many more have entered into it. The resources to help secondary teachers use CS in the core math/science classroom is sparse but with many eyes on the issue it will not remain a problem for long.

Taking the example of the sum of an arithmetic series, your students (and many programmers) would probably use a brute force method of iterating from 1 to 1000 and adding to a total. Call me weird, but I find this much less interesting, much less engaging, with much less ‘wow’ factor, and it is a much less imaginative solution, than the mathematics of constructing the algebraic equations for the nth term, then constructing the sum of the series in two ways, and solving to come up with Sum=n(a1 + an)/2The mathematical approach is incredibly more elegant, and complete, and will work for any arithmetic series with any number of terms and any difference. Amazing!I don’t say this because I’m a mathematician, I am actually a software engineer.I question the suggestion that there is no total order on the set of mathematics concepts. I would posit that mathematics has more ordering of concepts than other subjects, including CS, and herein lies the problem, students with gaps in their knowledge cannot progress and thus lose interest.Coming back to the proof of the arithmetic series, how can a student be interested in the proof if they have some gaps in their knowledge (even something simple like combining signs) and so they can’t actually do it? Thus those students fall further behind and become less and less interested, and they never actually ‘get it’. In contrast, a student who has the required skills and can do this, in addition to the beauty of the proof, finds encouragement to learn more, and they find a reason for their previous learning of algebraic abstractions, combining terms, manipulating equations etc.

I’d also have to call into question the motivating and ‘wow’ factor of producing a simple computer game. I’d be interested to know, does this work equally well for girls? I remember an introductory computer programming subject with an exercise to produce a computer game. I am male, but I found the exercise incredibly boring as I’m not that interested in computer games. Maybe 25 out of your 27 students are.

I agree with one comment that 10 years of programming may not be any more appealing to most students than 10 of mathematics! Also, once you actually begin programming you may not be working on something with all the ‘wow’ you talk about. I have spent the last 2 weeks, 10 hours a day, refactoring badly written code. This produces no visible results to any end user or even managers, but as a developer you have to fight the good fight against an unmaintainable code base.Mostly this horrible code is produced by people without a full CS education, and at least partly, this is where mathematics and CS digress. Programming allows you to do things, even if you do it the wrong way. The programme is ‘right’ to students when it runs and does what it should. However, someone with a bit more knowledge may look a the code and find a disaster. That doesn’t matter at the level you’re teaching, but as project size increases, the way you develop becomes increasingly important. Many students may start losing interest at that point, as they lose interest as mathematics progresses. Mathematics may not be so 'forgiving' of the wrong approach.

Don’t get me wrong with my criticisms here. It sounds like you’re a great teacher, and from what I can tell your students are lucky to have you. I also wouldn’t criticise your programming skills or knowledge for the level you’re teaching.

Kudos for keeping your students engaged. Unfortunately though, I find it a worrying trend that teachers need to cater for shorter and shorter attentions and turn almost all learning into ‘fun’ and ‘games’. And unfortunately for mathematics, I don’t see how you can turn the proof for an arithmetic series into a game to make it more interesting. Maybe, if students had to do it on their phone or computer, they’d be more interested? Again unfortunately, for mathematics, it is quicker writing mathematics with pencil and paper.

I taught a Java programming class to middle school kids (at a summer computer camp when I was an unemployed programmer) eight years ago. When the class was not going well because I had trouble communicating technical information during the lectures (it was a three hour class and I had never taught before), I began using presentation slides and increased lab time to two hours to let the kids "explore" how to program.

After reading your article, it validated that my instincts were right to adapt my strategy. Toward the end of the course I made the lab assignments more fun by having them do more stuff with graphics and animation. When the students showed their work to their parents on the last day of class, some of the parents seemed pleased that their kids actually learned something.

Great article, thanks for sharing your experience. Seymour Papert's book "Mindstorms" is a good read on why he invented the Logo programming language to help kids learn programming, with the sub-goal of making anything (math, physics, etc.) learnable by immersion, the way we naturally learn language.

I'm also working on a tool called Waterbear to help kids learn programming, even ones who are turned off by writing code in a text editor. The early version is available here: http://waterbearlang.com/. It's an open source project, welcoming new participants.

I've also found VPython very inspirational and hope to have something like it as part of Waterbear as the WebGL standard matures and is made more widely available (WebGL enables 3D in web browsers).

This is one of my favorite posts that I have read in a while because it is everything that is right about education. Keep up the amazing work and thanks for putting all of the effort you did to make this class great!