Scratch Source Code
- Understanding how Scratch works
- Building future versions of Scratch
- Making Scratch modifications
The Scratch 2.0 source code is now officially available on Github here. It is written in ActionScript and now provides the necessary tools for users familiar with the language to create mods of Scratch 2.0. From the source code page, users can view the pull requests for Scratch 2.0 as well as analyze the current issues that need debugged.
Prior to the Release
Before the release of the source code on May 13, 2014, the source code could only be viewed on a user's computer in compiled form. Compiling takes a human-friendly or high-level language and converts it directly into binary code. The uses of compiled code are as follows:
- Faster execution
- Smaller storage space
- Unavailability to access the original source code in its original form (some decompiler a work around this)
However, Scratch is and always will be open-source, and every update to the source code can be viewed on Guthub.
The Smalltalk code can also be viewed from the compiled image, but is less understandable.
Compiled Smalltalk code is when the original is changed (by the computer; the programmer does not do any of this) to remove the comments, change all the variables to shorter names, and to remove any indentations. For example, this Smalltalk method in the original source code:
aSmalltalkInitializationMethod |foo bar baz| "Initialize me." foo := 'a string'. bar := 'another string'. baz := AClass new. baz := openInWorld. ((anInstanceVariable = foo) or: [anInstanceVariable bar]) ifFalse:[ (2 atRandom = 1) ifTrue:[ anInstanceVariable := foo.] ifFalse:[ anInstanceVariable := bar.].].
Might end up looking like the following in the compiled version:
aSmalltalkInitializationMethod |t1 t2 t3| t1 f := 'a string'. t2 br := 'another string'. t3 bz := AClass new. t3 := openInWorld. ((anInstanceVariable = t1) or: [anInstanceVariable t2]) ifFalse:[ (2 atRandom = 1) ifTrue:[ anInstanceVariable := t1.] ifFalse:[ anInstanceVariable := t2.].].
The way source code (in Smalltalk) is compiled is when the .sources file is deleted.
- "License" redirects here. For the license Scratch projects are published under, see Scratch Project License.
There are two different versions of the source code, available under two different licenses and intended for different purposes. The first, available since Scratch was created, contains a non-branded image file with a generic sprite and no uploading. This is released under the Scratch Source Code License. Another version, added in March 2012, is licensed under the GPLv2 license. It contains all of the media included with the regular Scratch distribution and was created to make it easier to put versions of Scratch on open source repositories, especially for Linux distributions.