Thursday, September 27, 2012

Learnable Programming

The single best computer science essay of the year has just been published, and it is Bret Victor's Learnable Programming: Designing a programming system for understanding programs.

Warning in advance: this is a long and thoughtful essay; you aren't going to get through it in one sitting; you're going to need to read it, and think about it, and return to it later.

But if you have any interest at all in what computer programming is, in why it is so hard to learn, and so hard to teach, and in what we can do to best prepare our entire humanity for a future in which everything is programmable, and everyone is a programmer, you owe it to yourself to think about the things that Bret Victor is thinking about.

Victor's main observation is that too many people get hung up on the mechanics of programming, and don't understand that what they need to be concentrating on are the concepts of programming:

Two thoughts about learning:
  • Programming is a way of thinking, not a rote skill. Learning about "for" loops is not learning to program, any more than learning about pencils is learning to draw.
  • People understand what they can see. If a programmer cannot see what a program is doing, she can't understand it.

Thus, the goals of a programming system should be:

  • to support and encourage powerful ways of thinking
  • to enable programmers to see and understand the execution of their programs

Later in the essay, Victor deals with what I consider to be one of the hardest aspects of trying to teach people how to become programmers: learning abstraction:

The description still says "draw a rectangle here, then a triangle there", but the here and there have been abstracted. Different parameters give us different heres and different theres.

How does a programmer learn to write this abstract code? How does she learn to write a single description that is generalized for many cases?

She doesn't. The learner should start by writing concrete code, and then gradually change it to introduce abstraction. And the environment must provide the tools to perform this process, in such a way that the learner can understand the program at each stage.

Another extremely challenging part of teaching programming is to teach the ability to visualize what the computer is doing, and to identify with the actions that the program is instructing the computer to take:

That's Seymour Papert explaining the Logo turtle. The turtle serves a number of brilliant functions, but the most important is that the programmer can identify with it. To figure out how to make the turtle perform an action, the programmer can ask how she would perform that action herself, if she were the turtle.

For example, to figure out how to draw a circle, a learner will walk around in circles for a bit, and quickly derive a "circle procedure" of taking a step forward, turning a bit, taking a step forward, turning a bit. After teaching it to herself, the learner can then teach it to the computer. The turtle is the in-computer embodiment of the programmer herself, a "self", like the player-character in a video game, and thereby allows the learner to transfer her knowledge of her own body into knowledge of programming.

This is a wonderful article. By looking backward, and looking inward, Victor proposes how we can look forward, and how it is now fully within our grasp to build learning tools which can help us (all 7 billion of us, eventually), to achieve that next plateau of learning how to program, and how to program successfully.

No comments:

Post a Comment