(Redirected from Source Code)
- Understanding how Scratch works
- Building future versions of Scratch
- Making Scratch modifications
|This article or section contains information about a feature from a future version of Scratch that is unreleased and is subject to change. Please cite any additional info in order to prevent speculation.|
- scratch-blocks - Blocks
- scratch-render - WebGL Rendering
- scratch-vm - Scratch Virtual Machine
- scratch-gui - GUI
- scratch-paint - Paint Editor
- scratch-audio - Audio Engine
- scratch-l10n - Translations
- scratch-storage - File Support
- scratch-parser - SB2 Parser
- scratch-auth - Authentication
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 GitHub.
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:
|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:
|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.