It's been a frustrating day trying to get Squeak up and running. One site had archives that I couldn't unpack. Another one had an "all in one" bundle that was a piece of cake to install. Unfortunately, I have to run inisqueak to create my image and it didn't seem to include that. After a bit of playing around, I created a $HOME/.squeak directory, copied Squeak3.7-5989-full.changes, Squeak3.7-5989-full.image and SqueakV3.sources over there, set my SQUEAK_IMAGE environment variable to point to an image file there and successfully ran Squeak. The main window has a variety of different screenshots(?) that I can zoom into and play with and some information that will probably prove useful, though it's a bit of a strange world for me.
It appears that to actually get to write code, I need to expand the System Browser window but Squeak is not automatically opening to that right away. I think that's right, but I'm not sure. I don't know if the image file I copied to the .squeak directory is not the one I wanted. I hover the mouse over various "things" and not all of them have tools tips.
After a bit of playing around and reading through a Squeak tutorial, I created various tiny methods and one of them looked like this:
hello: times say: text (times > 100) ifTrue: [ Transcript show: 'You will get bored!'] ifFalse: [1 to: times do: [:i | (Transcript show: text) cr]]
Which can be invoked as:
Object new hello: 5 say: 'This is cool'
I now think I understand the lack of if statements (I'm sure my terminology is off.) The (times > 100) expression constructs a boolean objects which understands the message ifTrue:ifFalse:. Since everything is an object and you send messages to them, a bare if hanging out there would not fit the language design.
So how does the loop work? The number 1 (one) creates an integer object which understands the to:do: message. This is very cool, but I'll admit that it's a bit strange to me. I look forward to more play, but tuit reclamation is proceeding, as always, slowly.
Re:Object oriented languages aren't
Ovid on 2004-09-26T19:41:21
That's a classic example of people misunderstanding the terminology. Even my brief exposure to Squeak is showing me more. While I'm unsure of the process by which (foo > 5) creates a Boolean object in Squeak, it's now clear how the ifTrue:ifFalse messages work and why the traditional if/else statements are procedural in nature. It's not clear to me if mixing a bit of procedural code with OO code is bad, but then, I'm still exploring this. I suspect that the pure OO approach has benefits that get around some complaints I have about inappropriate uses of "if". I doubt one constructs long strings of if/else statements (or their equivalent) in Squeak.
Re:Object oriented languages aren't
merlyn on 2004-09-26T23:02:23
The object to which methods are sent is always the left one. There are no prefix operators. Everything is left to right. So, inyou'd look for a greather-than binary message in the class (and superclasses) of value currently held in the foo variable. If it was:foo > 5you'd look for a less-than binary message in the class of 5 and its superclasses. Yes, a wacked-out system could make those do different things, but "with great power comes great responsibility".5 < foo