Squeak
Squeak is based on principles of Live and Exploratory Programming
- direct code changes instant visual / auditory effects
Object Model
- Everything is an object
- classes are objects too
- class is the single instance of an anonymous class (meta-class)
- e.g.
Rectangleis sole instance ofRectangle class
- e.g.
- Only message passing between objects
- (Very) late binding
- All methods are public
- method lookup: starting at receiver class, then bubbling up the inheritance tree
- Instance variables are private to the object
- Class-based single inheritance
- Garbage collection
A few but powerful ideas and language constructs Small and extensible language

Syntax (excerpt)
- Messages
- unary:
receiver selector - binary:
receiver binary-selector argument - keyword:
receiver keyword1: arg1 keyword2: arg2 - Priority: unary > binary > keywords (same level from left to right | workaround: parantheses)
- unary:
- Arrays
- literal array:
#(1 2 3 (1 3) $a 4) - byte array:
#[1 2 3] - array:
{ Date today . Time now }- syntactic sugar mapped to
Array with: with:
- syntactic sugar mapped to
- literal array:
- Fractions:
1/33 - Comments:
"a comment" - Block:
[:var | | tmp | expr... ]- Anonymous function objects (storeable and passable)
- higher order functions: Closure / Lambda
- Lexically scoped
- Method annotation (pragma):
<...>- Primitive:
<primitive: ...>
- Primitive:
Class Definition
= a message sent to another class
Morph subclass: #CalculatorMorph
instanceVariableNames: 'first second result'
classVariableNames: ''
poolDictionaries: ''
category: 'Calculator'Method Definition
- usually defined in a browser (directly invoking the compiler also possible)
- always returns an object (default is
self)
ObjectSubclass>>descriptionForPartsBin
^ self
partName: 'Calculator'
categories: #('Useful')
documentation: 'Not yet...'Instance Creation
- Literal: e.g.
1or'abc' - General:
newwhich usesbasicNewand callsinitialize - Class specific: e.g.
Color orangeorColor r: 1.0 g: 0.6 b: 0.0
Self and Super
Similarities
- Refer to same object when used in same context
{ self. super. self == super }{ sameObject. sameObject. true }
- can be passed as arguments to a message
- rarely used for super
- can be assigned to variables
- rarely used
- can receive messages
Method Lookup
self:
- dynamic lookup at run-time
- search for method begins in instanceโs (receiver) class
- even if
selfis used by superclass method
- even if
super:
- statically determined at compile-time
- search for method begins in superclass of the class containing the method, in which
superwas used- not necessarily direct superclass of instance (reveiver)
Live and Exploratory Programming
Benefits of short feedback loops:
- understand code and its effect on the system
- check whether the program works as expected
- tests (unit, integration, acceptance)
- investigate bugs
- explore unfamiliar code
Programming system vs. programming language:
- Integration von Sprache und Werkzeugen in einer IDE

Framework
Morphic
#drawOn: aCanvas| draws an Morph or similar onto a canvs#handlesMouseDown: evtand#mouseDown: evt| override to handle mouse events#handlesKeyboard: evtand#keyDown: enEvent| override to handle keyboard events#addMorph: aMorph| adds a submorph
Observer
#changed: aParameteror#changed: anAspect with: anObject| inform all the dependents about a change on the receiver#update: aParameteror#update: anAspect with: anObject| override to receive a change notice from an object of whom the receiver is a dependent#addDependent: anObject| make the given object one of the receiverโs dependents
Prototype
#copy| executes#shallowCopyand then#postCopy#shallowCopy| returns a copy of the receiver which shares the receiverโs instance variables (sharing by reference)#postCopy| should be overridden by subclasses to complete the full copy
#deepCopy| returns a copy of the receiver with its own copy of each instance variable- recursively calls
#deepCopy - does not preserve object identities in cycles in the object graph
- recursively calls
#veryDeepCopy| does a complete tree copy using a Dictionary- an object appearing twice in the tree is only copied once
- all references to the object in the copy of the tree will point to the new copy