<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Is Squeak Smalltalk Slow?</title>
	<atom:link href="http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/feed/" rel="self" type="application/rss+xml" />
	<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/</link>
	<description>Leveraging Perl and Emacs</description>
	<lastBuildDate>Sat, 15 Jun 2013 02:12:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Casey Ransberger</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-8978</link>
		<dc:creator><![CDATA[Casey Ransberger]]></dc:creator>
		<pubDate>Tue, 17 May 2011 23:29:45 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-8978</guid>
		<description><![CDATA[Lots of answers to your question already, to summarize: depends on the implementation on the methods you&#039;re using in Smalltalk, and on the implementation of the virtual machine. 

Well, and then did I mention that it depends on the implementation of the virtual machine? It turns out that fast VMs for dynamic languages are kind of like black magic in terms of the number of people who understand them well, but you can get one for Squeak now!

http://www.mirandabanda.org/cogblog/downloads/

It has a JIT, polymorphic inline thingummies, and gets the job done right fast. Combined with improvements made to the Smalltalk code recently in Squeak, the system has gotten quite fast.

Wandered past this post for the second time and thought I&#039;d set the record straight now that the game has changed in the Squeak world:)]]></description>
		<content:encoded><![CDATA[<p>Lots of answers to your question already, to summarize: depends on the implementation on the methods you&#8217;re using in Smalltalk, and on the implementation of the virtual machine. </p>
<p>Well, and then did I mention that it depends on the implementation of the virtual machine? It turns out that fast VMs for dynamic languages are kind of like black magic in terms of the number of people who understand them well, but you can get one for Squeak now!</p>
<p><a href="http://www.mirandabanda.org/cogblog/downloads/" rel="nofollow">http://www.mirandabanda.org/cogblog/downloads/</a></p>
<p>It has a JIT, polymorphic inline thingummies, and gets the job done right fast. Combined with improvements made to the Smalltalk code recently in Squeak, the system has gotten quite fast.</p>
<p>Wandered past this post for the second time and thought I&#8217;d set the record straight now that the game has changed in the Squeak world:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IanO</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1017</link>
		<dc:creator><![CDATA[IanO]]></dc:creator>
		<pubDate>Fri, 25 May 2007 16:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1017</guid>
		<description><![CDATA[Hi Goran,

That is really cool: it really nicely demonstrates the benefits of turtles all the way down I guess.  Cheers for the update.

Ian]]></description>
		<content:encoded><![CDATA[<p>Hi Goran,</p>
<p>That is really cool: it really nicely demonstrates the benefits of turtles all the way down I guess.  Cheers for the update.</p>
<p>Ian</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Göran Krampe</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1016</link>
		<dc:creator><![CDATA[Göran Krampe]]></dc:creator>
		<pubDate>Fri, 25 May 2007 13:06:55 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1016</guid>
		<description><![CDATA[Hehe, ok, after further trixing I am down to 30 ms with cleaner code.
I am posting these changes to squeak-dev.]]></description>
		<content:encoded><![CDATA[<p>Hehe, ok, after further trixing I am down to 30 ms with cleaner code.<br />
I am posting these changes to squeak-dev.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Göran Krampe</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1015</link>
		<dc:creator><![CDATA[Göran Krampe]]></dc:creator>
		<pubDate>Fri, 25 May 2007 10:59:36 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1015</guid>
		<description><![CDATA[Hmmm, ok, the code-tag didn&#039;t like &lt; and &gt; obviously, one more try:

&lt;code&gt;
printString
	&quot;Highly optimized version for base 10, and utilizing the fact
	that we know SmallInteger maxVal and not using a WriteStream.&quot;
	
	&#124; integer next result i sz &#124;
	self = 0 ifTrue: [^&#039;0&#039;].
	self &lt; 0 ifTrue: [^&#039;-&#039;, self negated printString].
	result := String new: 10.
	i := 10.
	integer := self.
	[integer &gt; 0] whileTrue: [
		next := integer // 10.
		result byteAt: i put: 48 + (integer - (next * 10)).
		i := i - 1.
		integer := next].
	sz := 10 - i.
	^(String new: sz) replaceFrom: 1 to: sz with: result startingAt: i+1
&lt;/code&gt;]]></description>
		<content:encoded><![CDATA[<p>Hmmm, ok, the code-tag didn&#8217;t like &lt; and &gt; obviously, one more try:</p>
<p><code><br />
printString<br />
	"Highly optimized version for base 10, and utilizing the fact<br />
	that we know SmallInteger maxVal and not using a WriteStream."</p>
<p>	| integer next result i sz |<br />
	self = 0 ifTrue: [^'0'].<br />
	self &lt; 0 ifTrue: [^'-', self negated printString].<br />
	result := String new: 10.<br />
	i := 10.<br />
	integer := self.<br />
	[integer &gt; 0] whileTrue: [<br />
		next := integer // 10.<br />
		result byteAt: i put: 48 + (integer - (next * 10)).<br />
		i := i - 1.<br />
		integer := next].<br />
	sz := 10 - i.<br />
	^(String new: sz) replaceFrom: 1 to: sz with: result startingAt: i+1<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Göran Krampe</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1013</link>
		<dc:creator><![CDATA[Göran Krampe]]></dc:creator>
		<pubDate>Fri, 25 May 2007 10:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-1013</guid>
		<description><![CDATA[Hi!

I am a long time Squeaker/Smalltalker and looked into this for fun.
If we look at your original code there are a few things we can do:

1. Use #printString instead of asString. Of course gives almost no improvements but it might be the &quot;correct&quot; message to use.

2. Avoid concatenation since it has to create new buffer and copy etc.

3. Not call &quot;String crlf&quot; every time. We can assign &quot;crlf := String crlf&quot; in a local var and use that in the loop.

4. And finally of course, we could create an optimized #printString for SmallIntegers.

So let&#039;s see, here is SmallInteger&gt;&gt;printString:
&lt;code&gt;
printString
	&quot;Highly optimized version for base 10, and utilizing the fact
	that we know SmallInteger maxVal and not using a WriteStream.&quot;
	
	&#124; integer next result i sz &#124;
	self = 0 ifTrue: [^&#039;0&#039;].
	self  0] whileTrue: [
		next := integer // 10.
		result byteAt: i put: 48 + (integer - (next * 10)).
		i := i - 1.
		integer := next].
	sz := 10 - i.
	^(String new: sz) replaceFrom: 1 to: sz with: result startingAt: i+1
&lt;/code&gt;
And here is your snippet with some modifications:
&lt;code&gt;
&#124; myFile ios &#124;
ios := ReadWriteStream on: &#039;&#039;.
crlf := String crlf.
Transcript show: &#039;Populate Buffer: &#039;,
        (Time millisecondsToRun: [
                1 to: 10000 do: [
                        :i &#124; ios nextPutAll: i printString; nextPutAll: crlf
                        ]]) asString , &#039; millseconds&#039; ; cr.
MessageTally spyOn: [
 	1 to: 10000 do: [
 		:i &#124; ios nextPutAll: i printString; nextPutAll: crlf]].
Transcript show: &#039;Position: &#039;, (ios position) asString ; cr.
myFile := StandardFileStream fileNamed: &#039;test.txt&#039;.
Transcript show: &#039;Output Buffer: &#039;,
                    (Time millisecondsToRun: [
        myFile nextPutAll: (ios contents); close]) asString,
     &#039; milliseconds&#039; ; cr.
&lt;/code&gt;

The end result? On my box this makes your test &lt;em&gt;run more than 4x faster - from 141 ms to 34 ms for the population&lt;/em&gt;. I would presume this matches both Perl and GNU St given your numbers.

Now, note that I did this just for fun - the comparison in itself doesn&#039;t say anything in general IMHO. I was just curious how much faster we can make it using &quot;regular&quot; optimizations.

regards, Göran]]></description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>I am a long time Squeaker/Smalltalker and looked into this for fun.<br />
If we look at your original code there are a few things we can do:</p>
<p>1. Use #printString instead of asString. Of course gives almost no improvements but it might be the &#8220;correct&#8221; message to use.</p>
<p>2. Avoid concatenation since it has to create new buffer and copy etc.</p>
<p>3. Not call &#8220;String crlf&#8221; every time. We can assign &#8220;crlf := String crlf&#8221; in a local var and use that in the loop.</p>
<p>4. And finally of course, we could create an optimized #printString for SmallIntegers.</p>
<p>So let&#8217;s see, here is SmallInteger&gt;&gt;printString:<br />
<code><br />
printString<br />
	"Highly optimized version for base 10, and utilizing the fact<br />
	that we know SmallInteger maxVal and not using a WriteStream."</p>
<p>	| integer next result i sz |<br />
	self = 0 ifTrue: [^'0'].<br />
	self  0] whileTrue: [<br />
		next := integer // 10.<br />
		result byteAt: i put: 48 + (integer - (next * 10)).<br />
		i := i - 1.<br />
		integer := next].<br />
	sz := 10 - i.<br />
	^(String new: sz) replaceFrom: 1 to: sz with: result startingAt: i+1<br />
</code><br />
And here is your snippet with some modifications:<br />
<code><br />
| myFile ios |<br />
ios := ReadWriteStream on: ''.<br />
crlf := String crlf.<br />
Transcript show: 'Populate Buffer: ',<br />
        (Time millisecondsToRun: [<br />
                1 to: 10000 do: [<br />
                        :i | ios nextPutAll: i printString; nextPutAll: crlf<br />
                        ]]) asString , ' millseconds' ; cr.<br />
MessageTally spyOn: [<br />
 	1 to: 10000 do: [<br />
 		:i | ios nextPutAll: i printString; nextPutAll: crlf]].<br />
Transcript show: 'Position: ', (ios position) asString ; cr.<br />
myFile := StandardFileStream fileNamed: 'test.txt'.<br />
Transcript show: 'Output Buffer: ',<br />
                    (Time millisecondsToRun: [<br />
        myFile nextPutAll: (ios contents); close]) asString,<br />
     ' milliseconds' ; cr.<br />
</code></p>
<p>The end result? On my box this makes your test <em>run more than 4x faster &#8211; from 141 ms to 34 ms for the population</em>. I would presume this matches both Perl and GNU St given your numbers.</p>
<p>Now, note that I did this just for fun &#8211; the comparison in itself doesn&#8217;t say anything in general IMHO. I was just curious how much faster we can make it using &#8220;regular&#8221; optimizations.</p>
<p>regards, Göran</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Paes</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-819</link>
		<dc:creator><![CDATA[Alex Paes]]></dc:creator>
		<pubDate>Wed, 09 May 2007 23:54:18 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-819</guid>
		<description><![CDATA[I have started learning smalltalk just a couple of months ago so i decided to try out your code, i tried your code in 3 different smalltalk implementations (squeak, Smalltalk/X and GNU Smalltalk) i had to make some minor changes (#printString instead of #asString and different classes for file streams). The results were as follows:

Squeak: ~170ms
Smalltalk/X: ~10ms
Gnu Smalltalk: ~80ms

I know Smalltalk/X has some optimizations through primitives but i&#039;m not sure about Gnu Smalltalk.

After, i decided to try a different approach outputting the 10,000 numbers directly to a file:

&lt;code&gt;
&#124;ios&#124;
ios := StandardFileStream fileNamed: &#039;c:\test.txt&#039;.
Transcript
        cr;
	show: &#039;Write to file stream: &#039;;
	show: 
		(Time millisecondsToRun:
			[1 to: 10000 do: [:each&#124; each printOn: ios. ios nextPut: Character lf]]) printString;
	show: &#039; ms&#039;;
        cr.
&lt;/code&gt;

This last code performed with the following results:

squeak: ~210ms
Smalltalk/X: ~10ms
Gnu Smalltalk: ~62ms

So if i see it correctly the Smalltalk/X primitive optimizations result in a constant time for both approaches. Gnu Smalltalk slightly benefits from this approach (FileStream possibly performs buffered I/O ??) while squeak comes last with even worse results. I&#039;d believe commercial smalltalk implementations should yield even better results (Cincom Visual Works, Instantiations VA Smalltalk, Dolphin).

So although i find smalltalk very acceptable in terms of performance for most applications, i must agree that at least when comparing to other implementations and almost certainly with other languages, squeak is somewhat slow.]]></description>
		<content:encoded><![CDATA[<p>I have started learning smalltalk just a couple of months ago so i decided to try out your code, i tried your code in 3 different smalltalk implementations (squeak, Smalltalk/X and GNU Smalltalk) i had to make some minor changes (#printString instead of #asString and different classes for file streams). The results were as follows:</p>
<p>Squeak: ~170ms<br />
Smalltalk/X: ~10ms<br />
Gnu Smalltalk: ~80ms</p>
<p>I know Smalltalk/X has some optimizations through primitives but i&#8217;m not sure about Gnu Smalltalk.</p>
<p>After, i decided to try a different approach outputting the 10,000 numbers directly to a file:</p>
<p><code><br />
|ios|<br />
ios := StandardFileStream fileNamed: 'c:\test.txt'.<br />
Transcript<br />
        cr;<br />
	show: 'Write to file stream: ';<br />
	show:<br />
		(Time millisecondsToRun:<br />
			[1 to: 10000 do: [:each| each printOn: ios. ios nextPut: Character lf]]) printString;<br />
	show: ' ms';<br />
        cr.<br />
</code></p>
<p>This last code performed with the following results:</p>
<p>squeak: ~210ms<br />
Smalltalk/X: ~10ms<br />
Gnu Smalltalk: ~62ms</p>
<p>So if i see it correctly the Smalltalk/X primitive optimizations result in a constant time for both approaches. Gnu Smalltalk slightly benefits from this approach (FileStream possibly performs buffered I/O ??) while squeak comes last with even worse results. I&#8217;d believe commercial smalltalk implementations should yield even better results (Cincom Visual Works, Instantiations VA Smalltalk, Dolphin).</p>
<p>So although i find smalltalk very acceptable in terms of performance for most applications, i must agree that at least when comparing to other implementations and almost certainly with other languages, squeak is somewhat slow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A Basic Transcripter in PLT Scheme &#171; A Curious Programmer</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-746</link>
		<dc:creator><![CDATA[A Basic Transcripter in PLT Scheme &#171; A Curious Programmer]]></dc:creator>
		<pubDate>Thu, 03 May 2007 13:46:24 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-746</guid>
		<description><![CDATA[[...] When I retried the same in Squeak it took around 5700ms although I&#8217;m certain it had earlier taken more than 10 seconds. This is a different computer and a different image but maybe the Squeak Transcripter isn&#8217;t [...]]]></description>
		<content:encoded><![CDATA[<p>[...] When I retried the same in Squeak it took around 5700ms although I&#8217;m certain it had earlier taken more than 10 seconds. This is a different computer and a different image but maybe the Squeak Transcripter isn&#8217;t [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JJ</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-577</link>
		<dc:creator><![CDATA[JJ]]></dc:creator>
		<pubDate>Fri, 13 Apr 2007 18:33:17 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-577</guid>
		<description><![CDATA[I think if you look at the use some people have put Squeak through (heavy multimedia capabilites), you would see that Squeak isn&#039;t such a loser proposition. Take a look at the Scratch programming langauge for kids, or Croquet.]]></description>
		<content:encoded><![CDATA[<p>I think if you look at the use some people have put Squeak through (heavy multimedia capabilites), you would see that Squeak isn&#8217;t such a loser proposition. Take a look at the Scratch programming langauge for kids, or Croquet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IanO</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-575</link>
		<dc:creator><![CDATA[IanO]]></dc:creator>
		<pubDate>Fri, 13 Apr 2007 16:25:53 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-575</guid>
		<description><![CDATA[&lt;blockquote&gt;Grant wrote: Am I reading that right? You’re using a profiler in Smalltalk, and just timing the perl? Apples and oranges. Profilers have an inherant performance penalty in any language.&lt;/blockquote&gt;
The timings reported come from this line without the profiler running:
&lt;code&gt;
Transcript show: &#039;Populate Buffer: &#039;,
        (Time millisecondsToRun: [
                1 to: 10000 do: [
                        :i &#124; ios nextPutAll: ((i asString) , String crlf)
                        ]]) asString , &#039; millseconds&#039; ; cr.
&lt;/code&gt;
The profiler shows that 80% of the time is spent converting i from a SmallInteger to a String.]]></description>
		<content:encoded><![CDATA[<blockquote><p>Grant wrote: Am I reading that right? You’re using a profiler in Smalltalk, and just timing the perl? Apples and oranges. Profilers have an inherant performance penalty in any language.</p></blockquote>
<p>The timings reported come from this line without the profiler running:<br />
<code><br />
Transcript show: 'Populate Buffer: ',<br />
        (Time millisecondsToRun: [<br />
                1 to: 10000 do: [<br />
                        :i | ios nextPutAll: ((i asString) , String crlf)<br />
                        ]]) asString , ' millseconds' ; cr.<br />
</code><br />
The profiler shows that 80% of the time is spent converting i from a SmallInteger to a String.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: IanO</title>
		<link>http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-574</link>
		<dc:creator><![CDATA[IanO]]></dc:creator>
		<pubDate>Fri, 13 Apr 2007 16:23:02 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/2007/04/11/is-squeak-smalltalk-slow/#comment-574</guid>
		<description><![CDATA[&lt;blockquote&gt;Kirit wrote: It’s a while since I did any Smalltalk seriuosly and I’ve never done any Perl, but it looks to me like the two versions aren’t doing the same thing. I’m not sure how much difference it would make though - maybe very little.&lt;/blockquote&gt;
My initial version wrote directly to the file and took almost the same amount of time.  On the Squeak beginner list it was suggested that this was because the I/O is buffered in Perl and unbuffered in Squeak and the recommendation was to write to a stream in memory first and then dump to a file.]]></description>
		<content:encoded><![CDATA[<blockquote><p>Kirit wrote: It’s a while since I did any Smalltalk seriuosly and I’ve never done any Perl, but it looks to me like the two versions aren’t doing the same thing. I’m not sure how much difference it would make though &#8211; maybe very little.</p></blockquote>
<p>My initial version wrote directly to the file and took almost the same amount of time.  On the Squeak beginner list it was suggested that this was because the I/O is buffered in Perl and unbuffered in Squeak and the recommendation was to write to a stream in memory first and then dump to a file.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
