Squeak Smalltalk and Seaside come to the iPhone
We talked to John M McIntosh about what was involved in getting Squeak to run on the iPhone and what programming model is used for writing applications.
It's more complex than just using a webview, for example the Wiki text entry feature of WikiServer has to bring up a multiline text view, then bring up the standard keyboard, and a keyboard control bar that let's you enter special characters and signal cancel or done. Although the Wiki information is presented using a Web view we have four different screens we manage thru the UIKIt . Since you have to have custom Objective-C classes to do this work and compile the VM you can choose to do some of the work in Smalltalk and some in Objective-C. Technically you could do *all* the work in Smalltalk but there is some performance issues with doing that and there is no real benefit.
Because the UI is unique to the iPhone you need to separate out the visual layer from the domain model, basic MVC logic. In fact WikiServer started out as a headless application with a control screen, then someone asked can't we edit the contents directly on the device? However we have not taken the approach of building a generic UI layer and enabling platform specific implementation, that would be much more work. But I should point out http://news.squeak.org/2009/01/08/squeak-goes-to-mars where Esteban Lorenzano has been building a Cocoa UI framework with intent of porting to the iPhone, and I'll note other Smalltalk system like Cincom's Visualworks use native widgets, but enabling that is a huge endeavour which we are not undertaking at this time.
InfoQ: What do you use for the web app? Seaside?
Seaside for serving the webpages, then UIWebView which is the UIView using Mobile Safari to render the pages. In theory any modest size seaside app could run on the iPhone.
InfoQ: Can you use Squeak images on the iPhone? Can you modify and persist them as on other systems? Do you get the same startup behavior as on, say, desktop systems?
The basic software at isqueak.org lets an iphone developer build a squeak vm that uses an image of his choice. The image requires some updates to bring in the multi-touch logic, and the Objective-C bridge. You then touch interact with the Squeak desktop, and yes optionally you can save an image.
Our Swirl application http://www.mobilewikiserver.com/Swirl.html Shows the Squeak desktop, with touch disabled, and we use UIKit Alert dialogs to prompt for information.
Our Fraction application
http://www.mobilewikiserver.com/Fraction.html Much like WikiServer has it has two UIKit screens and touch interaction are sent to a calculation engine which has no knowledge of the UI, it accepts keystrokes and updates a text string.
InfoQ: The current apps seem to have about 16/17 MBs in size. Is it possible to optimize that?
SqueakDocs and ST80Docs are much bigger than that since they are compressed and include the text source code for the April era Web based Squeak and Pharo development images. Once installed on the iPhone they need about 54 mb of Flash memory. This is different than ram size were it appears we need about 10MB to load the VM and Mobile Safari (without Safari it's a few MB), then the image, so they have about a 35MB ram footprint.
WikiServer out of the box requires much less ram memory, 14 MB, but that is a result of careful tuning.
InfoQ: What's the difference between the Pharo and Squeak versions?
The Squeak version is the developer image for web based development as found via links from squeak.org. We added in the logic from WikiServer to support the web view, the status, and info screens. Other than our additions, and a few minor changes to improve startup time there is no difference between it and the image you would download for your desktop. The Pharo version is a production of the Pharo team which wants to make a image which has more of a business focus than an educational focus, so much of Morphic and eToys is stripped out, and they have a more active update stream and proactive approach to bug fixing at the moment.
InfoQ: Is it possible to bring the size of the images down by stripping out unneeded stuff or is this already a stripped version?
I'll talk in detail about this issue at: http://www.esug.org/Conferences/2009/Current+List+of+Talks/Smalltalk+on+iPhone
The base Pharo image is about 22 MB, we removed 12MB of code to make WikiServer use about 10.5MB. Swirl which doesn't include Seaside is about 6 MB. It's possible to reduce that further, and we would like to exploit the work Craig Latta is doing on very small images http://netjam.org/projects/spoon/ We also exploit the virtual memory manager on the iPhone and only swap in pages to ram that actually are required for execution. For WikiServer it appears about 4MB of image data is not required for execution of the application.
The commercial Squeak-based applications are available in the Apple AppStore, WikiServer (NOTE: ITunes Link, there is also a Mobile Wiki Server website) and SqueakDocs using Squeak (NOTE: ITunes Link) and SqueakDoc using Pharo (NOTE: ITunes Link).