Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 38 ยท Getting Started

Installing Pharo and a Tour of the Smalltalk Environment

Install Pharo with the Pharo Launcher, understand VM, image and changes files, and take a guided tour of the World menu, Playground, System Browser, Inspector and Debugger.

To follow along with real Smalltalk you need a Smalltalk system on your own computer. This course uses Pharo, which is free, open source (MIT licence) and runs on Windows, macOS and Linux. This lesson shows the installation and then walks through the windows you will use every day.

The real Pharo cannot run on this site, so the Smalltalk code here is read-only. Menu names and shortcuts below match recent Pharo versions (11 to 13), but the user interface evolves a little with each release, so use the Help menu if something has moved.

Installing

The easiest way is the Pharo Launcher, a small application that downloads and manages images.

  1. Download the Pharo Launcher from the official Pharo website for your system.
  2. Start it, press New, and choose a recent stable template such as "Pharo 13.0 - 64bit (stable)".
  3. Give the image a name (for example learning) and click Create image.
  4. Select it in the list and press Launch.

The Launcher also lets you keep many images side by side, one per project, which is how most Pharo developers work. Alternative routes exist: the one-line install script (curl get.pharo.org | bash on macOS and Linux), a plain zip file, or a package manager.

VM, image and changes

A Pharo installation is made of three things:

Piece What it is
VM A small native program, different for each operating system, that executes bytecode
Image (.image) The snapshot of all objects: classes, tools, windows, your data
Changes (.changes) and sources (.sources) Logs of the code you typed and the source text of the system

You can copy an image to another computer with a matching VM and it comes up exactly as you left it. Never edit these files by hand.

flowchart LR
    L["Pharo Launcher"] -->|"downloads"| VM["VM"]
    L -->|"creates"| I["Image + changes"]
    VM -->|"loads and runs"| I

The Launcher gives you a VM and an image; the VM brings the image to life.

The World and its menu

When Pharo starts you see a World: a desktop inside the application window. Click on an empty area to open the World menu. It has entries such as:

  • Playground: a scratch pad for trying code.
  • System Browser: the place where classes and methods live.
  • Test Runner: run SUnit tests.
  • Iceberg: Git integration.
  • Tools, Window, System (Settings, Save, Quit).

Everything you open is a window made of objects. The mouse is used heavily: left click selects, right click opens a context menu that is full of useful commands ("Do it", "Print it", "Inspect it", "Browse implementors").

Tour of the main tools

Playground

The Playground is a text area where you type an expression, select it, and run it. Three commands matter most:

Command Windows / Linux macOS What it does
Do it Ctrl+D Cmd+D Evaluate the selection
Print it Ctrl+P Cmd+P Evaluate and print the result after the selection
Inspect it Ctrl+I Cmd+I Evaluate and open an inspector on the result

If nothing is selected, the current line is used. You will learn all three in Playground and your first programs.

System Browser

The browser has four panes: packages, classes, protocols (method categories) and methods, with the source of the selected method below. Select the class Integer, the protocol math functions and the method factorial to read how Smalltalk computes factorials in its own library. You are allowed, and encouraged, to read every method in the system.

A very useful shortcut: select any word in any tool and press Ctrl+B (Cmd+B) to browse the class with that name, or Ctrl+N (Cmd+N) to find who uses it.

Inspector

An inspector shows the instance variables of any object and lets you evaluate code in the context of that object (self is the inspected object). Inspect 3/4, a date, or a window and see what they are made of.

Debugger

When something goes wrong, the debugger opens. It shows the stack of message sends, the source of the current method, and the variables. You can edit the code right there, save, and press Proceed to continue. You will use it more in Tools and Image Workflow.

Transcript

The Transcript is the system log window: Transcript show: 'Hello'; cr. writes a line to it. It is the closest thing to console.log, though in Smalltalk you often just inspect or print the result instead.

Your first lines

Open a Playground from the World menu and type:

SMALLTALK
3 + 4.

Select it and press Ctrl+P (Cmd+P). Pharo prints 7 right after the selection. Now try:

SMALLTALK
'Pharo' reversed.
10 factorial.
Date today.

and use Print it on each. These are the same ideas as the last lesson: one object, one message.

JS Stand-in: a mini Print it

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Saving and leaving

  • World menu > Save (or Ctrl+S in the World) writes the image so your windows and code come back next time.
  • World menu > Save and quit does both.
  • Code you write in classes is also logged in the .changes file, so even if the image crashes you can usually recover your work. Later you will keep code in Git with Iceberg, which is the proper long-term home.
JS Stand-in: an image as a saved object graph

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which pieces make up a Pharo installation?

    The VM executes the image; the .changes and .sources files hold the text of code you wrote and the system's sources.
  2. 2. Which shortcut evaluates the selection and shows the result after it?

    Print it evaluates and inserts the printed result next to the code. Do it evaluates without showing a result; Inspect it opens an inspector.
  3. 3. What is the Pharo Launcher for?

    The Launcher creates, lists and starts images, each with the matching VM.
  4. 4. Where can you read the source of a method in the standard library?

    All system code is available in the image, and you may browse and even change it.

Summary

  • Install Pharo with the Pharo Launcher and create a fresh image.
  • A VM runs an image; the image holds all objects; changes/sources files keep code text.
  • The World menu opens the Playground, System Browser, Test Runner, Iceberg and more.
  • Do it, Print it and Inspect it are the three Playground commands you will use constantly.
  • Saving the image keeps your world; Git (Iceberg) is the long-term home of code.

Next: Playground and Your First Programs