[Edu-sig] Freedom: some Smalltalk history and Python implications

Andreas Raab andreas.raab at gmx.de
Fri Aug 11 05:52:40 CEST 2006


kirby urner wrote:
> http://www.4dsolutions.net/ocn/numeracy0.html -- numeracy3.html

This is *great* material, thanks. My background being in computer 
graphics I really enjoyed reading it. I wish I would've had that when I 
was the right age. (which reminds me: what age group do you usually teach?)

Interestingly, if you were to adapt that material to Smalltalk the very 
first example would be the hardest because you'd have to explain so much 
more to begin with. E.g., your trivial little:

def tri(n):
     # triangular num n
     # = sum of n consecutive counting nos (n>=1)
     if n<=1: return n
     else: return n + tri(n-1)

just has no trivial little counterpart in Smalltalk. The Right Way to do 
this in Smalltalk (discounting workarounds like arbitrary helper 
classes) would be to extend class Integer directly:

tri
     " triangular num n "
     " = sum of n consecutive counting nos (n>=1) "
     n <= 1
       ifTrue:[^n]
       ifFalse:[^n + (n-1) tri]


And besides the maintenance nightmares (so how exactly do I persist a 
method on Integer?), the above is also a primary example for what is 
"wrong" about Smalltalk:

1) Conceptually, if we're teaching math we probably want to define f(x) 
at some point. Not being able to, and instead to define "x f" is just 
distracting and awkward.

2) Syntactically, the above has quite a number of "weird" binary symbols 
- like the up-arrow for return and the square braces. One of my mantras 
for programming languages is that the more binary symbols (instead of 
words) they use the more obscure they get from an end-user perspective: 
Simply because except from a few binary symbols that we know from math 
(plus, minus, equals, parenthesis) their meaning is both arbitrarily 
assigned by the language designer and typically critical for 
understanding the language. So if you don't know what the binary symbols 
of a language mean you're screwed - just try APL.

3) Pragmatically, there is something odd about control structures in 
Smalltalk - the fact that there is only the "receiver message: argument" 
syntax necessitates that control structures like if/then are written in 
sort of a post-fix notation, e.g., <condition> ifTrue: instead of the 
more natural prefix notation "if <condition>". I also strongly believe 
that the prefix notation for control structures is critical for 
understanding code - it is one of these things where in a sequence of 
statements you suddenly get to a point that screams "attention! control 
flow changes". And having that "warning" upfront signified by "if" or 
"while" or somesuch is tremendously helpful.

Now, there are other things that are very, very right about Smalltalk 
but those are in my understanding prime reasons of why Python is so much 
more appealing for beginners. Python just looks right for it, not too 
much, not too little and the few things that might not be totally 
obvious you can guess pretty quickly.

Interestingly, once we get a little deeper into the curriculum there is 
nothing in there where I'd say this is particularly difficult or 
problematic. Like when you actually get into objects, all of this 
translates directly and some of it may even look nicer (though this may 
depend on taste). The main hurdle would really be to get through the 
required mechanics in the beginning.

And although it's slightly tangential, here is how something like that 
may look using the eToys environment:

     http://people.ofset.org/hilaire/drgeo2/demo/2-thales/

> But I do need my spatial geometry, either as renderings (stills) or as
> dynamic (like in Pygeo).
> 
> So my first question for Squeakers, after they show me how to generate
> my sequences, is how do I convert this to vector-based graphics of a
> spatial nature.  Does Squeakland provide those facilities.

Yes. All graphical objects can carry a pen - just set it down and draw 
to your hearts content ;-) Like here:

     http://squeakland.org/pdf/poster/grapherposter.pdf

> Or do I need to start with VisualWorks in order to avoid switching
> between Smalltalks down the road?

For media-related stuff, *nothing* beats Squeak. It is so far ahead of 
the others it's not even funny. Bitmap graphics, vector graphics, 3d 
(software and accelerated), wave sound, fm sound, midi, video, you name 
it. And those things that aren't in the release are at SqueakMap 
(http://map.squeak.org/packagesbyname).

Cheers,
   - Andreas


More information about the Edu-sig mailing list