Chapter 9: Deploying the Application

Richard Kenneth Eng
Learn How To Program
2 min readJun 4, 2017

--

Smalltalk is different from all other programming languages in wide use today. It’s image-based, which means that Smalltalk is its own little operating system separate and distinct from the host platform that you’re running on (whether that’s Linux, macOS, or Windows). Your application lives in this operating system, not in your host system.

With this understanding, you should know that when you run your application, you basically run it in the Smalltalk operating system.

For Cranky, then, there are a few things you should do to make it more like the conventional software applications you’re used to.

First, create an application folder. Let’s call it Cranky.

A Pharo application needs several files in the same folder:

  • the Pharo image that contains your application (Pharo.image)
  • the Pharo changes file (Pharo.changes)
  • the Pharo VM (pharo)
  • the Pharo Sources file (PharoV50.sources)
  • the Pharo library files (contained in lib/pharo/5.0–201705051953 folder)

Note that the library files’ numerical folder name may change in future versions of Pharo.

Additionally, Cranky needs two other files in the same folder:

  • the background image for the application (for example, hot_air_balloon_mysticmorning.jpg)
  • the shared C library for FFI (ffilibc.so)

For Cranky, start with a fresh image (the one you backed up when you first installed Pharo). Import the source code for the #Cranky class by dragging Cranky.st onto the Pharo window. (Recall that you created Cranky.st by right-clicking on the Cranky class in the System Browser and selecting ‘File Out’.) Choose ‘FileIn entire file’.

Next, there are a couple of ways in which you could start up Cranky automatically. If you start the application in the Pharo window and save the image to disk, then the next time you open the image, Cranky will be already executing!

Another way to do this is use a special application launcher class. First, you create the #ApplicationLauncher class:

Object subclass: #ApplicationLauncher
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Cranky'

Then you create a class method for this class:

ApplicationLauncher»startUp
Cranky new

Finally, you register the launcher class to be invoked at image startup by executing the following in the Playground:

Smalltalk addToStartUpList: ApplicationLauncher

Save the image and you’re good to go. The next time you open the image, Cranky will be automatically started.

You may want to shrink the Pharo window so that it doesn’t take up so much space. Allow enough space for Cranky to fit in the window.

To start the Cranky application, you open the Pharo image:

cd /home/pi/Cranky
./pharo Pharo.image &

The ampersand tells the shell to execute Pharo in a separate process. For convenience, you can put this shell script into a file called cranky.sh. Make sure you give it Execute permission. The shell script can be placed anywhere you want.

So there it is: your Cranky application is deployed.

--

--