Presentation is loading. Please wait.

Presentation is loading. Please wait.

Squeak and Botkit-Port Jeff Forbes Joel Miller. Introduction ● Squeak is a pure OO language ● Based off of SmallTalk-80 – Designed at Xerox PARC by Alan.

Similar presentations


Presentation on theme: "Squeak and Botkit-Port Jeff Forbes Joel Miller. Introduction ● Squeak is a pure OO language ● Based off of SmallTalk-80 – Designed at Xerox PARC by Alan."— Presentation transcript:

1 Squeak and Botkit-Port Jeff Forbes Joel Miller

2 Introduction ● Squeak is a pure OO language ● Based off of SmallTalk-80 – Designed at Xerox PARC by Alan Kay, Dan Ingalls, Ted Kaehler, and Adele Goldberg – The designers wanted a pure object-oriented, interpreted, easy to use language. – Failed/Abandoned because of the slowness of interpreted languages based on the current technology

3 Squeak ● Squeak can be obtained at no cost at http://www.squeak.org ● Squeak is self contained and also includes a VM/UI of which all programs are run: – Everything is self contained in an *.image file ● Available for most OSes

4 The Squeak UI/VM

5 Squeak Features ● Completely Object Oriented –This means everything is an object! Call by name All code is a message which is sent to an object – An object is an instance of a class – Similar rules to Java ● Garbage collection is standard!

6 Objects ● Everything is an object ● There are no primitive types ● Even classes are objects!! ● Everything inherits from the Object class ● No dual inheritance, no interfaces ● self is this and super is super

7 Messages ● 3 Types of Messages: – Unary Ex. ‘abc’ reversed. –Binary ● 2 + 4 – Keyword Ex. Transcript show: 5. There can be many keyword messages passed to an object

8 Syntax ● Assignment x := 13 –In Squeak, the underscore “_” can be used (  ) Arrays: #(1 2 3 4 5 6) Character: $e Strings in single quotes Comments in double quotes Equals? = Identity test == Lines are completed with a period # prevents evaluation New creates objects

9 Order of Operations ● The math inside SmallTalk/Squeak is infinite precision ● Everything left to right – This means 2 + 5 * 9 gets evaluated as 63! – 2+(5*9) will get desired result. Messages: Unary > Binary > Keyword

10 BlockContexts ● Informally called “blocks” ● Used for nearly all structured programming constructs ● Made by putting square brackets around code ● Very similar to lambdas in Scheme

11 Blocks (cont.) ● [6 + 7] is a block but won't evaluate until you say [6 + 7] value. ● Blocks can have local variables – block := [ :a :b | a + b ] – This would be called as block value: 6 value: 7 ● Blocks introduce pluggability to a class

12 Conditionals ● The basic conditionals are included: – ifTrue – ifFalse Ex: (x < 15) ifTrue: [ Transcript show: 'less than 15'.] ifFalse: [ Transcript show: 'gt or eq 15'.]

13 Loops ● whileTrue: – The condition must be a block so it can be re-evaluated ● timesRepeat: – No access to the loop index ● to: do: – First parameter in execute block gets set to index Ex: [x < 15] whileTrue: [ Transcript cr. Transcript show: y. temp := y + z. y := z. z := temp. x := x + 1. ]

14 BotKit-Port ● BotKit port written by John Purcell ● Written as a masters thesis –Therefore poorly documented ● Directly interfaces with the RCX ● Allows immediate mode and “scripted mode” ● Bug: if statements do not work while sending from the BotKit! (immediate)

15 Code Examples "simple program which goes foward until communication stops" "From http://www.eg.bucknell.edu/~lego/" ISpirit initialize. bug := BugBot new. rcx := bug rcx. bug forward. rcx spirit free. "Turn around message: ex. bug turnaround." self rcx soundTrillUp. self forward. self turnLeft; sleep: 200. self backward; sleep: 300. self rcx soundTrillDown.

16 Examples Cont. "go forward until hit a wall, then backward" ISpirit initialize. bug := BugBot new. rcx := bug rcx. "motor hooked up to port 1 on RCX" theMotor := rcx motor: 1. theMotor on. theSensor := rcx touchSensor: 1. [ theSensor ] whileFalse:[ theMotor forward. ] theMotor backward.

17 Resources ● Squeak: http://www.squeak.org ● Squeakwiki: http://minnow.cc.gatech.edu/Squeak ● Squeak: Open Personal Computing and Multimedia by Guzdial and Rose ● BotKit-Port: http://www.eg.bucknell.edu/~lego/ ● BotKit: http://www.object- arts.com/Bower/Bot-Kit/ (Link Down) Questions?


Download ppt "Squeak and Botkit-Port Jeff Forbes Joel Miller. Introduction ● Squeak is a pure OO language ● Based off of SmallTalk-80 – Designed at Xerox PARC by Alan."

Similar presentations


Ads by Google