Why Johnny Can’t Code

The most-excellent SF author David Brin has an article on Salon called “Why Johnny Can’t Code” (you have to sit through a commercial to gain access). In it, he laments the approachability of dear-old “line oriented” BASIC, by which, I think he means that era of BASIC when every line began with a numeric label:

10 PRINT “HELP, I AM STUCK IN A PROGRAM LOOP”

20 GOTO 10

Apparently, to this day elementary-school textbooks have sidebars exhorting kids to “Try it in BASIC!” and Brin tells an amusing story about having to buy a Commodore 64 on eBay for $25 in order to give his kid that chance.

He conflates a couple of different things: the increasing abstraction levels between the user and the underlying hardware, the resulting mental model, and the “learnability” of block-oriented imperative code. With BASIC, he says, you could write PONG and see the block move “at the command of math, and not magic.” A nice turn of phrase but not fair: the PDP-8 on which I learned to program didn’t have a raster display and I seem to recall quite a bit of PEEKing and POKEing “magic” when I did eventually gain access to such things.

There’s two things about BASIC:

  • Many people can “get it”, and
  • What they “get” is a decent mental model of imperative code (I’ll always remember the very first time I tried to tutor someone in BASIC: “So then it goes to the next line: ‘X = X + 1’,” I said. “False!” She said. I was flustered). Imperative code maps well to how computer registers and memory have volatile state. But BASIC doesn’t provide a mental model of all sorts of other stuff (like the plasticity of memory) that are equally part of any kind of even rough understanding of what’s “really going on.”

(A related point: the only other “programming-like thing” that many people “get” is spreadsheets.)

So, while I agree with the premise that it was much easier to develop a mental model of how computers worked, I disagree with the premise that BASIC was all there was to it.

If, though, you want a BASIC-like programming model in a modern wrapper, there’s a surprising equivalent: Flash. Flash works exactly like “line-oriented BASIC”: execution “falls through” from one block to the next but can be redirected to an arbitrary label/block/frame with a GOTO. It has the added benefit of having built-in graphics. You could totally write PONG in Flash. The only difficulty would be to constrain yourself to imperative constructs, since Flash has all sorts of additional constructs that you’d have to willfully ignore.