(Redirected from Eng:Squeak)
|This page has links to outside of the Scratch website or Wikipedia. Remember to stay safe when using the internet as we can't guarantee the safety of other sites.|
Smalltalk is an object-oriented programming language that was released in its first version, Smalltalk-80 in 1972. It was developed by the Learning Research Group of Xeroy PARC for educational use. The current version of Smalltalk, released in 1998, is ANSI Smalltalk. Some of the Smalltalk implementations include:
- Squeak is a Smalltalk implementation by Disney and is derived directly from Smalltalk-80, the first copy of Smalltalk ever released. It can be downloaded here. Squeak Smalltalk was used to implement the Scratch Development Environment from version 1.0 up to Scratch 1.4. Since Scratch 2.0 Flash is used instead of Squeak Smalltalk.
- 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.
The System Browser
- Main article: System Browser
You can browse, create and edit methods (blocks) along with defining a new object, giving it variables, and using methods like you can in BYOB.
This is what the Squeak System browser (in Scratch) looks like:
The string in the first pane (Scratch-UI-Panes) is just an non-vital categorizer to make things easier to find. The one in the second pane is the name of the class, the third is another category, and, the last are the methods themselves.
- Main article: Squeak Tutorial#Methods
Methods are Squeak's procedures, similar to the blocks in Scratch. It is easy to define your own. In fact, there is, in a way, no 'Scripting Pane' and the methods are called on by each other or when an event happens. You can even program a method to call on itself (like in BYOB), creating recursion.
Classes and Instances
- Main article: Squeak Tutorial#Classes and Instances
Classes and instances are the core concept of OOP (Object Oriented Programming), and what also makes it more like the real world. For example, say there is an abstract idea of the Car class. That red car on Main Street is an instance, or specimen of Car, whereas the blue car on Maple Drive is another yet separate instance of the same class, Car.
There is also the concept of subclasses and superclasses: a subclass is a class that inherits its methods from another class, called its superclass. In simpler terms, the previously mentioned red car on Main Street might be an instance of VWBeetle, which is a subclass of Car. The vehicle on Maple Drive could be an instance of the class ChevyBlazer, but neither the Blazer nor the Beetle are directly instances of Car, although they inherit all the methods of Car.
You can also add class and instance variables to a class, and it will deal with them accordingly. An instance variable is a variable that each instance (of a given class) will get a new one, and will be able to set it to whatever it needs to via the methods on the instance side.
A class variable is a variable that the entire class shares and can be accessed through either side. You can also use Global variables which are global to the entire Squeak application.
- Main article: Squeak Tutorial#Morphic classes
The graphics system used in Smalltalk is called Morphic. Morphic creates new morphs, which are objects to be displayed on the screen.They can be given commands, such as
self forward: 10 or
self color: Color red. To create a new Morph, the following code is used:
class new openInWorld.
IMAGE file is a source-code "image" on Squeak. The Scratch 1.x series, along with any modifications, use
IMAGE files for the sources. These files contain all the necessary information to draw the GUI, and interpret code.
Opening an IMAGE File
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 your hard drive. If you are asked to choose an application, choose Scratch.
Editing an IMAGE File
- Main article: Shift-Click-R
IMAGE file 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