Here is the first version of Embedded Squeak (developed using Squeak 2.2).
http://www.kurtz-fernhout.com/squeak/

Embedded Squeak is mostly Squeak with things removed. 
Less is more!

The current version is built for Windows, 
and features a text-only console in which you can type 
Smalltalk expressions. There is no image or changes file --
everything is in the EXE. Almost all the i/o primitives 
are stubbed out. This version of the code should compile/run 
on almost all platforms with minimal changes 
(you just need to know how to do character I/O). 

Why would one want to use a stripped-down Squeak?
* You might want to embed Squeak in other applications,
devices like cellular phones, headless web servers, 
or even PDAs with native widgets (Pilot/Newton?).
(Andrew Brault's Pocket Smalltalk is inspirational in this regard).
* Squeak-e is preparation work for other things.
Now one can create an image with just the compiler
and various support classes, and build a totally new
GUI / event system on top of the compiler core.
One can also then come up with a package system
to load packages onto this stripped down Squeak,
to build up to the big Squeak.
* Smalltalk novices can experiment with just the language 
for a day before jumping into the development system. 

Why would one want a Squeak with the image embedded in the EXE?
* Using it is immediate gratification on ports to new
hardware -- if you can get the console going,
you at least have the compiler options set correctly.
There is no need to mess with files or display drivers at the start.
* Smalltalk novices may find it easier to get one self-contained EXE 
to run (even if they can't save and reload their image).
* Quick startup easily installed Perl/Python alternative.

Main features:
* subtracted: most VM i/o functionality 
(including file & GUI support * sound).
* added: one Squeak method to write image as C memory array,
and read that array at program startup. 
* added: EmbeddedSystem class to process serial i/o
as console command lines.

I made these modifications to mini.image to support embedding:
EmbeddedSystem (original)
SerialPort (loaded and used as is, except comments out primClose in open)
Preferences (modified on startup by EmbeddedSystem, but also saved in this image)
SystemDictionary>>processStartUpList
SystemDictionary>>processShutdownList

Evaluate the code in:  
"EmbeddedSystem prepareImageHeaderFile"
to create 'ImageFileInMemory.c' from 'embedded.image'.

Ideally, you should be able to file in the four included *.st files 
into 'mini.image' and be ready to save 'embedded.image'.
Import the chanages to SystemDictionary last.
However, I have found that sometimes the image saved does
not boot the first time. After loading and saving it again, 
it works. I would like to resolve this.
You can do prelimiary testing of the changes by
hooking COM1 to COM2 via a null modem cable, and
using the included Hyperterminal settings from COM1
(the default serial port for the EmbeddedSystem server is 2,
although the port doesn't matter in the stand-alone console version).

You can (but should not have to) evaluate
"EmbeddedSystem shutDown."
before saving. 
EmbeddedSystem is restarted automatically on loading.

Also, before saving, you may wish to 
remove all windows from the screen.
Otherwise, sometimes the image that is built will not boot
all the way. However, this problem may be due to the
same cause as the earlier mentioned problem,
since I have made versions with open windows that booted.

I used the non-inlined version of the interpreter. 
I based the image on mini.image and the core code on sqMacMinial.c.

The class EmbeddedSystem is released under 
the terms of the Squeak license as a new base class.

A Microsoft VC++ 5.0 Project is included. If building your
own project, you need to define EMBEDDED to embed the image. 
You also need to add a /Zm500 to the compiler options to
allow the compiler to compile the 2MB+ C file.

I tried this embedding approach on the Newton 14 months ago, 
but alas the C++ compiler did not have such an option and
choked on a big image definition file. 
Maybe a 150K image might compile for the Newton?  

Things to do (and I'd be grateful for help):
* create an expression to strip the GUI from the image 
and then save the image (maybe reducing the image to 200K?).
* adding exceptions (so GUI isn't launched ever -- 
a top level handler reports to console).
* optionally generating VM without bitblit, sound primitives, other stuff.
* resolving why some MemoryImageFiles don't load properly 
(probably related to state of image when saved).
* a better command line interface, with macros, 
code filein format reader, and support for multi line expressions
* better backspace support
* ports (especially to DOS).
* Transcript redirection to the console
* socket support for events to communicate with a headed Squeak 
to browse code and debug processes. I was originally going 
to do this at the VM level, but now I think it's OK 
to do this in Squeak for a start.
* support for pluggable I/O primitives 
and other dynamicaly loaded primitives
* generating interp.c as a C++ class (for the Newton).
* getting support for the "image embedding" code changes 
in the mainline Squeak distribution.
  
Enjoy. If anyone can think of a catchy name for Embedded Squeak 
I'll consider renaming it. Right now I'm leanign to
Squeak-e, for Squeak-embedded. But how about 
Squeakette? (ette = Elegant Technology To Embed)

For changes or suggestions regarding Embedded Squeak,
contact me at: 

Paul Fernhout ( mailto:pdfernhout@kurtz-fernhout.com )
Kurtz-Fernhout Software
http://www.kurtz-fernhout.com

pdf 12/20/1998
