Scratch

By Shamus
on Jul 15, 2009
Filed under:
Programming

A few weeks ago I talked about learning programming, and I commented that I didn’t know what little kids were taught these days as a sort of “my first computing language”. At the time, I felt like kids should start with something linear and straightforward. Scratch has re-aligned my thinking on the matter.

Scratch is an interesting programming language (or pseudo-language, depending on how pedantic we’re feeling today) that can be used to teach freshly weaned babes the intricacies of software engineering. Well, no. But it packs a lot of ideas into a fabulously simple and straightforward system.

In Scratch, you build your programs out of interlocking puzzle pieces. There are loops and conditionals, which contain a little opening (which expands as needed) to hold other pieces. It basically encapsulates the idea of curly braces. Conditional statements have a hexagonal hole, into which only a conditional test can be fitted. Conditional tests are hexagon-shaped pieces which have oval holes, into which only variables or numbers can be placed.

The upshot is that it’s impossible to make a syntactically incorrect program. There is no way to make invalid code, which allows the would-be programmer to focus exclusively on structure and logic. It’s obvious how everything fits together, so the student gets a feel for program structure without needing to muck about with ideas like scope and indentation. Once they see the real thing (like, some C++ or some Python) they should be able to recognize and intuit what it does instead of seeing it as a big bunch of random symbols and crap.

The language is object-oriented and (this is the kicker) multi-threaded. You begin by dragging little clip art into your scene. You can use the prepackaged art, import your own, or draw something new using their editor, which is only slightly more robust than MS Paint. You can then edit the code for that specific object. You can have it move around, interact with other objects in the scene, respond to keyboard or mouse input, or passively wait for events triggered by other objects.

scratch1.jpg
I fiddled around with and and was astounded at what you can do with it. There are a lot of very simple things you can’t do, but there are a lot of powerful things you can do.

I made a very simple program that has two fish swimming around a scene. The larger, slower fish attracts to the smaller one, which zips around the scene in random arcs, bouncing off the edges as necessary. If the big one touches the small one, it “eats” the smaller fish and grows slightly larger. I also made some purely cosmetic transparent bubbles that float up the sceen, but only because I’m a slave to graphics spectacle.

Simple stuff, really. Here is the code for the big fish:

scratch_code1.png

And here is the code for the little one:

scratch_code2.png

I have two daughters, ages nine and eleven. The youngest, Esther, is our dreamer. She devours books at an absurd pace. (We’re talking young-adult fantasy stuff here, not highbrow technical stuff.) She’s read more books at nine than I had by twenty. (Which isn’t that big a challenge, but still.) She draws and sings and creates stories and is completely uninterested in anything that might involve the use of numbers. She approached me a few weeks ago, wanting to know about programming.

I suspected that she was only interested in the subject because she wanted to understand what I did all day. I was only too happy to humor her, figuring she would get bored and go back to reading books once she saw how dull code is compared to what does.

After cramming a few basic ideas into her head (and some number theory, because she was attentive and I wanted to see what she’d do with it) I set her loose with Scratch and she went on a four-day programming bender.

Things Scratch teaches:

  1. Object oriented design.
  2. Basic programming logic and understanding the flow of execution.
  3. The importance (or at least, utility) of setting initial values for variables.
  4. The difference between global and “member” variables.
  5. Programming is debugging.
  6. Programming is fun.

I recommend Scratch to anyone who is curious about coding. Even adults. Sure, the clip-art stuff is kinda cheesy, but it’s easy to put a few bits together and make things happen. My daughters had a blast with it and they’ve never done anything remotely like coding before. I had fun with it and I’ve been coding in one form or another since 99 Luftballons was on the charts.

Enjoyed this post? Please share!


20203Feeling chatty? There are 43 comments.

From the Archives:

  1. KarmaDoor says:

    This seems very similar to the approach taken by the Alice language. Both are aimed at newcomer coders; Scratch at younger ones and Alice at older ones with more preconceptions.

  2. Rutskarn says:

    Aww. That’s easily the cutest thing I’ve seen all week.

    But yeah, I was put off programming by the fact that I can’t juggle various logical progressions in my head at once, which might have had something to do with the fact that I was both 8 years old and very, powerfully stupid.

    If I came back to it, I could probably, with herculean effort, re-learn parts of it before failing at the very next level.

  3. Curious says:

    I would be curious to know what a kid of 9 year old is able to do with Scratch in 4 days.

  4. Neil says:

    Very cool. It mostly gets rid of “you forgot to close a parentheses here” or “you hit the comma button instead of the period button here” kind of errors that can drive inexperienced people up a wall.

  5. Daniel says:

    I am curious about the same thing that Curious is curious about.

  6. koew says:

    Scratch reminds me of the trigger-events in the desktop game making applications Games Factory and Click & Create.

    I spent hours upon hours with those apps during my teens, and it really made me develop an interest in programming.

  7. chabuhi says:

    I bought Colobot for my son a few years ago. He didn’t get into it, but I totally did. I already had some training in a couple of languages, so Colobot was pretty elementary for me, but I absolutely think it’s a great and fun teaching tool for kids (maybe even adults) just starting to learn programming.

  8. mockware says:

    I started my 9 year old girl on Lego mindstorms and she really enjoyed that. It uses the puzzle piece achitecture for programming the robot brain and she really enjoyed that. Thanks for showing this to me. I’ve downloaded it and my unsuspecting 9 year old will find another odd application on her computer. When I was a kid, I was poking and peeking into memory to make a sprite move clumsily accross the screen of my commodore 64.

  9. Unbudgingprawn says:

    It’s also similar to the Lego Mindstorms program. It takes the Tinkertoys approach of having the pre-built “modules” that you can just plug in to your code, but deals mostly with controlling robots rather then the general programming that Scratch is good for.
    Scratch is a fun program though. I work at a youth center that has a computer lab, and many of the kids love playing with Scratch. Sometimes it’s more popular then the RPG Maker program
    Finally: http://www.c-jump.com/

  10. Spider Dave says:

    We talked about this sort of thing in a course I took last semester. At my school, the fundamentals of programming are taught with either Java or C, but if you are instead taught with a visual programming language (Alice and Gem-Cutter were the ones introduced here) wouldn’t it be easier to learn all the concepts? You’re still learning about loops and arrays and lists and all that fun stuff, without having to worry about tricky syntax, curly braces, or semicolons. Definitely a good way to teach programming, I think.

  11. Samrobb says:

    Woot! Thanks, Shamus. I’ve got an extremely geeky bright 9-year old that I’ve been wanting to introduce to programming… I think this is just what I needed :-)

  12. Badger says:

    I actually had the opportunity to visit the MIT lab where they created Scratch- the “Lifelong Kindergarten”, they call it, and it’s an amazing place. We got to beta-test Scratch back in 2006, before they released it to the public, in order to get feedback from educators.

    And yes, it does look a lot like the Mindstorms software, because they helped to develop that, as well. In addition, they’ve built a very cool product called Crickets, which you can buy as kits for kids (although since they are sold as educational gear, the price is a bit stupid, and I’d recommend Mindstorms instead for the same price point).

    And if you ever get the chance to visit the Lifelong Kindergarten, do it. It’s an amazing hacker space, filled with LEGO and servos and machinery and people who have a lot of fun.

  13. radio_babylon says:

    kids today are so spoiled. the first program i ever wrote was entered with switches on a computer i built (assembled, not designed) myself… (yes, really…) then i walked uphill in the snow both ways to school… (not really)

  14. Sounds a lot of fun. Might well try it when I’m not so crazy busy!

  15. Inquisitor says:

    It really reminds me of Wiremod, a mod for Garry’s Mod(which, for those who don’t know, is a sandbox mod for Half-Life 2). It’s not as child-friendly as this, but it does present elements of coding and arithmetic in a visual form, as well as providing some neat things that mesh with the physical sandbox of the vanilla game.
    For example, I recently used Wiremod to create a drivable hovercraft in the game. It checks to see if it’s within a certain range of the ground, and adjusts its height accordingly.
    These sort of things are wonderful for those of us who have an interest in computer science but are not so savvy on non-visual media.

  16. Joe Weaver says:

    My wife used Scratch when she taught a computer literacy class for middle schoolers. The kids loved it and created some pretty nice projects. Many actually installed it at home so they could play with it more. Parents of children not in the class would call her to find out how they could use it.

    So yeah, Scratch is pretty awesome.

  17. Anachronist says:

    I echo Curious and Daniel’s question: Shamus, did your 9 year old kid come up with anything interesting in 4 days? I’m curious to know what happens if you remove the obstacle of having to learn a programming language syntax and let imagination take over.

  18. g. says:

    This looks like sk8 – only a little more compatible with current systems ;)

    Thanks!

  19. […] are keyed in such a way that it is impossible to create a syntactically incorrect program. Via this guy, who includes a sample program and talks about how his nine year old daughter learned and used the […]

  20. Johannes says:

    Cool! I’ll be checking this out, even though I no longer program for a hobby. There’s still some love left, and that’s why I run Linux and will check out Scratch.

    Oh, and I might introduce this to my two sisters as well, one of which is, ah well, almost not computer-illiterate (she knows how to turn the thing on and off, and runs MSN).

  21. Yar Kramer says:

    Hmm. I’m not new to programming as such (I’m halfway-decent with Java and PHP and MUSHcode), so I’m not sure what it might have to offer me, but it definitely looks like a good tool for abject-newbies.

  22. mark says:

    If your daughter doesnt mind sharing, we’re all curious to see what she’s been making in scratch!

  23. Carra says:

    Ugh, they actually made an English version of 99 luftballons?

    And I learned to program by reading through the Amstrad 464 manual. It contained example programs in Locomotive Basic. I remember that one of those was a program to write Sierpinski triangles. I had no idea what it was at the time but it sure was pretty. And then trying to find out where you made a mistake while typing in three pages of code…

    It was fun to be able to draw lines by just typing “Draw x,y” or make sounds by “sound tone, volum”. Ah, simpler times.

  24. Yeah, it does seem very similar to Alice – someone mentioned it before.

    I was a bit dissapointed though that you didn’t include a sample of what your kids came up with during their adventures with Scratch. Did your daughter actually seem to grasp some of the concepts the tool is teaching after 4 days? Does the level of abstraction the tool provides appropriate for that age?

    Also, does it give her a new appreciation for what you do? Does she seem to understand that daddy is not just sitting there and typing cryptic codes into the computer all day, but building complex abstract systems?

    In other words, we know the tool is fun but does it work? Do your kids seem to grasp programming better now?

  25. RedClyde says:

    Once I started “real” programming in College I realized what great practice (logic-wise and stuff) RPG Maker had been.

    But then again, programming is basically nothing more than algorithms, sets of instructions. Everybody uses algorithms everyday, whether they realize it or not, so I wonder why some people have so much trouble with programming… I know several really smart people – smarter than me, certainly – that have a hard time grasping programming. Maybe it’s the translation and organization of said instructions into the actual programming languages?

  26. Joe Weaver says:

    I can say that a bunch of my wife’s students (12 years-ish olds) ended up understanding at least the general notions of iteration and conditional execution. At the very least, it gave them better scaffolding for later education.

  27. Adalore says:

    Whooo! I made the cat move when I pressed wasd, and meow when I press space, Glllleeeee…

    I must learn more… must learn how too program, well at least I want too, though I am not sure why making the cat move made me soo happy, maybe it’s that now I can bend our robotic overlords too my WILL!

    BWAHAHAHAHAH!

    If RPG maker works well for learning the logic, maybe I’ll also mess around with that, I did before but really, I had no real story to try to tell. (Plus now, I can draw custom sprites and effects if need be.)

    I’d like too see what she did too.

  28. _underscore_ says:

    This reminds me of the incredibly old and obscure ZZT-OOP “programming language” for some reason.

  29. Telas says:

    As someone who doesn’t ‘grok’ programming, but has changed a tire without a jack and jerry-rigged a fix for a thermostat cover’s broken/frozen bolt, I find this simply amazing.

    Suddenly it all makes as much sense as a differential. (The pumpkin on a car’s axle, not the equation.)

    But then again, I guess I’m a visual learner or very mechanically inclined.

  30. Hipparchus says:

    This looks like a good way for me to get into Programming. I’m more of an artsy person, with writing stories and such, but I have always been interested in creating programs, video games, etc. The only programming know-how I have is RPG Maker :P. And don’t get me wrong, RPG Maker 2 programming language took me awhile to learn but now I can crank scripts freehand. The following is an example. Line 1 Screen Display: Message: “See?” Line 2 Input Creation: Multiple Choice: 2 “Yes””No” Line3 ScriptBranch InputVariable=1 Screen Display: Message: “Good.” Party: Posessions: +1Potion Input Variable=2 Screen Display: Message: “Well why not?” Line4 ScriptBranch end.
    Not perfect, but pretty darn close, I think. (By the way, does C or Java look or follow similarly to RPG Maker? I know RPG Maker is easier, but is it a different beast all together?)
    But reading about Shamus making a Terrain do-dad, Pixel City, programming for a living and me reading XKCD, which makes programming look as exciting as Shamus does, makes me want to learn somehow. Scratch seems good to accomplish this goal. Thanks for sharing! :)

  31. Martin Annadale says:

    Awesome find, Shamus. This was exactly the kind of thing I was looking for. My younger brother (14 years younger than me) has never been hooked by programming, despite seeing me do from a young age. I see this as a major character flaw in an otherwise ok personality. I mean this guy devours fantasy books and every single game made by bioware ever, so he’s not a bad person. But the whole “can’t program” thing is a real let-down. Hopefully this will get him started. And my daughter might like it as well, in a few years, when she can read and write and talk and well walk.

  32. Han says:

    If you’d like to know more about the year of 99 Luftballons

  33. Noumenon says:

    I was a bit dissapointed though that you didn’t include a sample of what your kids came up with during their adventures with Scratch.

    I was disappointed that he didn’t provide a link to the program he wrote so I could see the fish move. After that the code would make a lot more sense.

  34. Doug O. says:

    Heh. I’m going to see what the Lovebug (10 yo) does with this. Just have to get her interested.

  35. Mari says:

    Thanks, Shamus. My 11-year-old daughter downloaded it and has been obsessed for a full 24 hours. It was good timing because only three days ago she asked how she could learn to make her own computer game.

    Luckily she inherited her father’s much more logical mind so I think this will be just the stepping stone she needs. Hey, maybe Scratch can teach me to be more logical…

  36. Sweet! I’m also a big fan of Ken Kahn’s ToonTalk, a visual, concurrent programming language with 3D animated characters.

  37. TickledBlue says:

    Nice. Reminded me a little of Construct, but that’s not so much a tool to teach programming as a game creator aimed at visual designers rather than coders.

  38. Alex says:

    I got a kick out of “Set (Fatness) to [50]”.

  39. Kayle says:

    Looks like an interesting approach for a visual programming language. It’s tickling at a memory of something I saw on the Macintosh in the late 1980s… I tried to find it through Google, but nothing is quite right, though I did find ProGraph which was about the same time.

  40. […] Considering over half the “language” consists of dragging and dropping icons, does Scratch […]

  41. mand says:

    RedClyde (if anyone’s still reading this comment thread), what you say about the trouble people have translating algorithms into the syntax needed for a computer to use them: reminds me of my first experience with formal logic.

    I found it straightforward but most others struggled – all of them very bright people and most good at reasoning and being ‘logical’ in everyday life. Those who took to it found it easy to ‘unfold’ the steps of the logic, but difficult to put the statements into the notation in the first place.

    They were all studying ‘artsy’ subjects rather than sciences; i’m a linguist, but not of the artsy type, more grammarian, so i suppose that’s why both the reasoning-steps side of it and the turning-natural-language-into-notation side of it seemed normal to my mind. (I tend to think visually in chunks of meaning that i move around according to sometimes complex rules.) Very few people can describe the grammatical rules they use all the time in speaking, though they immediately recognise ‘wrong’ usage.

    Ooph, that came out longer than i expected, but just thinking it may throw some light on what you’re thinking. Or what you were thinking, back in July. ;0)

  42. Zyzzyva says:

    Very cool stuff. I’m pretty hardcore about my CS, but my French-Major gf liked it and understood it pretty well, so I’m definitely impressed.

    Speaking from the more experienced programming side: it would be nice if there was some way to spawn more sprites, although I appreciate that that would be easy for newbies to accidentally abuse and slag the simulator. It would also be nice to pass data in messages (rather than just have everyone checking global variables all the time). And of course an easy way to define new blocks would be useful. (And maybe a kind of “define class/datatype” feature – maybe it could procedurally generate for each class its own lock-and-key shapes to maintain the guaranteed syntactic correctness?) Given all that I could definitely see this as fun to play around with at a higher level: I like programming and I think visually but nothing visual has more utility than eg FORTRAN II with concurrency. Scratch Advanced would definitely be a nice thing to use.

  43. destinysWalrus says:

    I like Scratch, found it when trying to make a quick game for one of my (history, I think) classes. I do know a bit of several programming languages, as a result of every one of my programming classes deciding to use a different language.

    What particularly appeals to me about Scratch is the puzzle pieces. It makes it so much easier for me to figure out how things fit together if I’m literally putting pieces together.

    Though I have to admit for most projects of mine I probably will use the usual typing-stuff languages instead of Scratch – I do enjoy the typing after all.

2 Trackbacks

  1. […] are keyed in such a way that it is impossible to create a syntactically incorrect program. Via this guy, who includes a sample program and talks about how his nine year old daughter learned and used the […]

  2. By Lingua Programmatica - Twenty Sided on Mon Mar 29, 2010 at 10:31 am

    […] Considering over half the “language” consists of dragging and dropping icons, does Scratch […]

Leave a Reply

Comments are moderated and may not be posted immediately. Required fields are marked *

*
*

Thanks for joining the discussion. Be nice, don't post angry, and enjoy yourself. This is supposed to be fun.

You can enclose spoilers in <strike> tags like so:
<strike>Darth Vader is Luke's father!</strike>

You can make things italics like this:
Can you imagine having Darth Vader as your <i>father</i>?

You can make things bold like this:
I'm <b>very</b> glad Darth Vader isn't my father.

You can make links like this:
I'm reading about <a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth Vader</a> on Wikipedia!

You can quote someone like this:
Darth Vader said <blockquote>Luke, I am your father.</blockquote>