Rurple NG

Aug. 13th, 2009 02:31 pm
ciphergoth: (Default)
[personal profile] ciphergoth
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:
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.

Date: 2009-08-13 01:37 pm (UTC)
From: [identity profile] battlekitty.livejournal.com
Hee - it's Karol the Robot! (Or whatever it was called)...

I remember using that in highschool *mumble* years ago! Most interesting thing I did in that class - the rest of it was typing and proofreading for some inexplicable reason...

Date: 2009-08-13 01:38 pm (UTC)
From: [identity profile] battlekitty.livejournal.com
And *now* I've looked at the work blog...!

Date: 2009-08-13 01:39 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
Yep, it's the fourth-generation successor of Karel the Robot!

Date: 2009-08-13 01:45 pm (UTC)
From: [identity profile] palmer1984.livejournal.com
OH that's so cool. We must have another programming date at some point :).

[Feeling quite bad for not managing to do much more programming since you taught me stuff. It's not due to lack of interest, just everything being very hectic].

Date: 2009-08-13 01:53 pm (UTC)
From: [identity profile] purplerabbits.livejournal.com
That sounds like something I would like to learn from :-)

Date: 2009-08-13 06:46 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
I shall post again when I have Windows and Mac installers ready!

Date: 2009-08-13 01:53 pm (UTC)
From: [identity profile] wildeabandon.livejournal.com
Oh nifty. I'll have a play when I get a chance.

Date: 2009-08-13 01:55 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
You'll need Python 2.6 and wxPython - I think those are now the only dependencies. I've only tried it under Ubuntu - I've had reports that parts of it don't work properly under Windows or MacOS.

Date: 2009-08-13 02:02 pm (UTC)
From: [identity profile] robot-mel.livejournal.com
Neat! One thing I like about the age I am is that when we got personal computers programming was just something you learned along with it. (At least if your dad was a software engineer like mine was) And then in the early days of the internet you actually had to learn the HTML rather than having applications to do it for you. I think (like cars) it's much more fun when you understand how it works.

I never built a car, but I did rebuilt the engine on my VW Beetle - twice...

Date: 2009-08-13 08:16 pm (UTC)
From: [identity profile] skx.livejournal.com
Yeah for most people I know that are programmers/IT-related they started like that.

For me it was the fact that the family computer came with a manual which introduced BASIC and we had very small budget for buying games .. so I'd experiment with programming.

In many ways computers were simpler then. (Not necessarily easier due to RAM/feature constraints, but definitely simpler.)

Date: 2009-08-14 09:34 am (UTC)
lovingboth: (Default)
From: [personal profile] lovingboth
It was certainly possible to 'know' a system in a way that is impossible now, even down to being able to build several of the 8 bit micros yourself from TTL chips.

Date: 2009-08-14 09:36 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
One of the exercises on our degree course was to build your own microprocessor from logic gates. You only had 256 bytes of memory, but it was still way cool, and you had tremendous freedom of design - eg you wrote your own instruction set and you could decide whether to have a single bus or separate instruction and data buses.

Date: 2009-08-14 11:18 pm (UTC)
lovingboth: (Default)
From: [personal profile] lovingboth
You've seen opencores.org, haven't you?

The one slightly critical comment I'd make on this is that the first line should say '.. how to program in Python', but I haven't played with it properly yet.

Date: 2009-08-14 11:19 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
No, it's programming I mean to teach; Python is just the choice I've made for what to teach. Though one of those people programmed a little before, a long time ago, so it's more of a rediscovery.

Date: 2009-08-14 11:45 pm (UTC)
lovingboth: (Default)
From: [personal profile] lovingboth
Hmm, when I think about introducing programming to JA, it's doing it via starlogo-ng or possibly Forth driving a Mindstorms robot. But that's probably me...

The former means not having to answer 'Why do some words have to have (parentheses) at the end?' with 'Because that's what Python insists on', just a very intuitive (YMMV) graphical IDE where you put building blocks in the place you want and get very graphical results. Does it do the indenting of source for you? If not, that's another thing I'd need to explain, etc.

The latter means a very interactive environment where you're encouraged to factorise and reuse short definitions.

This doesn't stop me being very impressed with it and I accept seven year olds may well not be your target audience :)

Date: 2009-08-15 07:56 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
It does indent source for you, but you still need to explain it. I agree that the parentheses are frustrating, but as I say in the blog post the payoff is that people start off using a language that they won't have to throw away when they get more sophisticated.

Date: 2009-08-13 02:12 pm (UTC)
ext_78940: (Default)
From: [identity profile] yoyoangel.livejournal.com
I feel very lucky that my mum was a geek who had us learning Basic at infant school age.
I agree that things are more fun when you know how they work.

Date: 2009-08-13 02:19 pm (UTC)
From: [identity profile] weegoddess.livejournal.com
I've had to teach myself a bit of HTML so that I could write/update/maintain parts of my website. And I agree, it's really really cool to have the computer do exactly what you tell it to. And oh so frustrating when it doesn't and I can't for the life of me figure out what's amiss...;-D

Date: 2009-08-13 03:38 pm (UTC)
simont: A picture of me in 2016 (Default)
From: [personal profile] simont
Oh no, the really frustrating thing is not when the computer doesn't do what you told it. That usually just means you take it back and complain. The really frustrating (and extremely commonplace) thing is when it did do exactly what you told it, but that wasn't what you should have told it! Then you've got nobody to blame but yourself...

Date: 2009-08-13 02:38 pm (UTC)
From: [identity profile] robinbloke.livejournal.com
Ahhh happy days, this reminds me of using the LOGO turtle :)

Date: 2009-08-14 11:06 pm (UTC)
lovingboth: (Default)
From: [personal profile] lovingboth
Have a look at starlogo-tng from MIT.

Date: 2009-08-13 03:12 pm (UTC)
From: [identity profile] damerell.livejournal.com
The trouble with learning to program is that there has to be something you want (or need) to do. This was a lot easier in the 8-bit days when, say, simple text adventures were obvious hobbyist projects (not that you can't write one now, but you're much more likely to when text adventures are a commonplace thing) and simple graphics were simple to do.

There's still a fair few people seem to learn some kind of programming from the desire to write a roguelike game - a roguelike remaining a practical single-person hobbyist project.

I think the other approach is what you're doing - a game with a programming environment inside it which is secretly a real programming language. Zach's Manufactoid ( http://www.zachtronicsindustries.com/pivot/entry.php?id=18 ) is a similar idea with Lua which might be interesting (Windows-specific, alas). There's a bunch of robot-arena Flash games with languages specific to the game, too, but some of them have proper flow control and whatnot.

Date: 2009-08-13 03:16 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
Well, one of the other features of my rewrite is that it's designed to support pluggable environments - so support for a roguelike environment is absolutely a practical goal.

Date: 2009-08-14 09:43 pm (UTC)
From: [identity profile] emarkienna.livejournal.com
Yeah, I sometimes have programmer's-block where I'm itching to write something new, but stuck for ideas.

I think a nice thing about game programming in general is that even if you're just doing something that isn't particularly original, it's still easy to add your own original creativity (levels, rules, characters etc).

Date: 2009-08-13 05:07 pm (UTC)
From: [identity profile] haggis.livejournal.com
I learned to program BASIC and loved it and I've made intermittent attempts to learn C++. I really enjoy it but I'm feeling a bit stymied at the moment. I write programs to play little puzzle games or solve little logic problems but I have difficultly with any graphical stuff, which should be straightforward in more developed languages.

Can you advise what languages would be worth looking into?

Date: 2009-08-13 06:46 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
Python, no doubt about it. A beautiful, clean and simple language that's good for total beginners to programming but is also well suited to real work. There are many, many libraries for a huge variety of tasks. The program I wrote is written in Python and teaches Python. Google write everything in either C++, Java, or Python. There are things other languages do better, but you'd be very hard pressed to regret learning Python first.

Graphical stuff sadly is hard in any modern environment, but you can get very nice results out of Cairo, which is what I use for my electoral charts - in Python, naturally :-)

Date: 2009-08-13 06:50 pm (UTC)
From: [identity profile] haggis.livejournal.com
Thanks, I'll look into it.

One of the things I wanted to make was one of those simple ecological models (sharks eat the fish so the fish population drops so the sharks die out a bit so the fish population booms) that I could make much more customisable. The logic is easy, trying to write a program to display it was such a nightmare I gave up.

Date: 2009-08-13 06:55 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
If you want to display it as a graph, the Python library "matplotlib" is not too hard to use and produces absolutely fantastic results, as well as being very flexible. A lot of my electoral charts used it.

Date: 2009-08-13 08:10 pm (UTC)
From: [identity profile] meico.livejournal.com
Graphical stuff sadly is hard in any modern environment

I think Processing make grapical stuff very very easy. Simple to invoke, deploy, and with tons of great examples online. :)

Date: 2009-08-13 08:17 pm (UTC)
From: [identity profile] skx.livejournal.com
One thing you might like to experiment with is javascript/html.

You can write fairly complex things that run inside a browser these days...

Date: 2009-08-14 05:06 pm (UTC)
From: [identity profile] meico.livejournal.com
Add the "canvas" element and it gets really interesting. :)

Date: 2009-08-15 02:03 am (UTC)
From: [identity profile] emarkienna.livejournal.com
Yeah I remember when I moved from BASIC to C, it meant a less satisfying period of just amusing myself with less exciting text input/output.

I thought that Java was nice in that it includes a graphics library as standard, and it's easy just to write an Applet that you can immediately view in a browser.

In a lot of cases though, you can use many graphics libraries with many programming languages. What have you been trying so far to do graphics? I've found SDL is fairly easy to use for doing 2D game-style graphics.

Date: 2009-08-13 06:04 pm (UTC)
From: [identity profile] meico.livejournal.com
Very cool. :)

A good friend of mine works a Microsoft and has spent the last few years trying to achieve the same thing... The project is called Kodu and is available right now on XBox Live...

I also started to do a similar thing inside of a web browser myself, it works quite well but has at lest one annoying bug (entering in new code after hitting the run button then hitting run again doesn't stop the first version of the program- so you end up with two versions of the program running concurrently). That said, I think it's pretty dang cool:

http://www.tinyurl.com/processingnow

and the javascript only version:

http://www.tinyurl.com/javascriptnow

Go to either of them and hit the "run" button. Certainly a robot/ turtle environment is easier and more illustrative though. :)

Date: 2009-08-14 11:35 am (UTC)
From: [identity profile] ciphergoth.livejournal.com
Kodu looks cool, but I'm not concerned by competition from non-open-source alternatives. I love your processingnow demo!

Date: 2009-08-14 04:29 pm (UTC)
From: [identity profile] meico.livejournal.com
Yay, glad you like it. :)

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);
}

Date: 2009-08-13 06:20 pm (UTC)
From: [identity profile] plumsbitch.livejournal.com
Fascinating, thanks heaps for pointing this up.

(am someone who a)made little things in BASIC and machine code on a ZXSpectrum as a tiny thing and somehow then forgot all about it b)when riding bikes, did a mechanics courses coz I wanted to know how my machine was doing what it does, and have recently begun to get frustated with how little I understand about a machine with which I spend so much time interacting.)

Date: 2009-08-14 10:18 am (UTC)
From: [identity profile] dennyd.livejournal.com
Neat project, hope it goes well :)

Profile

ciphergoth: (Default)
Paul Crowley

January 2025

S M T W T F S
   1234
5678 91011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 10th, 2026 06:45 am
Powered by Dreamwidth Studios