Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
A Great Squeak Demo - Dan Ingalls 1998
Last updated at 10:53 am UTC on 11 June 2018

A Great Squeak Demo

I have never failed to get an "Ah-ha" out of the factorial part of my Squeak demo. It's a bottom-up approach that seems to work well for people who are competent in some other programming language and wondering what Smalltalk is all about. Here's how it goes...

First I show the code for Integer factorial, and explain how it works in terms of sending messages, and run it for 6 factorial, which anyone can understand.

Then I run 100 factorial, which is always fun. We joke about whether it's correct or not, so I print

100 factorial // 99 factorial

(if you have Squeak plugin installed, try this).

and we joke again about how it probably is correct, after all. Moreover, it's clear by now that Squeak is doing serious arithmetic (i.e. division) on monster numbers, quickly and correctly.

THEN I go back to factorial and explain how the fact that the code is messages means that it will work for any kind of numbers, so long as they support those messages. That's how it continues to work when the results get to be too big for normal integers. If someone isn't getting it, then I show them max: in Magnitude and point out that this one tiny proceedure is constantly servicing Integers, Floats, LargeIntegers, Fractions, Times and Dates (show the hierarchy). This is the power of polymorphism.

Finally I talk about how Squeak defines a virtual machine in which this metaphor of message sending IS the actual instruction set. At that point I show the compiled bytecodes of factorial [that's why we bother to have show-bytcodes in a menu], responsible for the foregoing numeric pyrotechnics. It never fails to blow people's minds that you can have this kind of power encoded in 21 (count 'em) bytes. (max:, by the way, is 7 bytes). - Dan Ingalls (2 Jul 98)