Learning from Smalltalk
Sasha Gerrand
@sgerrand
Programmer
Bigcommerce
Jim Weirich
1956 - 2014
ENV=reality rake vale:jim
What is Smalltalk anyway?
(isn't this a Ruby conference?)
Smalltalk
- is an object-oriented, dynamically typed, interpreted, reflective
programming language -
was created as the language to underpin the "new world" of computing exemplified by "human–computer symbiosis",
a popular theme in the 1960s
It was designed and created at the Learning Research Group (LRG) of Xerox PARC by Alan Kay, Dan Ingalls, Adele Goldberg,
Ted Kaehler, Scott Wallace, and others during the 1970s
Alan Kay
- One of the fathers of object-oriented programming
- Architect of the modern windowing graphic user interface
Dan Ingalls
- Pioneer of object-orientated programming
- Primary architect and implementer of 5 generations of Smalltalk
Adele Goldberg
- Key role in the development of Smalltalk
- Developed 'design templates', a forerunner of design patterns
Smalltalk
"Most ideas come from previous ideas."
It is "called "Smalltalk"--as in "programming should be a matter of ..." [Smalltalk] and "children should program in ..." [Smalltalk].
I figured that "Smalltalk" was so innocuous a label that if it ever did anything nice people would be pleasantly surprised."
A Brief History
- 1960s - Alan Kay develops early concepts, based on Lisp and Simula and exposure to educational languages like Logo
- 1969 - Smalltalk first coined
- 1971 - Initial working version, Smalltalk-72, created in just over a week at Xerox PARC
- 1972 - Smalltalk-72 becomes the first released version
- 1974 - Smalltalk-74 released
- 1976 - Smalltalk-76 released
- 1980 - Smalltalk-80 released - first version provided to external companies for 'peer review'
- 1980s - Digitalk and ParcPlace systems release commercial versions of Smalltalk-80, developer base shrinks
- 1990s - Java released for free, Smalltalk usage shrinks further
Patches welcome
Not all doom and gloom.
Open Source versions of Smalltalk do exist:
- Pharo
- Squeak
- GNU Smalltalk
Design concepts revisited
Purely object-orientated:
-
An object is always an instance of a class
-
Classes describe the behaviour and properties of instances
-
Polymorphism: classes extend a superclass
(except the special 'root' class) and can be subclassed - All values are objects
Design concepts
Smalltalk objects can do exactly 3 things:
- Hold state
- Receive messages
- Send messages
(while receiving messages)
Syntax
Literals
"this is a comment"
'this is a string'
#'this is a symbol'
#thisIsAlsoASymbol
Numbers
42
-42
123.45
1.2345e2
2r10010010
16rA000
Arrays
#(1 2 3 4)
Syntax
Variables
Declarations
|a|
|a b c|
Assignment
a := 3
b := 'the quick fox'
Equality comparison
a = b
Identity comparison
a == b
Syntax
(I'll stop now)
Different to Ruby
Smalltalk is more than just a language
Different to Ruby
Image based
Smalltalk systems store the entire program state
(including both Class and non-Class objects)
in an image file, which can be loaded.
(including both Class and non-Class objects)
in an image file, which can be loaded.
Smalltalk images are similar to (restartable) core dumps and can provide similar functionality, such as delayed or remote debugging with full access to the program state.
Different to Ruby
Image based
Smalltalk = VM + Language
Smalltalk program = VM
Different to Ruby
Amazing tools
The VM was the first IDE as we know it
- Code editor
- Class browser
- Standard graphics library and importer
- Debugger
- Profiler
- Test runner
- and more
Semantics
In which I highlight a grab bag of differences
Semantics
Ruby has mixins
Smalltalk does not
Semantics
Ruby permits adding methods to individual objects
All methods reside inside classes in Smalltalk
Semantics
In Ruby, creating methods dynamically is a popular pattern
Methods and classes are generally treated statically in Smalltalk
Semantics
Ruby offers powerful macros in class definitions
Smalltalk has no macros whatsoever
Semantics
If an Array in Ruby needs to be sorted, it must be done explicitly
Smalltalk has an OrderedCollection implementation to maintain sorting order through mutations
Key learnings
(AKA get to the point)
Key learnings
The class browser is a great tool for viewing senders and implementors in a live system.
Being able to inspect code on the fly is extremely helpful
Key learnings
Debugging and incremental tracing of code is also valuable. Having persisted state available makes tracking down errors much faster.
Key learnings
Smalltalk, in many ways, is Light Table
(just 30 years ahead of its time)
Questions?
Sasha Gerrand
@sgerrand
Programmer
Bigcommerce
Further reading
History, papers, etc
Smalltalk: http://smalltalk.org
Downloads
Pharo: http://www.pharo-project.org
Squeak: http://squeak.org
Sasha Gerrand
@sgerrand
Programmer
Bigcommerce
Learning from Smalltalk - RubyConf 2014
By Sasha Gerrand
Learning from Smalltalk - RubyConf 2014
Smalltalk leaves a long shadow on the programming landscape and can be considered both as an ancestor and influence on the design of Ruby. This talk introduces Smalltalk to Rubyists.
- 3,545