Skip to the content.

Chapter 27: Pharo - The Modern Smalltalk

Welcome to Part VIII: Exploring the Smalltalk Variations! You’ve learned Smalltalk fundamentals using examples that work across implementations. Now we’ll explore specific Smalltalk systems, starting with Pharo - the modern, actively developed Smalltalk that’s pushing the language forward.

Throughout this book, most examples have been Pharo-centric because it’s accessible, well-documented, and actively maintained. Now let’s explore what makes Pharo special and why it’s an excellent choice for modern development.

What is Pharo?

Pharo is a pure object-oriented dynamically typed language descending from Smalltalk-80. It began in 2008 as a fork of Squeak, with a focus on:

Pharo is open source (MIT license) and runs on Windows, macOS, and Linux.

Why Pharo?

1. Modern and Maintained

Pharo releases a new major version annually:

2. Excellent Documentation

3. Best-in-Class Tools

4. Rich Ecosystem

Thousands of packages available:

5. Professional Quality

Used in:

Installing Pharo

Quick Install

  1. Visit pharo.org
  2. Click Download
  3. Choose your platform:
    • Windows: Download and extract
    • macOS: Download .dmg, drag to Applications
    • Linux: Download and extract
  4. Run the launcher or VM

That’s it! You have a complete Pharo environment.

The PharoLauncher manages multiple Pharo images:

  1. Download from pharo.org
  2. Install
  3. Launch PharoLauncher
  4. Select an image template (e.g., “Pharo 11.0 - 64bit (stable)”)
  5. Click “Create Image”
  6. Launch the image

Now you can easily manage multiple projects and Pharo versions!

First Steps in Pharo

The Welcome Window

When Pharo opens, you see:

Close the welcome window for now.

Opening Tools

Press shortcuts to open tools:

Try opening a Playground and evaluate:

'Welcome to Pharo!' inspect

An Inspector opens showing the string!

Pharo’s Philosophy

Pharo follows core principles:

1. Everything is an Object

Truly everything:

2. Live Programming

The system is always running. You modify it while it runs. No compile-restart cycle.

3. Simple and Uniform

Small syntax, few keywords, uniform message sending. Easy to learn, powerful to use.

4. Reflective

The system can inspect and modify itself. You can browse, change, and extend everything.

5. Open and Clean

All source code is available and readable. Clean, modern codebase without legacy baggage.

Key Pharo Features

Modern UI Framework

Pharo uses Spec 2 for building UIs:

| presenter |
presenter := SpPresenter new.
presenter application: SpApplication new.
presenter layout: (SpBoxLayout newTopToBottom
    add: (SpLabelPresenter new label: 'Hello Pharo!'); yourself).
presenter open

Spec provides reusable, composable UI components.

Iceberg (Git Integration)

Built-in Git support via Iceberg:

See Chapter 18 for details.

Rich Standard Library

Pharo includes excellent collection classes:

Strong support for:

Quality Tools

Documentation Browser

Access documentation from within Pharo:

Pharo’s Ecosystem

Web Development

Seaside - Component-based web framework:

renderContentOn: html
    html heading: 'Welcome!'.
    html paragraph: 'This is Seaside on Pharo.'

Teapot - Micro web framework:

Teapot on
    GET: '/hello' -> 'Hello, Pharo!';
    start

Data Visualization

Roassal - Powerful visualization library:

| view |
view := RSCanvas new.
(1 to: 20) do: [ :i |
    view add: (RSEllipse new size: i * 5; yourself) ].
view open

Database Access

Voyage - Object persistence:

VOMongoRepository
    host: 'localhost'
    database: 'mydb'.

user := User new name: 'Alice'.
user save

Machine Learning

PolyMath - Scientific computing:

| matrix |
matrix := PMMatrix rows: #((1 2) (3 4)).
matrix determinant

API Development

OpenAPI - REST API generation from specs:

OpenAPIGenerator generate: '/path/to/openapi.yaml'

Pharo Projects

Real projects built with Pharo:

Commercial

Open Source

Research

Used in universities worldwide for:

Learning Resources

Books (All Free Online!)

  1. Pharo by Example - Comprehensive introduction
  2. Deep into Pharo - Advanced topics
  3. Enterprise Pharo - Web development
  4. Numerical Methods with Pharo - Scientific computing

Available at: books.pharo.org

Online Courses

Pharo MOOC - Free online course with videos:

Available at: mooc.pharo.org

Community

Unique Pharo Features

Fluid Class Definition

Define classes with a fluent API:

Object << #Point2D
    slots: { #x . #y };
    package: 'MyApp'

Cleaner than traditional syntax!

Slots

Advanced instance variables with behavior:

Object << #Person
    slots: { #name => ObservableSlot };
    package: 'MyApp'

Slots can trigger events, enforce constraints, etc.

First-Class Instance Variables

Access instance variables reflectively:

object instVarNamed: 'x' put: 42

Intercept and modify behavior dynamically:

method := MyClass >> #myMethod.
method ast link: (MetaLink new
    metaObject: [ :node | Transcript show: 'Executed!'; cr ];
    selector: #value:;
    yourself)

Now every call to myMethod logs “Executed!”

Calypso Browser

The default browser in modern Pharo - faster, more extensible than older browsers.

Development Workflow in Pharo

Typical Session

  1. Launch Pharo
  2. Open Playground - Experiment with code
  3. Create classes - Use System Browser
  4. Write tests - Test-driven development
  5. Run tests - Test Runner
  6. Debug - Fix issues in Debugger
  7. Commit - Save to Git via Iceberg
  8. Save Image - Preserve your work

Iterative Development

Write method  Test  Debug  Refactor  Repeat

All without restarting!

Pharo vs Other Smalltalks

Feature Pharo Squeak Smalltalk/X VisualWorks
License MIT MIT Various Commercial
Active Dev ✅ Very ✅ Yes ✅ Yes ✅ Yes
Modern Tools ✅ Excellent ⚠️ Good ⚠️ Good ✅ Excellent
Git Integration ✅ Built-in ❌ Add-on ⚠️ Limited ⚠️ Limited
Documentation ✅ Excellent ⚠️ Good ⚠️ Good ✅ Excellent
Community ✅ Large ⚠️ Medium ⚠️ Small ⚠️ Small
Education ✅ Great ✅ Great ⚠️ Good ⚠️ Good
Commercial Use ✅ Yes ⚠️ Some ✅ Yes ✅ Yes

Pharo excels in modern development practices and community support.

When to Use Pharo

Great For:

Consider Alternatives For:

Installing Libraries

Use Metacello to install packages:

Metacello new
    baseline: 'Roassal3';
    repository: 'github://ObjectProfile/Roassal3:master/src';
    load

Or use Catalog Browser:

Customizing Pharo

Themes

Change the look:

Fonts

Key Bindings

Startup Actions

Run code on startup:

SessionManager default
    registerSystemClassNamed: #MyStartup

Try This!

Explore Pharo:

  1. Install PharoLauncher
    • Download from pharo.org
    • Create a new Pharo 11 image
    • Launch it
  2. Take the Tour
    • Open Welcome window
    • Click “Interactive Tutorial”
    • Follow the guided tour
  3. Experiment with Tools
    • Open Playground (Ctrl+O W)
    • Open Browser (Ctrl+O B)
    • Try Spotter (Shift+Enter)
  4. Build Something
    • Create a class
    • Add methods
    • Write tests
    • Run them!
  5. Install a Package
    Metacello new
        baseline: 'PetitParser2';
        repository: 'github://kursjan/petitparser2';
        load
    
  6. Visualize Data
    Metacello new
        baseline: 'Roassal3';
        repository: 'github://ObjectProfile/Roassal3/src';
        load.
    
    | canvas |
    canvas := RSCanvas new.
    (1 to: 20) do: [ :i |
        canvas add: (RSBox new size: i * 3; yourself) ].
    RSFlowLayout on: canvas nodes.
    canvas open
    
  7. Read the Books
    • Visit books.pharo.org
    • Read “Pharo by Example”
  8. Join the Community
    • Join Discord: discord.gg/pharo
    • Ask questions
    • Share your projects!

Pharo’s Future

Pharo continues evolving:

Recent Additions

Upcoming Features

The Pharo Philosophy

Pharo believes:

  1. Simplicity over complexity - Small, clean, understandable
  2. Live programming - Modify while running
  3. Everything is an object - No exceptions
  4. Uniform syntax - One way to do things
  5. Reflectivity - Inspect and change everything
  6. Open source - Community-driven development
  7. Education first - Teaching is a priority
  8. Industrial strength - Professional quality

Looking Ahead

You now understand Pharo - the modern, actively developed Smalltalk! You know:

In Chapter 28, we’ll explore Squeak - Pharo’s parent, focused on multimedia and education. Squeak powers projects like Scratch and has unique capabilities for creating rich, interactive experiences.

Then Chapter 29 covers the Glamorous Toolkit - a moldable development environment that reimagines how we work with code and data.

Part VIII shows you the diversity and richness of the Smalltalk world!


Key Takeaways:


Previous: Chapter 26 - Packages and Code Organization Next: Chapter 28 - Squeak - Multimedia and Education