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.
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:
And here is the code for the little one:
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:
- Object oriented design.
- Basic programming logic and understanding the flow of execution.
- The importance (or at least, utility) of setting initial values for variables.
- The difference between global and “member” variables.
- Programming is debugging.
- 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.
Shamus Plays LOTRO
As someone who loves Tolkein lore and despises silly MMO quests, this game left me deeply conflicted.
What Does a Robot Want?
No, self-aware robots aren't going to turn on us, Skynet-style. Not unless we designed them to.
The Mistakes DOOM Didn't Make
How did this game avoid all the usual stupidity that ruins remakes of classic titles?
The Strange Evolution of OpenGL
Sometimes software is engineered. Sometimes it grows organically. And sometimes it's thrown together seemingly at random over two decades.
In Defense of Crunch
Crunch-mode game development isn't good, but sometimes it happens for good reasons.