Please send questions to st10@humboldt.edu .

INTRO to SMALLTALK/SQUEAK (Extreme OOP!) - part 1

*   ...because object-oriented programming is another dominant
    programming model;

*   do note: object-oriented (OO) can be "in front" of many things!

    OO programming
    OO modeling
    OO analysis
    OO design

    ...we'll focus mostly on OO programming (OOP) here.

*   potential benefits of object-oriented programming (OOP):
    *   (discussed verbally)
    *   abstraction
    *   modularity
    *   reusability
    *   better organization
    *   user-defined classes
    *   inheritance (might mean less code-writing!) - aids "differential" 
        programming
    *   abstract data types
    *   polymorphism
    *   better portability
    *   better readability

    *   aggressive use of abstract data types
    *   there is often more stability in data than in what
        computations get done on that data -- so OOP MAY
        yield more stable systems over time
    *   might be project-oriented than product-oriented
        ...might allow for building a family of systems 
           rather than single systems
    *   aids "differential" programming (you only have to
        write the part that is different from an existing
        program, because of inheritance)
    *   might simplify client code, since they only need
        to "ask" objects to perform some operation, even if the
        client doesn't know what kind of object they are
        invoking
    *   some claim that, since the real world consists of
        objects, modeling these as OO objects is "natural"

*   not a panacea! Has pluses and minuses;

*   We're going to discuss SMALLTALK-80 (the Squeak implementation of
    Smalltalk-80) as our focus on object-oriented programming (OOP)

    *   why? because it takes OOP further than C++, Java
        AND it is very different from C++, Java

    *   other choices could have been:
        C++, Java, Ada 95, Beta, Cecil, CLOS, Eiffel,
        Dylan, Emerald, Modula-3, Oberon, Objective C,
        Python, Sather, Self, Theta, and others!

    *   VERY close to everything is an object in Smalltalk!!

        (doesn't have non-object primitive types as Java, for example,
	has)

        *   C++ : multi-paradigm, only some things are objects
        *   Java: takes it further, many more things are objects,
            but primitive types aren't, and neither are
            classes themselves, for example;
        *   Smalltalk-80: the classes themselves are objects,
            the environment is an object, oy!

    *   has a RICH programming environment (a plus AND a minus)
        that is intimately related to the language

    *   Squeak (www.squeak.org) is a free implementation of
        Smalltalk-80, available for Linux, Mac, Windows, and
        more?

*   very brief background:
    *   The Learning Research Group at the Xerox Palo Alto
        Research Center (Xerox PARC) developed Smalltalk as the
        language for the Dynabook, during the 70's and early 80's

    *   (when people say "Smalltalk", they usually mean 
        Smalltalk-80)

    *   late-60's? early-70's: Dynabook was a yet-to-be-developed
        "laptop of the future" (whose target audience was children)
 
        Alan Key, Dan Ingalls, Adele Goldberg: key players
        in the development of Smalltalk

        they chose simulation as the metaphor for programming
        the Dynabook;
	...influenced by Lisp, Simula, Ivan Sutherland's
           Sketchpad

*   before there was Smalltalk-80, there was Smalltalk-72
    *   interpreted
    *   extensible syntax (programmer can add syntax)
        fred move up x inches
    *   more object-oriented than Simula -- even integers are objects
    *   'class' is even an object (albeit a rather special one)
    *   ...but no subclassing yet;

*   Smalltalk-80
    *   now you've got subclasses!
    *   everything is an object -- blocks(closures), classes,
        activation records, etc.!
    *   not statically-typed
    *   rich programming environment
    *   no longer just a programming language for children!

*   there are commercial versions of Smalltalk-80
   (ParcPlace, Digitalk, others)

   ...and free versions, such as Squeak

*   Smalltalk is considered the first "major" object-oriented
    language (with Simula as the "grandfather")
      
    ...and has influenced other object-oriented languages,
       C++, Objective C, CLOS, Cecil, Kaleidoscope, Java,
       and more;

*   key language elements:
    *   objects (instances)
    *   classes
    *   messages
    *   methods

    *   as you should already know:
        an object has some private memory (its instance variables/data fields)
        and some operations it can perform;

*   a method may "send a message" to other objects;
    but the actual method that gets invoked depends on the message
    that is sent and the methods defined by the class of the
    "receiver" object

    *   every object is a member (instance) of a class

    *   the class is the "blueprint" from which instances are created

    *   a method may send a message to other objects (instances);
        the actual method invoked depends on the message that
        is sent and the methods defined by the class of the
        "receiver" object;

        once the proper method is determined, the method is
        executed and can use and modify the instance variables
        of the receiver object;

    *   classes can have subclasses, which inherit the
        instance variables and method definitions from the
        superclass, allowing a subclass to use and modify
	an existing class;

        ...this can add complications! what method gets
        done, exactly, when a message is sent?
	... Smalltalk-80 has reasonably simple (?) to determine
            that;

*   Smalltalk/Squeak were designed with a THREE-BUTTON mouse in mind;

    *   here are the common mappings if you have fewer:

    *   buttons named by color 
                          Windows (often)   Mac (often)    typical meanings:
        red    (left)     left-click        click button   move/select
	yellow (middle)   right-click       option-click   context-menu
	blue   (right)    ALT-left-click    command-click  window/Morphic menu

*   double-click on a .image file to start up Squeak

    *   can use Tools tab to bring up a Workspace window 

    *   type in the window, then right-click/option-click, print it
        to print the value of that expression

*   consider the meaning of something like:
    3 + 2

    ...this MEANS the "+" message is sent to the object 3
    (the receiver), with the object 2 as its argument;

    "+" is a binary message

    see more examples of binary messages in the posted
    workspace contents

*   unary message:

    object message

    13 negated
    (5 @ 8) class   "tell me what class you are"

*   keyword message: involves a "word", not an operator; can be n-ary;

    2-ary (binary) keyword message:

    Recipient keyword: Argument

    3-ary keyword message:
       
    Recipient keyword1: Argument1 keyword2: Argument2

    (and you'd call this message keyword1:keyword2:

    ...and so on!

*   order of operations: simple rules, but different than
    you might expect:

    unary messages are top priority, executed left-to-right

    binary messages are next, executed left-to-right

    n-ary messages are next, executed left-to-right
    (BUT! for multiple n-ary messages, the "longest" message
     has precedence, where "longest" is the biggest n
     ...a 3-ary message has precedence over a 2-ary message