|This page has links to websites or programs not trusted by Scratch or hosted by Wikipedia. Remember to stay safe while using the Internet, as we can't guarantee the safety of other websites.|
Smalltalk is an object-oriented programming language that was released in its first version, Smalltalk-80, in 1983. It was developed by the Learning Research Group of Xerox PARC for educational use. The current version of Smalltalk, released in 1998, is ANSI Smalltalk. Some Smalltalk implementations include:
- Pharo is a fork of Squeak and the only differences are that they provide more frequent updates, they changed the system menus and windows slightly, and they removed some of the unnecessary code (along with some other minor changes). It can be downloaded here.
There are many other Smalltalk implementations, and a list can be found here.
Classes and Instances
- "Class" redirects here. For the page about Student and Teacher accounts, see Student and Teacher Accounts.
- See also: Squeak Tutorial#Classes and instances
A class represents a type; every Smalltalk object, including numbers, strings, lists, blocks, the stage, sprites, and even classes themselves, is an instance of a particular class. Every class, except for Object, the root class, has one superclass, which it inherits methods and variables from, and a class may have any number of subclasses, which inherit from it. Each class has a class comment, which is a description of the class.
Messages and Methods
- See also: Squeak Tutorial#Methods
In object-oriented programming, objects communicate by message passing. When one object sends another a message, the object then invokes the corresponding instance method of its class. Methods define the behavior of objects. Smalltalk also has class methods, which are invoked when a class receives a message.
A method may have temporary variables, which are variables that are used only by the method and do not persist. It is also possible to add class and instance variables to a class. An instance variable is a variable that is local to each instance of a given class. A class variable is a variable that the entire class shares and can be accessed by both instance and class methods. One can also use global variables, variables which are global to the entire Smalltalk application. Variables are modified using the assignment operator,
variable _ value.
The System Browser
- Main article: System Browser
The leftmost column lists categories of classes, to make classes easier to find; the second column lists classes; the third lists message categories; and the rightmost lists messages. The question mark is used to display or edit the class comment of the selected class.
- Main article: Morphic
The user interface framework of Squeak is Morphic. Morphs are the basic graphical objects displayed on the screen. A new morph can be created by selecting "new morph…" in the World Menu, or by evaluating
Morph new openInWorld (substituting the name of the class for Morph) in a workspace. They can be sent messages, such as
aMorph position: 200@200 or
aMorph color: Color red,
An image stores the state of Smalltalk. Scratch 1.x, along with most modifications, are distributed as image files. These files contain all the necessary information to draw the user interface and interpret code. However, they do not contain source code, which is stored separately as two files, SqueakV2.sources and the changes file.
Opening an Image
An image file can be opened with any Squeak virtual machine, such as the Scratch application or any modification's application. Simply double click the file on the hard drive. If an application to choose is requested, choose Scratch.
Editing an Image
- Main article: Shift-Click-R
The open image can be edited by shift-clicking the loop of the "R" in the Scratch Logo and selecting "Turn fill screen off". Clicking on the gray area will bring up the World Menu. Click "open…", then "browser" to open the System Browser, which contains the source code. It can then be edited. Shift-clicking the R again and selecting "save image for end user" will close Scratch and save the changed image file.