Programming with Scratch

As a homeschooling parent, I'm a big fan of educational software and I've written quite about about various programs in the past. But, as a programmer, I'm also a big fan of any program that makes computer programming more approachable by younger children. So, when I heard about Scratch, I was pretty enthusiastic. (Thanks, Mitch)

Scratch allows the user to write programs by dragging and connecting simple programming instructions. The programming instructions resemble puzzle pieces and will only “fit” together in ways that make semantic sense. For example, you can't put the “Start” instruction inside an “If” instruction. The instruction pieces are also color-coded according to what type of instruction they represent; all control structure pieces are yellow, while all motion pieces are blue. The program that the user creates controls one or more objects, or sprites. From a programmer's perspective, Scratch has a very sophisticated set of instructions, as we'll see soon.

Scratch comes with a number of example projects that provide a fairly broad sample of what can be done with Scratch.

Once a user has created a program that they like, they can share their project with others via the Scratch Web Community at As I write this, just under 1.1 million projects are available for download! Some of these projects are obviously done by young users and are very simple. Others are quite sophisticated.

Broadly speaking, Scratch projects fall into 3 different categories. Some projects are simply animations or stories that play out within Scratch. One of the example animations that come with Scratch tells the story of a little girl who is so frustrated by email spam that she calls her Congressman to suggest that a law be created to outlaw sending spam. The Congressman proposes the law, The House signs it. The Senate modifies it and sends it to the President. It's just a neat little story. Obviously, there wasn't any intense programming needed.

The Interactive Art projects range from kaleidoscopes, to paint programs, to dress-up games. The kaleidoscope example project lets the user move a cursor around the canvas using the arrow keys. The program then duplicates the user's movements to create interesting patterns.

Then there are the game projects. In about an hour, I whipped up a simple Pong program. Others have “whipped up” 3D combat flight simulators! One of the more simple, but engaging games that I found was a virtual obstacle course where you guide a little green ball around with the mouse and try to avoid moving obstacles. This was a very simple game, but I spent more time playing it than I care to admit.

The Scratch user interface is intuitive, though perhaps a bit limited. Figure 1 (Figure 1.) The interface breaks out cleanly into 3 columns. The left column is what you might refer to as a “pallet” that contains the various instructions that the user can choose from to build a program. At the top of the pallet is a group of buttons that select which type of instructions to display below. Here you can see that the “motion” instructions have been selected.

The right column of the interface is divided into two parts. The top part is the “stage” where all of the action takes place. The bottom part contains one or more sprites that are used in the program. By selecting a sprite, the user can then write a program to control the sprite's actions.

The center column is where the actual programming takes place. The user simply drags programming instructions from the pallet into the center column and connects them together to build up one or more programs that control the current sprite, which is displayed at the top. Figure 2(Figure 2.) The current sprite can also be resized and rotated as needed.

As I implied earlier, each sprite can have one or more programs that control it's behavior. Typically, you'd have a main block that runs when the program starts. You could also have a block of instructions that run when the user presses the left arrow key; this block of code might move the sprite to the left, or it might cause the sprite to “fire” a weapon. Other blocks of code may execute when a sprite receives a certain message, either from another block of code, or from another sprite. My Pong game has a message handler that responds to the “score” message that gets broadcast whenever either player scores a point. The message handler simply resets the ball in the center of the field and starts it moving again. But by having multiple blocks of code running, either as main blocks, keyboard handlers, or message handles, you can write very sophisticated programs.

Scratch includes several different sprites in quite a few different categories. However, the user can also import their own graphics or use the built-in sprite editor. The build-in sprite editor is just like most pixel-based paint programs. The user has a selection of colors and tools to choose from and can rotate and resize a given sprite as needed.

Finally, each sprite can have multiple “costumes.” A costume is essentially a different version of a given sprite, perhaps in a different pose, or with a “power-up” affect applied. By switching costumes, the user can create, characters that appear to walk, characters that wear armor, or balls that appear to spin as they move. A sprite's costumes can be activated from within the programming.

In addition to having multiple sprites at once, Scratch allows you to change the background from within a program. This capability can be used to create different levels of a game or different scenes in a story, for example. Different backgrounds can be created in the same ways that sprites are created from within Scratch.

As you can see, there is a lot to talk about before we even discuss the programming institutions available to the user. As mentioned earlier, the programing institutions are broken down into eight categories. The “motion” instructions move and rotate a sprite in different ways. In the “looks” category, we find instructions for changing a sprite's costume and color. We also find instructions that allow the sprite to “say” and “think” messages to the user. In the sounds category, we find instructions for playing drum sounds as well as 128 different instruments and sound affects. The pen institutions give the user the ability to draw lines under program control, much like the Logo programing language. The control category is where we find our control structure instructions such as while loops and if statements. The sensing instructions allow the user's program to test the location of a sprite or the mouse pointer. In the “operators” category, we find arithmetic, boolean, and string operators that can be combined to form complex expressions. Finally, the “variables” instructions allow the user to create, display and manipulate scalar and list variables.

Given the power of the environment that Scratch provides its user, you can imagine that people are anxious to share their creations. Scratch lets users share them via the Scratch website, but there is also a Java interpreter that allows a user to embed their creation in a web page. I've also heard rumors on the forum that there is a Windows compiler that will turn a Scratch project into a stand-alone executable. In fact, if you go to the Scratch projects web page, you can actually test drive a project before you download it.

I only have one suggestion and one criticism of the Scratch program. For me, the programming area was way too small. I easily filled it and had to scroll around to see the big picture in anything but the most trivial of programs. Finally, it would be really really neat if Scratch could have even a simple networking stack. A networking stack would open up an entire universe of new opportunities for Scratch programing.

Since committing to write this article, I've spent a lot of time playing with Scratch, both with other people's projects, as well as my own. I'm still thinking of fun things to do with it as well as ways to integrate Scratch into our homeschooling curriculum. This is a program that you really need to check out.

fig1.png46.18 KB
fig2.png65.94 KB

Mike Diehl is a freelance Computer Nerd specializing in Linux administration, programing, and VoIP. Mike lives in Albuquerque, NM. with his wife and 3 sons. He can be reached at


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

what is sprite?

Anonymous's picture

what is sprite?

See: Sprite on Wikipedia

Anonymous's picture

App Inventor for Android

Anonymous's picture

App Inventor for Android (by Google) is "a derivated work".

"The blocks editor uses the Open Blocks Java library for creating visual blocks programming languages. Open Blocks is distributed by the Massachusetts Institute of Technology's Scheller Teacher Education Program and derives from thesis research by Ricarose Roque. We thank Eric Klopfer and Daniel Wendel of the Scheller Program for making Open Blocks available and for their help in working with it. Open Blocks visual programming is closely related to the Scratch programming language, a project of the MIT Media Laboratory's Lifelong Kindergarten Group."
[About App Inventor - On the Shoulders of Giants!]

See also: Sharing the Joy of Creating Android Apps with Everyone


Anonymous's picture

What about Laby? Isn't it about the same?

It seems similar to a

macias's picture

It seems similar to a programming game on Mac, it was released around 1987, I don't remember the name, but the main "character" in that program was robot with sunglasses. You wrote programs to get more cookies for him (it?).

creative thinking

josephy's picture

I should say scratch from MIT is creative.


Trent's picture

Nice review. I only have one complaint.

A palette is a flat surface for mixing paints on; or, by extension, anything that holds a set of tools for easy use. A pallet is a wooden frame that you stack goods on for transport by a forklift. (The palate is the roof of the mouth, and is pronounced identically to the above two, but is less likely to be confused with them.) Just sayin'.


Mike D's picture

Nice catch.

For Java programmers... Alice

Scott Dowdle's picture

Another programming language with a visual construction kit type interface is Alice ( It is based around Java and designed for High Schoolers... but I'm sure if you liked Scratch, you'd like Alice. so what's

Anonymous's picture so what's your take on the Illumination Software Creator then ?

This is so efficient

harbhag's picture

This is so efficient .

Are those screenshots from

Anonymousse's picture

Are those screenshots from MS-Windows? Isn't there a Linux version of this? Come on, eat your own dog food LJ contributors! ;-)

Yes, they are.

Mike D's picture

Yes, they are screenshots from the windows version, running under wine. I simply didn't want to install a bunch of required packages in order to install Scratch, only to (potentially) find that I didn't like it. Also, since my boys use a windows machine, I have a better frame of reference for what they will be using.

Great find, thanks

Jure Repinc's picture

This is a great find and I will sure add it to my toolbox of current programs I use when I sometimes teach the young about programming. Currently I use KTurtle for younger ones and later Greenfoot for a bit more advanced courses.

A really good alternative

mt66's picture

Try sugar, the window manager of the OLPC, only one world, amazing. In the list of activities you will find Turtle Art, a logo derived game. All together , a mix of irresistible diversion and discover for kids and not.


sugar Turtle Art and scratch/squeak

Ladislav Kocbach's picture

Walter Bender, who is the front figure of sugar worked for years at MIT Media Lab. The mentioned Turtle Art has a very simplified version of the visual programming available in Scratch. Scratch is running in Squeak, a Smalltalk environment. Sugar contains also e-toys, running also on Squeak, so your comment, "mt66" is basically more relevant than you realized, but with opposite sign. If you have played with Turtle Art, you have experienced what the Scratch has to offer, only on a very basic level. Turtle Art has only one "sprite", the turtle, Scratch can have as many sprites as you need (I have seen a 30 000 gas particles simulation in Squeak with extra libraries). And yes, they are very closely related. They have the same genes, so to say.

There is indeed an enormous potential in all these offerings. The visual and bugfree programming is one of the great features.

sugar and turtle art

kevix's picture

if you go to, the home of Turtle Art and the Sugar environment, there is a Scratch activity packaged for 'Sugar on a Stick' and Sugar environment.


vtr's picture

Hello! I found out some time ago a game that implies a lot of programming inside a game and you dont need even to read (all is done with simbols). The game is a flash game called "Alchemical engineering" from a guy that has a lot of games like that (games for engineers as he calls). Tehre you have to program a mechanical arm putting symbols on it to achieve a certain amount of objetives, very addictive, and its perfect to teach about the basis of programming

Other example is a game that you have to "program" a steam powered combat robot conecting pipes and playing with gas physics concepts. I showed the game to my 9 year old nephew, and he loved it.

here is the alchemical engeniering link:
and the steam robot:

he has a lot of great games like that.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot