I've been writing a program for teaching people how to program:

And I've blogged about it on the work blog. I start by quoting Cory Doctorow's Little Brother:

And I've blogged about it on the work blog. I start by quoting Cory Doctorow's Little Brother:
If you’ve never programmed a computer, you should. There’s nothing like it in the whole world. When you program a computer, it does exactly what you tell it to do. It’s like designing a machine — any machine, like a car, like a faucet, like a gas-hinge for a door — using math and instructions. It’s awesome in the truest sense: it can fill you with awe.
A computer is the most complicated machine you’ll ever use. It’s made of billions of micro-miniaturized transistors that can be configured to run any program you can imagine. But when you sit down at the keyboard and write a line of code, those transistors do what you tell them to.
Most of us will never build a car. Pretty much none of us will ever create an aviation system. Design a building. Lay out a city.
Those are complicated machines, those things, and they’re off-limits to the likes of you and me. But a computer is like, ten times more complicated, and it will dance to any tune you play. You can learn to write simple code in an afternoon. Start with a language like Python, which was written to give non-programmers an easier way to make the machine dance to their tune. Even if you only write code for one day, one afternoon, you have to do it. Computers can control you or they can lighten your work — if you want to be in charge of your machines, you have to learn to write code.
no subject
Date: 2009-08-14 04:29 pm (UTC)Javascript + canvas is teh Roxor! (the fact that you type in Processing and not javascript is really just a nicety, you could make it parse any input language- including python)
Gotta get a fix for that bug though. If I fix that bug then people can have nearly instant iteration times: try some code, hit run, change a var, hit run, add a function, hit run, etc. It's not nice to force people to refresh the window each time. Fixing it will mean digging into the processing.js file to see what it is really doing to set up the loop though.
That said, the bug can be kinda fun if you write code for a random bouncing ball... every time you hit run (after the first time) it adds another one (which can sometimes be seen in the flickering). :)
You might have noticed the page doesn't make use of any server side features so you can just save the files to your desktop and run all this in a browser even when away from any network...
I'm sure you could add a robot/maze version and I wonder if there is a python.js laying around somewhere...
code for a random bouncing ball:
float radius, xPos, yPos, xVel, yVel;
void setup() {
size(200, 200);
smooth();
radius = 16 + random(16);
xPos = radius + random(width - radius*2);
yPos = radius + random(height - radius*2);
xVel = random(-5, 5);
yVel = random(-5, 5);
}
void draw() {
background(255);
xPos += xVel;
yPos += yVel;
if(xPos + radius > width || xPos - radius < 0){xVel *= - 1;}
if(yPos + radius > height || yPos - radius < 0){yVel *= - 1;}
stroke(0);
fill(0, 50);
ellipse(xPos, yPos ,radius*2, radius*2);
}