Let’s Talk about…

Download Report

Transcript Let’s Talk about…

Let’s Talk about…
Smalltalk
History of Smalltalk
Developed in the early 70’s (1969) in the Learning Research
Group at Xerox’s Palo Alto Research Center
Companies who invested in the research and development
of Smalltalk:
• Xerox
• Apple
• Digitalk
• Object Technology Inc. (OTI)
• IBM
Early Beginnings
The Xerox Smalltalk Team developed the mouse technology
and the bitmap
• First graphical bit-map based
• multi-windowing (window overlapping)
• programming environment (debugger, complier,
editor, browser)
• with a pointing device
What is Smalltalk?
• a TRUE object-oriented programming (OOP) language
• Encapsulation
• Polymorphism
• Inheritance
• Data Binding
• Integrates a multi-windowed development environment
• Simple and Compact Language
What is Smalltalk?
• a large set of reusable classes (UI, sockets, basic data
structures, etc)
• a set of powerful development tools
• Browsers
• UIBulider
• Inspector
• Crash recovery
• Project Management
• A run-time environment based on virtual machine
technology
Smalltalk language
• Everything is an object (numbers, files, editors, compliers,
points, tools, boolean)
• All actions are done by sending a message to an object OR
Objects communicate ONLY by message passing
• Every object is an instance of a class (which is also an
object)
Object, Class, Methods
OBJECT
• An object is a collection of data and code
CLASS
• A class is the definition of an object
• The class of an object holds the code for the object
• Each class defines data and a set of methods
(the code) which operates that data
METHODS
• Methods always belong to a class
• A method in Smalltalk is a subroutine
• It takes at least one parameter and always returns one
value
Object, Class, Methods
Class  Object
•Data
•Methods (subroutine)
to operate data
Messages
Messages
Class  Object
Messages
•Data
•Methods (subroutine)
to operate data
Class  Object
•Data
•Methods (subroutine)
to operate data
Messages
Objects communicate through messages…
Message  1 + 2
• receiver: 1 (an instance of SmallInteger - Object)
• selector: #+
• arguments: 2 (an instance of SmallInteger - Object)
Message  Workstation withName= #mac
• receiver: Workstation (a class)
• selector: #withName
• arguments: #mac
Syntax Differences
C++ / Java
SmallTalk
Comments
/*comments*/
//comments
“comment”
Assignments
int max=100;
Variable := avalue
Basic Types
“string”
‘string’
Self Reference
this
this.getClass()
self
self class
Smalltalk vs Java & C++
Smalltalk
• “Everything is an object”
• Objects are passed by reference
• Objects are the units of encapsulation
C++
• “Everything is a structure”
• Objects are passed by value (pointers)
• Classes are the units of encapsulation
Java
• “Almost everything is an object”
• Objects are passed by reference (no pointers)
• Classes are the units of encapsulation (like C++)
Alan Kay
Smalltalk addressed the need for a small, highspeed, PC-based product
The major ideas in Smalltalk are credited to Alan
Kay
“making simple things very simple and complex
things very possible” – Alan Kay
…..Thanks for listening…..