Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

15
Smalltalk Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002

Transcript of Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Page 1: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

SmalltalkSmalltalk

Mark Colangelo

CMSC-631, Fall 2002

10 December 2002

Page 2: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

History of SmalltalkHistory of Smalltalk

Alan Kay designed and build the first OOP-based personal Computer called FLEX in 1967-68

In 1967 Simula 67 was designed In 1972 Alan Kay and other and XEROX PARC

Created Smalltalk 72 with roots tied to Simula 67 Followed by Smalltalk 76 (Completely OOPL) Followed by Smalltalk 80 which became available

as the first commercial release of Smalltalk

Page 3: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Smalltalk in the Real WorldSmalltalk in the Real World

Financial– Chubb– Chrysler– Dunn and Bradstreet, several other

Manufacturing and Engineering– Texas Instruments– Romax (Simulation Software)

Page 4: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Free Implemenations of Free Implemenations of SmalltalkSmalltalk

Squeak (Smalltalk for Win , Mac and others)– http://www.squeak.org/download/index.html

GNU Smalltalk (Unix systems only) – http://www.gnu.org/software/smalltalk/smalltalk.html

Page 5: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Installation of SqueakInstallation of Squeak

Installation of Squeak is trivialDownload zip file

– Squeak3.2.image– Squeak3.2.changes – SqueakV3.sources – Squeak VM for your system, version 3.2

Doubleclick Squeak image. No other installation is required

Page 6: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Squeak Install FilesSqueak Install Files

Page 7: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Squeak DesktopSqueak Desktop

Page 8: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Hello WorldHello World

Page 9: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Exending Hello WorldExending Hello World

hello1 to: 3 do: [:i | (Transcript show: 'Hello

World') cr]

Gives:Hello WorldHello WorldHello World

Page 10: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Adding Logic to Hello WorldAdding Logic to Hello World

hello: times(times > 100) ifTrue: [ Transcript show: 'You will get

bored!'] ifFalse: [1 to: times do: [:i | (Transcript show: 'Hello World') cr]]

Page 11: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Final Hello WorldFinal Hello World

hello: times say: text

(times > 100) ifTrue: [ Transcript show: 'You will get

bored!'] ifFalse: [1 to: times do: [:i | (Transcript show: text) cr]]

Page 12: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Syntax ObservationsSyntax Observations

Any variable can store any object. Object keeps track of what it is.

Could pass an integer into the text parameter. No error until the Transcript tried to show it.

Page 13: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

MessagingMessaging

Always pass messages to an objectthe colon syntax for parameter passing

looks a lot like the colon syntax for loops--and logic, for that matter. That's because it's exactly the same.

hello:say, ifTrue:ifFalse: and to:do are all messages.

Page 14: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

Blocks of Code are ObjectsBlocks of Code are Objects

[:i | (Transcript show: text) cr] is an object Code block can be passed as an argument to

to:do: Transcript is a global variable that contains an

object which understands the show: message. In addition to show:, the Transcript object

understands the message cr, which puts a newline in the Transcript window.

Page 15: Smalltalk Mark Colangelo CMSC-631, Fall 2002 10 December 2002.

ReferencesReferences

Smalltalk home page– www.smalltalk.org

Squeak home page– www.squeak.org

Smalltalk Industry Council home page– www.whysmalltalk.com