Hi! My thoughts...
Matthew Tuck
matty@box.net.au
Wed, 23 Dec 1998 22:31:27 +1030
Gaurav Vaidya wrote:
> Has anyone here tried Smalltalk? It is to object-oriented
> programming languages what C is to functional ones ... flexible.
Yep, I know of Smalltalk. There's a couple of smalltalk links on the
pages. Smalltalk was really the second OOP (that I'm aware of). While
it did a lot of things that subsequent languages did wrong (read as
C++), it's by no means perfect.
In my opinion, the lack of typing is a large problem. Having it decided
whether a message is valid or not at run-time is just asking for
trouble, for a benefit which is dubious. This could be overridden by
allowing run-time defined types, and unchecked calls and the like
through a reflective interface or such if desired.
I certainly think Smalltalk is a good inspiration though. It got a lot
of things right, such as the notion of an integrated environment, and an
everything-is-an-object philosophy.
Feel free to add any specifics about how you feel Smalltalk is a good
language.
> It uses objects, which can be sent messages.
> <b>Everything</b> is either an object or a message, for example,
> something like the C "a++;" become "a ++", in which the message "++" is
> sent to object a. "==", "+", "-" are all messages! For example,
> "alpha + beta" is actually the message "+" with the message "beta" being
> sent to "alpha". This seems like I good idea!
Sather translates operators to messages, which is slightly different,
but the same in spirit, e.g.
"a + b" becomes "a.add(b)"
Smalltalk does conditionals by passing messages, e.g.
a iftrue: ... iffalse: ...
so basically booleans get two parameters, the section of code to call.
Now I like this technique - especially since it enables me to define
multiple implementations of the boolean type - something you couldn't do
with a normal if. But I do think there's nothing wrong with having a
normal if, as long as it is a shorthand for a Smalltalk-like method
call, similar to the operators in Sather.
A problem with this is it is restricted to a single dispatch model.
That is, the message is sent to the object on the left. Multiple
dispatch is where the class of both objects can alter the method
called. Now, most OO languages do this, and I'm not widely versed on
multiple dispatch techniques, so I'll cease talking about it.
Some of the techniques we've talked about on the list already may well
be able to let you choose how you wanted to do this.
Also if uses strict left to right precedence. I don't really consider
this a problem, so I won't say any more about it.
--
Matthew Tuck - Software Developer & All-Round Nice Guy
mailto:matty@box.net.au (ICQ #8125618)
Check out the Ultra programming language project!
http://www.box.net.au/~matty/ultra/