Scratch Wiki > Scratch Source Code

Scratch Source Code

This page includes information about the source code for Scratch, a project and product of the Lifelong Kindergarten group of the MIT Media Lab.

Before downloading the source code, please be sure that you understand the terms of the Scratch source code license (see discussion below).

Download

Download: ScratchSource1.4.zip (4.8 megabytes)

This source code release is based on the source code of Scratch 1.4 with a few changes:

  • the Scratch logo was replaced
  • the default sprite is a generic cat, not the official (copyrighted) Scratch cat
  • the project sharing code was removed

The download consists of a Squeak image and changes file. To view the source code, just drop the .image file onto a Squeak virtual machine (e.g. Scratch.exe or Scratch.app, which come bundled with Scratch). If you are new to Squeak, see the "Scratch and Squeak" section below.

scratch cat icon Scratch Plugins

ScratchPlugin is a Squeak plugin (a shared library that extends the Squeak VM) written in C that supports image filters, presentation mode, the help button, and several other features. Scratch will not crash without ScratchPlugin, but these features will not work. UnicodePlugin is a Squeak plugin that support Unicode text rendering. The ScratchPlugin and UnicodePlugin source code (for Windows, Mac OS X, and Linux) is here:

ScratchPluginSrc1.4.zip 

The Linux code has not yet been fully tested by the Scratch team. It's mostly complete, but it may need a few minor adjustments.

scratch cat icon Scratch UI "Skin"

The Scratch User Interface uses a number of graphical elements. These are stored in a Dictionary in the ScratchSkin class variable of ScratchFrameMorph. The readSkinFrom: class method can be used to read in the graphical elements from a folder. Here's the skin folder:

ScratchSkin1.4.zip

About the Scratch Source Code

scratch cat icon Product vs. Research

Scratch is two things at once: an educational software product and a research project.

The Scratch product is designed to serve the needs of a specific target audience: youth and others who wish to learn and use programming for creative expression. Like any software product, Scratch will evolve over time, with a strong focus on stability and serving the needs of its core audience.

As a research project, Scratch explores ways to use visual programming and user interface design to make programming easier for non-experts. There are dozens of possible directions for future Scratch research, such as modifying the software to run on mobile devices, adding new data types and data structures to the programming language, and applying Scratch scripting ideas to other application domains. Research projects are different from products: they evolve quickly, explore new territory, and may never become as polished, stable, or well-documented as a product. Research projects move faster and farther when they are not held back by product concerns.

Since the Scratch team cannot possibly explore all of the potential research directions suggested by Scratch, we are making the Scratch source code available so that others can also explore and experiment. But please note that the source code license includes certain restrictions intended to avoid confusion between the Scratch product and research projects built on the Scratch source code. If members of the Scratch user community stumble on a research project based on the Scratch code, they should be able to tell at a glance that it is not the Scratch product.

scratch cat icon The Scratch Source Code License

The Scratch source code license allows you to distribute derivative works based on the Scratch source code for non-commercial uses subject to the following restrictions:

  1. you cannot use the word "Scratch" to refer to derivative works (except in the phrase "Based on Scratch from the MIT Media Laboratory"),
  2. you cannot use the Scratch logo or the official (copyrighted) Scratch cat in derivative works,
  3. you cannot implement the ability to upload projects to any MIT Scratch website (currently, http://scratch.mit.edu),
  4. copies or derivative works must retain the Scratch copyright notice and license, and
  5. you must make the source code for derivative works available.

This is just a summary; the full license is in the file "license.txt" included in the source code download package.

The purpose of these restrictions is to avoid confusion in the Scratch user community between the official version of Scratch (supported by the Lifelong Kindergarten group) and experimental variations. We are happy the share our source code, but we want to protect the Scratch brand and our user community.

We hope you will appreciate the reasons for these restrictions.

scratch cat icon Development of the official Scratch product

Although we are publicly releasing the Scratch source code, we maintain full control over the development of the Scratch software product. We are not actively seeking code contributions for the Scratch product - though, in future versions of the product, we could decide to incorporate code developed by others. We welcome bug reports and feature suggestions on the Scratch Forums.

scratch cat icon Scratch and Squeak

Scratch is written in Squeak, an open-source implementation of the Smalltalk-80 language. The Scratch source code is best explored using the browser and other tools inside the Squeak programming environment.

To get started, first copy the Scratch application ("Scratch.exe" or "Scratch.app") from your normal Scratch folder into the Scratch source code folder. (The Scratch application is actually just a Squeak virtual machine, so any recent Squeak virtual machine should also work.) Also, put copy of the Squeak source code file in that folder if needed (this file is included in the zip file starting with the 1.4 source release). Finally, drop the file "ScratchSourceCode1.4.image" onto the Scratch application. The Squeak programming environment will start up, allowing you to view and modify the Scratch source code.

Scratch is built on a modified Squeak 2.8 image. That version of Squeak is documented in two books: "Squeak: Object-Oriented Design with Multimedia Applications" by Mark Guzdial and "Squeak: Open Personal Computing and Multimedia" edited by Mark Guzdial and Kim Rose. To learn more about Squeak, including how to use the Squeak environment to explore the source code, see www.squeak.org.

Since Scratch simply uses a stock Squeak virtual machine, we are not distributing the Squeak virtual machine source code. Both the source code and pre-compiled binaries for the Squeak virtual machine are available at www.squeakvm.org.

The non-Scratch portion of the Squeak image file is distributed under the Squeak License. Which parts of the image file are Squeak and which are Scratch? The rule is that classes that appear in the original Squeak 2.8 image are covered by the Squeak license while all code in the remaining classes is covered by the Scratch license. The Scratch classes are easy to find in practice: nearly all of them appear in the class categories starting with "Scratch-".

scratch cat icon Documentation and Questions

Source code documentation is embedded in the code as class and method comments. In addition, here is a short text file describing the Scratch project file format. Since the Scratch source code is not intended for public consumption, you should not expect the level of comments or API documentation that you get with a system such as Java, where the whole point is to help developers build on its class library. Frankly, if we waited to release the Scratch code until it was all thoroughly and beautifully commented it would never get released.

We will try to answer quick questions about the source code posted via the contact form. However, you may get a faster response by posting to the Advanced Topics forum.

The best way to get answers questions about Squeak and Smalltalk-80 is to ask on the "Squeak-dev" mailing list; see the "Squeak Mailing Lists" link at www.squeak.org.

scratch cat icon Older Versions

Scratch 1.2 Source:  

Scratch 1.3 Source: 

Tag page
You must login to post a comment.