Download presentation
Presentation is loading. Please wait.
Published byMeghan Murphy Modified over 9 years ago
1
CS 403: Programming Languages Lecture 5 Fall 2003 Department of Computer Science University of Alabama Joel Jones
2
Lecture 5©2003 Joel Jones2 Outline Introduction to Smalltalk—What, Why, How Introduction to Squeak
3
Lecture 5©2003 Joel Jones3 What is different about Smalltalk? Everything is an object A real integrated development environment Carefully integrated classes and syntax Dynamically typed Simple syntax
4
Lecture 5©2003 Joel Jones4 Why learn Smalltalk? Nobody uses it. Yeah, nobodys like: FedEx Ericsson Chrysler Deutsche Bank Dunn and Bradstreet Wisconsin Department of Revenue Geico Direct John Deere Texas Instruments Nokia Mitsubishi Volkswagen Bell Atlantic NYNEX Bell South MCI USWest
5
Lecture 5©2003 Joel Jones5 History of Smalltalk A few links http://www.ayers.je/smalltalk/smalltalkhistory. html http://www.ayers.je/smalltalk/smalltalkhistory. html http://www.mojowire.com/TravelsWithSmallta lk/DaveThomas-TravelsWithSmalltalk.htm http://www.mojowire.com/TravelsWithSmallta lk/DaveThomas-TravelsWithSmalltalk.htm
6
Lecture 5©2003 Joel Jones6 Are you serious? But hopefully you will get a feel for why I like Smalltalk so much and Why we will be looking at Smalltalk a little further Will I be a good Smalltalk programmer by the end of the lecture?
7
Lecture 5©2003 Joel Jones7 Why do I care about the properties mentioned earlier? Carefully integrated classes and syntax for (Iterator i = myCollection.iterator(); i.hasNext(); ) { ItemType myItem = (ItemType) i.next(); myItem.something(); } myCollection do [:myItem | myItem something ] Java Smalltalk
8
Lecture 5©2003 Joel Jones8 Why do I care about the properties mentioned earlier? Everything is an object for (int i = 0; i < myArray.length; i++) { ItemType myItem = myArray[i]; myItem.something(); } myArray do [:myItem | myItem something ] Java Smalltalk Pair Up: What other property is exhibited here?
9
Lecture 5©2003 Joel Jones9 How the heck did that Smalltalk code work? Simple stuff first myItem something is a simple message send with no arguments A little harder myCollection do: [ … ] is a message send with one keyword with an argument Even harder […] is a block, which is a closure, a thunk with arguments, an anonymous inner class, a function pointer with lexical capture, etc.
10
Lecture 5©2003 Joel Jones10 Everything is an Object I wasn’t kidding The block is an object All loops and control structures in Smalltalk are objects Once you learn them, the collection classes mean you don’t have to write the same kind of loop infrastructure over and over again
11
Lecture 5©2003 Joel Jones11 Control methods Collections do: select: collect: detect: detect: ifNone: inject: into: reject: Boolean ifTrue: ifTrue: ifFalse: ifFalse: ifFalse: ifTrue:
12
Lecture 5©2003 Joel Jones12 What is the Smalltalk programming environment like? We will be using Squeak, a freely available implementation We’ll be looking at it right now. A quick reference can be found at: http://www.mucow.com/squeak-qref.html
13
Lecture 5©2003 Joel Jones13 References Download implementation, etc. www.squeak.org www.smalltalk.org Smalltalk idioms and conventions http://www.angelfire.com/tx4/cus/notes/smallt alk.html http://www.angelfire.com/tx4/cus/notes/smallt alk.html
14
Lecture 5©2003 Joel Jones14 Next two classes I will be out of town Meet at normal class time and place Someone will have lab assignments for you to do on Smalltalk http://www.mucow.com/squeak-qref.html
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.