This is a question I’m currently interested in knowing the answer to. I don’t know much about Smalltalk or Squeak unfortunately, but from what I do know, it seems like a good fit for the latest idea I have. The primary advantage over other environments I know, is that the image is available at all times. If an image receives a message it can’t handle because of a programming error, it can enter the debugger and wait for me to come along and debug it. I think that a decent Common Lisp implementation will offer me similar functionality.

Unfortunately, playing around with a new language for a couple of days gives a very limited idea of what it will be like to use it to develop a medium-sized application. For me, during the initial stage of investigation, it is very important to know whether it is worth taking the time with very quickly so that as little time is wasted as possible. Unfortunately, Squeak is a little harder to get to grips with than most languages I am familiar with as it is necessary to learn the IDE at the same time as the language. It is not possible (as far as I know) to simply enter a hello world program into a textfile and execute it.

The first script I entered into the Workspace (which is kind of a scratchpad for exploring new ideas) displayed the numbers from 1 to 200 on to the transcript, which is a kind of logging window. Here is the code to do that along with a timing method. If you highlight thecode and select “print it” from the menu, it tells you how long it took to run.

Time millisecondsToRun: [1 to: 200 do: [:i | Transcript show: i ; cr]]

This was the response: 10335

Ouch! 10 seconds. This is by far the worst performance I’ve ever seen in any language including BBC BASIC on a 2MHz machine. I was certain I must be doing something wrong so I asked on the Squeak beginners list. Unfortunately, it seems that it really is that slow. No-one has made any effort to tune the performance. Here is the comment from the Transcripter class:

"Transcripter is a dog-simple scrolling stream with display. It is intended to operate with no

support from MVC or color in a minimal, or headless version of Squeak. No attention has been

paid to appearance or performance."

Okay. Well that is a pity – it is one of the first parts of the Squeak people will see and I would have thought that it would put a few people off. Anyway, the “everything is an image” is still selling me so I try to see how long it takes to write 10,000 numbers to a file.

| myFile ios |

ios := ReadWriteStream on: ''. Transcript show: 'Populate Buffer: ', (Time millisecondsToRun: [ 1 to: 10000 do: [ :i | ios nextPutAll: ((i asString) , String crlf) ]]) asString , ' millseconds' ; cr. MessageTally spyOn: [ 1 to: 10000 do: [ :i | ios nextPutAll: ((i asString) , String crlf)]]. Transcript show: 'Position: ', (ios position) asString ; cr. myFile := StandardFileStream fileNamed: 'c:/test.txt'. Transcript show: 'Output Buffer: ', (Time millisecondsToRun: [ myFile nextPutAll: (ios contents)]) asString, ' milliseconds' ; cr. myFile close.

The MessageTally spyOn: is a nice profiler to see where it is spending its time – it is not really part of the initial test.

This produced the following output on the Transcript:

Populate Buffer: 275 millseconds

Position: 58894

Output Buffer: 9 milliseconds

Hmmm… is 275 milliseconds good or bad? I wrote a quick perl script and ran it with Cygwin.

use strict;open (FH, "> t3.txt") || die "Error: Can't write to file"; for (my $i = 0; $i < 10000; ++$i) { print FH "$irn"; } close FH;

It ran in 0.061s – more than 4 times faster than the Squeak. Well, this is not very good at all. MzScheme and Chicken Scheme both produced results similar to the Perl. Asking on the mailing list again, it seems that the integer to string conversion is implemented in Squeak for flexibility whereas [it is suspected that] all the other languages use C libraries.

Now, I’m not the sort of person who is in favour of premature optimisation, but if all the primitives are 4 times slower than Perl for reasons of flexibility that seems like a huge performance hit. It seems like it is harder to drop into C from Squeak than it would be from other scripting languages and Perl speed is about as slow as I like to go normally anyway. Maybe further investigation would reveal that the Transcript and integer to string comparisons are unusually slow. However, I have to balance the time spent investigating new programming languages is time I’m not spending developing my application.