Learnable Programming

More on a recurring theme — Bret Victor has just posted “an immune response” to the Khan Academy‘s recent additions covering Computer Science and programming:

Here’s a trick question: How do we get people to understand programming?

Khan Academy recently launched an online environment for learning to program. It offers a set of tutorials based on the JavaScript and Processing languages, and features a “live coding” environment, where the program’s output updates as the programmer types.

Because my work was cited as an inspiration for the Khan system, I felt I should respond with 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

A live-coding Processing environment addresses neither of these goals. JavaScript and Processing are poorly-designed languages that support weak ways of thinking, and ignore decades of learning about learning. And live coding, as a standalone feature, is worthless.

Alan Perlis wrote, “To understand a program, you must become both the machine and the program.” This view is a mistake, and it is this widespread and virulent mistake that keeps programming a difficult and obscure art. A person is not a machine, and should not be forced to think like one.

How do we get people to understand programming?

I have nothing to add other than to tell you to go read the whole thing.
Previous/related posts:

Khan Academy Tackles CS Education

I’m very excited to learn that Khan Academy has been working with John Resig (creator of jQuery) to develop a new computer science curriculum heavily influenced by Bret Victor’s talk on responsive programming environments.

Check out the video they made discussing their plans:

It’s very interesting to me to see the ways that academically trained developers differ (in ways both positive and negative) from self-taught developers. As I’ve said here before, I believe that having at least some minimal proficiency programming computers is an important part of basic literacy in the 21st century, and it’s not at all clear to me how to implement that on a wide basis. The work that people like Khan and the folks at Udacity are doing with flipped classrooms and the like are something that I’m watching very closely.

Update 27 Sep 2012:

Bret Victor responds (to the Khan Academy, not to me):

Here’s a trick question: How do we get people to understand programming?

Khan Academy recently launched an online environment for

learning to program. It offers a set of tutorials based on the JavaScript and Processing languages, and features a “live coding” environment, where the program’s output updates as the programmer types.

Because my work was cited as an inspiration for the Khan system, I felt I should respond with 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.

Go read the whole thing.

Friday Linked List (06/01/12)

Three cheers and a tiger for me — today is my 15th anniversary with Art & Logic, and in lieu of a party I’ve decided to dump some links that have collected in my pinboard account:

First, two different blog posts discussing ideas about user interface design. For me, these two posts have been shifting back and forth between agreeing with each other and disagreeing with each other, like an optical illusion.

Joshua Porter (no relation) gives 20 Principles of User Interface Design. Very clean, very sensible.

…but on the other hand, the always-worth-reading Rands looks to the techniques of progressive disclosure and hypothesis-driven learning that are used in games as a guide to user interface design.

Game designers have a different set of incentives to make their tools easier to learn via sandbox and atomically chunked learning. They may obsessively play test their games looking for user frustration earlier, but whether you’re leaping through a portal or creating masks of transparent elements in Photoshop, both use cases strive for a moment where you can cleverly and unexpected solve a seemingly impossible problem on your own.

Game designers and application designers might exist in different universes, but there is no reason one universe can’t teach the other.

Another list-based link from The Twelve-Factor App:

In the modern era, software is commonly delivered as a service: called web apps, or software-as-a-service. The twelve-factor app is a methodology for building software-as-a-service apps that:

  • Use declarative formats for setup automation, to minimize time and cost for new developers joining the project;
  • Have a clean contract with the underlying operating system, offering maximum portability between execution environments;
  • Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration;
  • Minimize divergence between development and production, enabling continuous deployment for maximum agility;
  • And can scale up without significant changes to tooling, architecture, or development practices.

The twelve-factor methodology can be applied to apps written in any programming language, and which use any combination of backing services (database, queue, memory cache, etc).

I’ve certainly seen a lot of projects going through various degrees of pain that could have been reduced or eliminated had they implemented these ideas.

Lastly — Blockly:

What is Blockly?

A new programming language made up of “blocks” that look like jigsaw puzzle pieces.

What do I use Blockly for?

First, a programmer needs to integrate Blockly with a web application, like Gmail or Google Docs, that you already use. Then you can use Blockly to write simple programs like macros and scripts that work with the web application.

For example, in Gmail, you can use Blockly to create email filters that do things like, “If Bob emails me three times in less than an hour, and each email contains the word ‘deadline’, delete all his emails except the first one.”

The image at the top of this post is a quick thing I threw together with their Blockly demo. Took me about 5 minutes (where I could have written and tested it in Python in much less). On the other hand, it’s very close to the programming interface used by MIT’s Scratch, which my kids both enjoyed using when they were little. It might prove to be a very easy and useful way to add end-user programmability to a system at some point. Their ‘Code’ demo lets you create a program with the Blockly editor and then export it to working code in any of JavaScript, Dart, Python, or XML.

 

Yes, Do Learn To Code!

My usual pre-work routine is to walk the dog (working at home, this is my counterpart to a commute), pour my first cup of coffee, and then curl up for a little while with Google Reader. I don’t know if it’s because I’ve selected feeds that are too closely aligned with my values and personal agenda, but it’s really rare that I’ll read a post that is just so wrong that it makes me angry. Jeff Atwood wrote a post like that: Please Don’t Learn To Code

To those who argue programming is an essential skill we should be teaching our children, right up there with reading, writing, and arithmetic: can you explain to me how Michael Bloomberg would be better at his day to day job of leading the largest city in the USA if he woke up one morning as a crack Java coder? It is obvious to me how being a skilled reader, a skilled writer, and at least high school level math are fundamental to performing the job of a politician. Or at any job, for that matter. But understanding variables and functions, pointers and recursion? I can’t see it.

Look, I love programming. I also believe programming is important … in the right context, for some people. But so are a lot of skills. I would no more urge everyone to learn programming than I would urge everyone to learn plumbing. That’d be ridiculous, right?

On the contrary: being able to think computationally and algorithmically should be a fundamental skill that’s possessed by modern humans, whether it’s a skill that they use on a professional basis in their lives or not. Every day I have to deal with a world full of people who show little or no ability to think clearly, and some level of being forced to develop some chunk of code to the point where it works correctly has to be a positive thing for people to know how to do, even if they never do it again.

When she was in graduate school, my wife had to take a class that required homework to be done in a spreadsheet. I did my best (and failed) to teach her how to use formulas and macros, but then I’d walk back into the room and see her summing columns with a calculator and typing the value into a cell.

Atwood is right that the goal of programming is to solve a problem, but he makes it sound like that’s a dirty thing, and the highest goal of a programmer is to duct tape together pre-existing modules and collect a check. Leaving aside the question of where those modules come from in the first place  (coded up by elves, I suppose) too often that approach leads to systems that are limited to the capabilities of those off the shelf modules and even more limited by the duct tape developers who lack the capability, imagination, time, or foresight to go beyond those limitations. We’ve made a lot of money over the years gutting and replacing these systems, and maybe even more building systems for clients whose in-house developers told them couldn’t be built at all.

I didn’t even intend to write software — I studied composition in college, and had to learn to write code in C for an electronic music class. It was only after I had enough experience as a developer that I was able to build tools that were a perfect solution to problems that I had as a composer and musician. Learning to program made me a better composer by teaching me a different fundamental modality of thinking, and being a composer has made me a better programmer. If you can successfully write a four voice fugue using common practice harmony, I can teach you to write bulletproof multithreaded code (here’s an article on one of my first real products that was a multithreaded DOS app that had at the time been running 24/7 for a decade).

I believe that everyone should learn to write a little code, and play an instrument, and make things out of wood, and tend a garden, and cook, and, yes, do a little plumbing, too. They shouldn’t learn these things because they’ll use them every day to earn a paycheck, they should learn them because it makes them better thinkers, and better able to take care of themselves. On top of that — if vast empires were being built on top of plumbing the way that they’re being built on software, I’d say that anyone who was happy to ignore it as a black art practiced by wizards was making a big mistake. The value of acquiring a new mode of thinking isn’t affected by the fact that most people won’t need to use pointers or recursion on a daily basis.

When my wife and I had our first child, my germ-phobic wife had a very  hard time with the pediatrician’s assurance that it was okay for our baby to put everything in his mouth, and that doing so was part of how he would learn about the world. I think that the way I learn things is by writing code about them. I don’t know if telling people to not explore that is being elitist, or condescending, or what, but it definitely strikes me as being very wrong.

Edit: There have been many many other similar responses to Atwood’s piece. I think that my favorite one is by Al Sweigart: A Modest Proposal: Please Don’t Learn to Code Because It Will Damage Your Tiny Brain

Edit 2: …or a much less snarky one that takes us back to the ancient Greeks from Vivek Haldar (always worth reading): Executable Thought