Programming in Middle School?

Eating breakfast in the hotel the other morning, my father mentioned a Twitter conversation he had to join about programming courses in schools and math curricula.

Programming and math education? I just had to get involved, too.

Ben Grey and Colleen K had started talking about the value of programming courses in school. Ben and my father (initially) were against it, concerned that the skills would be obsolete before they could be used, and were not particularly transferable to most fields. Colleen and I took the pro side.

Ben and my father both pointed out that languages go extinct, which is true. But judiciously chosen languages have staying power. Basic can be run in a browser, but is obviously a fine starting point. C has been around since 1972, and it isn’t going anywhere soon. JavaScript has been around since the mid-90s and seems to hold a secure point.

What of transferability? How many professional programmers still work in the first language they learn. Anyone? Anyone? Beuller? My first language was Perl, which helped me learn JavaScript and PHP, which helped me learn Java and C. People older than me probably started with Basic. People much older than me may have used ALGOL—which was on its fourth generation by the time C was born.

But what about the majority of students who don’t want to be programmers?

Programming is a powerful, concrete interface to the two mathematical concepts that cause the most problems for students in K-12: variables and functions.

In the US, our K-12 math curriculum covers three broad areas—numbers, variables and functions. These roughly correspond to primary math (counting, operations, fractions, equalities) algebra and geometry, and (pre-)calculus.

Most students can wrap their heads around numbers, even fractions. They are relatively concrete. Some students struggle with operations like multiplying and exponents, but this is the lowest hump, the bunny hill. The majority make it down unscathed.

When does your school start losing people in the math program? It’s probably around 8th grade. That’s when most schools begin the dreaded algebra. Variables are intuitive to some, but abstract and meaningless to others. If you believe Myers and Briggs, some of us are predisposed to abstractions and generalizations (*NTJ) but is there a biological reason others are lost here? Or do math teachers and curricula need to change?

Of the people who survive algebra without hating math, how many make it past “pre-calculus” or “FST”? I’ve heard the story a dozen times myself: “I was good at math until my calculus class.” If numbers are the bunny hill of K-12 math, then variables are the green circle, and functions are the double black diamond.

Again, functions may be completely intuitive to a few of us, but they can strike terror in the heart of even the most dedicated students.

Too often, when they reach a jump in complexity and struggle, students are told “it’s OK.” They are “not ‘math people.'” This can come from parents (“I was never good at math, either.”) or even well-intentioned teachers (“Maybe you’re just right-brained!”). There is a deeply held belief in this country that “math” is some innate ability, a genetic gift, and either you’re the next Will Hunting, or you may as well not try.

How does this relate to programming? How did you learn programming? Here’s a common roadmap:

  1. Imperative programming; no functions or abstractions; lots of constants; instructions in linear order.
  2. Using variables for input or consistency/ease-of-maintenance.
  3. Using functions and subroutines to encapsulate repeated operations.
  4. Using someone else’s functions—you probably don’t see the implementation.
  5. Branch off to more advanced ideas like object-oriented or functional programming; lots and lots and lots of abstractions.

A remarkably parallel route. And instead of saying “x is a number,” you can say “var name holds the name the user enters!” The results are far more immediate and interactive. Play is cheap. (“What if I change this line? Oh it doesn’t work, better undo that.”) Instead of limiting functions to scary numbers and equations, more pedestrian words can be used as arguments and return values.

Programming is applied mathematics. Teachers spend much of their lives looking for new examples, better applications, to drive home the theory, when there is already a wealth of application available.

There is also a two-pronged economic argument. To paraphrase Mr. Friedman: anything that can be outsourced, will, and the new jobs created here will require deeper interaction with computers. A cursory understanding of the programming techniques underneath will benefit all students as they enter the job market, and the exposure may mean more prepared students entering computer science programs. Basically: we need more talented, creative programmers—how many art students harbor latent programming skills—and even non-programmers will benefit from the exposure and understanding.

And of course, the math skills. No subject (that is taught) is taught as badly as math in our schools. On the personal level, this translates to people who misunderstand interest and get themselves in trouble with debt; on a national level, it certainly doesn’t help when a subprime mortgage market bubbles and pops.

Even if you don’t use “math” on a day-to-day basis, it is another way of thinking, of solving problems. Algorithmic thinking, epitomized in computer programming, provides a layer of cognitive flexibility, and every layer we can add, we should.

I don’t expect every student to become a master programmer, or even explicitly use those skills—or other skills in their math courses—every day. But I do expect schools to use every tool they have to make these methods of thinking and courses of study available to everyone. We wouldn’t allow a future programmer to skip his English class, why would we allow a future writer to skip his math and programming class?