genuine squeak newbie

Bob Arning arning at charm.net
Sun Jun 20 17:47:34 UTC 1999


On Sat, 19 Jun 1999 23:30:41 -0700 John BEPPU <beppu at taurus.oac.uci.edu> wrote: 
>I love one-liners.
>
>  Thus the Squeak environment is very alien to me.

It can actually be quite familiar if you ignore most of it and just concentrate on evaluating expressions in a workspace. Just in case you missed it, here is a message from a few days ago:

On Thu, 17 Jun 1999 10:33:39 -0500 Tim Olson <tim at jumpnet.com> wrote: 
>Thursday	Tim Olson 	MethodFinder is so cool!
>
>There was a recent posting on rec.puzzles, asking how many different 
>16-bit binary numbers had exactly 4 '1' bits.  I was playing around in 
>Squeak at the time, so I thought I'd whip something up:
>
>((0 to: (2 raisedTo: 16) - 1) select:
>     [:n | ((n printStringBase: 2) <<<need method here>>> $1) = 4]) size
>
>I was pretty sure that there already existed a method to count the number 
>of a particular element in a collection (in this case, the character 1 in 
>a string of characters), but couldn't remember what it was called.
>
>Then I remembered the new "selector finder" panel.  It not only has the 
>ability to type a fragment of a method name to find all the implementers, 
>it also has this great feature: you type in some examples of what you 
>want to do, and it will exhaustively search for any method which does 
>that.  So I typed in:
>
>	MethodFinder methodFor:
>     #( ('1101' $1) 3 ('abcda' $a) 2).
>
>which consists of 2 different examples of what I wanted:
>
>     the string '1101' with the operand $1 (the Character 1) gives the 
>result 3
>     the string 'abcda' with the operand $a gives the result 2.
>
>It immediately responded with:
>
>     '(data1 occurrencesOf: data2) '
>
>How cool is that!
>
>So I did it, and:
>
>((0 to: (2 raisedTo: 16) - 1) select:
>     [:n | ((n printStringBase: 2) occurrencesOf: $1) = 4]) size
>
>and got: 1820
>
>
>
>     -- tim

Note that what Tim was doing was typing text in a workspace and pressing cmd-i or cmd-p to evaluate it. Simple things like

MethodFinder methodFor:  #( ('1101' $1) 3 ('abcda' $a) 2).

and

((0 to: (2 raisedTo: 16) - 1) select:
     [:n | ((n printStringBase: 2) occurrencesOf: $1) = 4]) size

To my eye, that looks a lot like a command line interface (albeit with many more possibilities than many CLI's). While you will miss much of what's neat about Squeak if this is all you do, it is still a powerful place to do interesting things and it may be a more familiar place to start.

>  - How does one run programs?  
>  - Should I even be calling them programs?
>    Are programs just classes that need to be instantiated?

Probably the closest analogy to a "program" is a method. Alan Kay suggests treating objects as if each were a separate computer on a network. Messages are passed from object to object much like messages are passed from one networked computer to another. For the most part, you don't concern yourself with how that object/computer handles the message - you know that some method/program is executed on receipt of the message and a response is received. As to how one runs a program, there are many ways:

-- just opening an image starts many programs going. There are objects in that image that are responding to external events (mouse clicks, timers, etc) and running their own little (and not so little) programs as a result.
-- evaluating text in a workspace runs a program. Type
	#(1 3 5) sum
in a workspace and print it (cmd-p on a Mac) and you have run a "program" called #sum on a object/computer known as an Array (this object/computer containing 3 elements: 1, 3 and 5). This computer replies with another object/computer, the SmallInteger 9.
-- you can also arrange that methods/programs run in less explicit ways: adding a button to your desktop to perform common tasks or extending the functionality of existing tools to make your experiance more productive and enjoyable.

>
>[ ps ]
>
>  Is there anyone out there who uses Squeak as their primary environment?

I spend most of my time in Squeak (where this email was written, e.g.) and often have more than one image open.

To newbies in general: keep the questions coming. Remind us what is less than clear to those just starting out. Use the swiki: read it to see if there is something there, modify it to elicit clarification and add your own experiences that may help the next person. And, occasionally, if some tutorial or example was useful, let the author know.

Cheers,
Bob





More information about the Squeak-dev mailing list