Exploring Pharo World Menu and Language Overview
Notes are based on Pharo by Example, a free book suggested by a Mooc called Live Object Programming in Pharo
Pharo by example requires a basic understanding of programming and object-oriented principles (rudimentary is okay). This book is focused around understanding the development environment itself, the Pharo language (based on Smalltalk) and tools. The focus is more on the technology than object-oriented design. That is taught in the MOOC linked to above.
Try not to care. Beginning Smalltalk programmers often have trouble because they think they need to understand all the details of how a thing works before they can use it... One of the great leaps in OO is to be able to answer the question "How does this work?" with "I don't care".
The quote from the book book above hit me. The whole reason I started reading this book was because I wanted to understand the ins and outs of the Pharo environment.
Install and open the Pharo Launcher
I used Homebrew to install the Pharo launcher to my computer. I recorded what I did in a previous post called Setting up Pharo Smalltalk Developer Environment.
When you install and open Pharo Lancher, you should get a GUI similar to this:
The first thing I did was download a new image (a virtual evironment with everything it needs to run). To do this, I selected "Pharo 6.0 (stable)" from the template menu on the left of the screen. Then I double clicked on "latest-64" because my computer has a 64bit processer (I asked for help with this part because I didn't know which template to choose). It'll then give you the option to change the image name. I kept the default name.
Once you the template has downloaded, it will appear in the 'Current Images' panel on the right hand side of the screen. Double-clicking on that will open a window. After closing the welcome message window, the windew will look like this:
Clicking anywhere on the screen will cause a menu to pop up on the screen, this menu is called the "World Menu". The World Menu contains a list of core tools like the System Browser, Playground, package manager etc.
Right clicking anywhere on the screen bringn up a contextual menu that offers different sets of actions depending on where the mouse is pointing.
Meta clicking (Shift-Option click) on Mac (Shift-control click) on Windows brings up handles that allow you to perform operations on items in your window. These are shown as little icons that you can click on. When you hover over them you can see their name.
Playing in the Playground
Entering the following command and running it with Command-D will open an interactive Pharo Tutorial that will teach you the basics of Pharo.
Here is the linkto some of the notes I took when following the Smalltalk basics tutorial.
The Transcript is an object that is used for logging messages, like a system console. You can access it by clicking anywhere on the World, selecting "Tools" from the World Menu and then selecting "Transcript" from that.
It's can be helpful to open your Playground and Transcript, then resize the windows so that they are both visible.
To print a message to the Transcript, you can run Command-P after writing and selecting the following command:
Transcript show: 'Hello World!'; cr.
You can run an expression by selecting it and using the Command-D shortcut. This will send the message to your object, but won't show the result anywhere because the Playground doesn't know what to do with it.
The print it command is similar to the do it command in that it evaluates the expression you have selected and run (this time with Command-P). The difference is that it prints the result of the expression besides the expression, and also to a Transcript object.
The inspect it comman allows you to browse and interact with any object in the system (Command-I). The title of the inspector tells you what class your object is an instance of. The top panel in the inspector lets you see the instance variables of an object as well as their values. You can use the bottom panel in the inspector to write messages and send expressions to the object.