"Hello World" in Squeak -> Burn the Disk Packs!

Tim Olson tim at jumpnet.com
Wed Jun 21 13:51:33 UTC 2000


>Can anyone comment on what it would take to produce a minimal Squeak
>image (say 1K beyond the header) that would write out "hello world" to a
>disk file? Is such a thing possible in under 1K?

Interesting problem.  I just wrote a "simple" helloWorld method:

helloWorld

	| f |
	f := FileStream fileNamed: 'hello.out'.
	f nextPutAll: 'Hello, world!'; cr.
	f close.


Then traced it, collecting the set of all CompiledMethods it invoked when 
running:

tallyMethodSizesinBlock: aBlock

	| usedMethods w |
	usedMethods := Set new.
	thisContext sender
		runSimulated: aBlock
		contextAtEachStep: [:ctxt | usedMethods add: ctxt method].		
	^ usedMethods detectSum: [:m | m size].


For the helloWorld above I came up with 2426 bytes, total, from the 
following compiledMethods:


UndefinedObject>>#DoIt
SequenceableCollection>>#replaceFrom:to:with:startingAt:
StandardFileStream class>>#fileNamed:
Magnitude>>#max:
StandardFileStream class>>#register:
WeakRegistry>>#add:
FileStream class>>#fileNamed:
FileDirectory>>#fullPathFor:
FileStream class>>#fullName:
FileDirectory>>#fullNameFor:
Object>>#myDependents:
Set>>#findElementOrNil:
IdentityDictionary>>#scanFor:
WeakRegistry>>#protected:
BlockContext>>#ifError:
Process>>#errorHandler:
Dictionary>>#scanFor:
LookupKey class>>#key:
WeakKeyAssociation>>#key:
Association>>#value:
StandardFileStream>>#nextPutAll:
Character class>>#value:
StandardFileStream>>#nextPut:
StandardFileStream class>>#unregister:
Object>>#=
Set>>#fixCollisionsFrom:
Dictionary>>#keyAt:
FileDirectory>>#checkName:fixErrors:
FileDirectory class>>#splitName:to:
SequenceableCollection>>#copyFrom:to:
StandardFileStream>>#open:forWrite:
Object>>#retryWithGC:until:
Dictionary>>#removeKey:ifAbsent:
Semaphore>>#critical:ifError:
BlockContext>>#on:do:
WeakKeyDictionary>>#at:put:
Association class>>#key:value:
Set>>#atNewIndex:put:
WeakRegistry>>#remove:ifAbsent:
FileDirectory>>#pathNameDelimiter
FileDirectory>>#slash
FileDirectory class>>#slash
FileDirectory class>>#default
HelloWorld class>>#helloWorld
FileStream class>>#concreteStream
MacFileDirectory class>>#pathNameDelimiter
ArrayedCollection class>>#new
Collection>>#isEmpty
FileDirectory class>>#maxFileNameLength
SequenceableCollection>>#last
Character>>#asString
SequenceableCollection>>#copyReplaceFrom:to:with:
Object>>#species
FileStream class>>#new
StandardFileStream>>#register
WeakArray class>>#isFinalizationSupported
StandardFileStream class>>#registry
Object>>#executor
StandardFileStream>>#actAsExecutor
Object>>#actAsExecutor
Object>>#breakDependents
Object>>#hash
Set>>#fullCheck
WriteStream>>#cr
Character class>>#cr
StandardFileStream>>#close
StandardFileStream>>#unregister
WeakKeyAssociation>>#key
SequenceableCollection>>#findLast:
ArrayedCollection class>>#with:
SequenceableCollection>>#,
String>>#replaceFrom:to:with:startingAt:


     -- tim






More information about the Squeak-dev mailing list