Smalltalk -- a radical change in programming

A



  1972  Dynabook -- Alan Kay
  1976  SmallTalk76
  1980  SmallTalk80
  1990  ObjectWorks/SmallTalk -- VisualWorks
  

Design principles -- rapid prototyping

  • uniform object model -- control
  • dynamic typing -- flexible
  • standard libraries -- functionality

slide: The language Smalltalk


Terminology

Smalltalk



slide: Smalltalk -- terminology


Literal constants


slide: Smalltalk -- expressions (1)


Assignment

Variables

Block expressions


slide: Smalltalk -- expressions (2)


Message expressions

  • unary, binary, keyword

Unary

  • 1.0 sin , Random new

Binary

  • arithmetic -- ctr + 1
  • comparison -- aVar >= 200
  • combination -- 100 @ 200
  • association -- # Two -> 2

slide: Smalltalk -- expressions (3)


Keyword methods


    (i <= 7) 
          ifTrue: [ m:= "oke" ]
          ifFalse: [ ... ]
  

Control structures

  • conditional -- ifTrue: ifFalse:
  • iteration -- whileTrue:
  • looping -- to: by: do: [ :i | ... ]

slide: Smalltalk -- control


Object -- behavior

Class -- description

  • class variables, class methods
  • Self -- self reference


    slide: Smalltalk -- objects (1)


    Example -- class

    
      Behavior subclass: #Ctr
      instanceVariableNames: 'value'
      Ctr methodsFor: 'initialization'
         initialize
      	value := 0.
      Ctr methodsFor: 'modifications'
         add: aValue
      	value := value + aValue.
      Ctr methodsFor: 'inspection'
         value
      	^value
      

    slide: Smalltalk -- objects (2)


    Class description -- meta class

    
      Ctr class
      instanceVariableNames: ''
      Ctr class methodsFor: 'instance creation'
      	new
      		^super new initialize
      

    slide: Smalltalk -- objects (3)


    Inheritance

    
        Object
          Magnitude
             ArithmeticValue
                Number
                   Integer
      

    slide: Smalltalk -- inheritance


    
      Model subclass: #Ctr 
    Model
    ... initialize value := 0. TV open: self. ... add: anInt value := value + anInt. self changed: #value.

    slide: Smalltalk -- technology (1)


    
      View subclass: #TV 
    View
    instanceVariableNames: '' TV methodsFor: 'updating' update: aValue Transcript show: 'ok'; cr . TV class instanceVariableNames: '' TV class methodsFor: 'instance creation' open: aCtr self new model: aCtr

    slide: Smalltalk -- technology (2)


    The language Smalltalk

    A



    slide: Smalltalk -- summary