smalltalk for unix & w i n d o w s dennis smith cherniak software development corporation
TRANSCRIPT
Smalltalkfor
Unix & Windows
Dennis Smith
Cherniak Software Development Corporation
Smalltalk
• Smalltalk is …– a computer language
– a development environment
– a philosophy of development
– 100% objects
Where did it come from
• Conceived in the late 1960’s by Alan Kay
• Ideas from Simula, Logo, SketchPad• Concept of communicating “cells”
from his biology background• “Cells” later became “Objects”
• Alan Kay Moved to Xerox Park in 1972 where he worked on Smalltalk as a language for teaching children
Alan Kay
• Developed a number of concepts in the 60’s and 70’s– Objects– GUI interfaces– LapTop Computer– Smalltalk
• Alan Kay is now a “Disney Fellow” doing general Research
Smalltalk Yesterday & Today
• First commercial use– Tektronix, embedded in
oscilloscopes
• Used in many areas today– U.S. Power and Light utilities– Insurance Industry– Volkswagen production line– Swiss banks– Ford, General Motors, Chrysler
(Xtreme Programming)– Active Web Sites
Implementations
• VisualWorks (CINCOM) – Based on Xerox Park work– Binary cross-platform (UNIX,
Linux, Windows, Mac)– Full NC version at
www.cincom.com
• ObjectStudio (CINCOM)– Windows & Mainframes
• IBM VisualAge Smalltalk– Cross-platform via source (UNIX,
Windows, OS/2)
Implementations (2)
• Gemstone/S (Gemstone)– server side, persistent, multi-user, active
ODBMS (Unix, Linux, Windows)
– NC versions available at www.gemstone.com
• Dolphin– was free now commercial
• Squeak– Free - small group started by Alan Kay– Available at www.squeak.org
• MT– compiled, windows-only
• GNU– command line, no GUI
Smalltalk – What Is It
• A pure object language
• Simple syntax (5 lines of BNF)
• No compile-time types– Object’s have types– Variables / parameters do not
• Syntax contains no conditionals
• Syntax contains no loops
• Automatic Garbage Collection
Smalltalk – What is it (2)
• Uses a VM
• Compiles to byte codes
• Byte codes can be interpreted
• Normal execution uses a “cached compile” technique pioneered by Smalltalk in the 1980’s.
• Debugging uses interpreter
The Language
• Data is encapsulated in objects
• Access via sending message to the object
• A message invokes a method
• All method returns a value (default the object)
• Everything is an object– Integer, Float, Character, String– Class, Method, Byte Codes– Other Objects
Classes, Variables, Objects
• A class is a pattern for an object– Defines instance variables
– Defines methods
– May inherit from another class
• An Object is instantiated from a class using “Class new”
• Two kinds of variables– Instance variables in the object
– Temporary variables in the method
Methods and Messages
• Three kinds of messages– Unary (name of method)
• person surname
– Keyword (name and parameters)• person surname: ‘Jones’
– Binary, any single or pair of special characters
• personA = personB
• stringA , stringB
• age + 4
• age + 4 * 2
Constant Values
• Constants– Integers 2, 248– Characters $A $+ $$– Strings ‘this is a string’– Floats 123.45– Fixed Decimal (some) 123.45s– Symbols (canonicalized strings)
#abc #surname– Arrays #(12 ‘string’)
• Comments– “this is a comment”
Arithmetic
• This slide should be empty, there is no such concept
• However, by convention, if you send the message “+” to a numeric value the result is likely the sum
• Note however that “+” could be defined for String, Person etc.
• Note “3 + 4 * 5” results in 35!!
Conditionals
• Code block (its an object)[statements][:parm | statements]
• ConditionalaBoolean ifTrue: […]aBoolean ifTrue: […] ifFalse: […]
(true) ifTrue: aBlockaBlock value
(false) ifTrue: aBlock“do nothing”
Collections
• Many types of collections– Array (fixed size)– OrderedCollection (variable size)– Dictionary (keyed values)
• Simple enumeratoraCollection do: [:obj | …]
• Other enumeratorsselect:block returns boolean
reject:block returns boolean
collect: block returns new values
Sample Code
(PersonHolder)firstPerson
| person |person := self getPerson.spouse := person spouse.spouse > person ifTrue: [^spouse].^person
(Person)> aPerson
^self age > aPerson age
Sample Code (2)
• Find all persons older than some other person:
allOlderThan: aPerson
^personList select: [:p | p > aPerson]
Why Smalltalk
• Its fast
• Its easy to work and think with
• Changes are instantly available
• Debugger is fully interactive
• Its fully reflective, classes, methods, byte codes, compiler all written in Smalltalk
• Automatic garbage collection
Why Smalltalk (2)
• Features– IDE uses single browser (written
in Smalltalk of course)– Fully integrated GUI
development– Image reading (gif, bmp) and
manipulation (grow, shrink, rotate, flip, …)
– Network Support (SMTP, POP, IMAO, SOAP, SSP (JSP), …)
What We doat Cherniak Software
• Tools and Framework for building end-user database applications– Accounting– Payroll– Custom
• VisualWorks and Gemstone
• Business and Framework code runs both on VW and on Gemstone