Pharo Introduction

While working on a Project Euler problem, I noticed that there weren't too many good introductions to Pharo (one of the few is here, working through the MOOC just to test Pharo is a big investment). If one is familiar with other Smalltalks, it is very straight-forward to download, install, and run from https://pharo.org/, however for someone new it isn't easy.

If someone wants to use the code from Agile Artificial Intelligence, or reading commonly published Smalltalk code, they should:

  1. Download and install from https://pharo.org/download. For experimentation, running it from a documents directory should suffice
  2. Running something like ./pharo Pharo.image should suffice
  3. Most code is created in the browser, Right-click on the background and choose the first option, System Browser. An example is:

     _____________________________________________________________________________
    |_____________________________________________________________________________|
    |Package_name|PENode                |-- all -- |testRead3DirectionalFromLatice|
    |ProjEuler   |PENodeTest            |tests     |testRead4DirectionalFromLatice|
    |            |PESmallSumPathVisitor |          |testSmallestSumPathPerformance|
    |            |______________________|          |                              |
    |____________|Hier|_|Class|_|Comment|__________|______________________________|
    |testSmallestSumPathPerformance                                               |
    |       | node |                                                              |
    |       self timeLimit: 100 milliSeconds.                                     |
    |       node := PENode                                                        |
    |               readFromLatice:                                               |
    |                      '4445,2697,5115,718,2209,2212,654,4348,3079,6821       |
     -----------------------------------------------------------------------------

  4. When code lists a method as something like: PENodeTest>>testSmallestSumPathPerformance, the class is before the greater-than signs (PENodeTest), and the method name is after them (testSmallestSumPathPerformance). This applies to instance methods (to be send to an instance of the class).
  5. If it is a class method, then clicking on the Class button in the center of the browser will toggle to the class methods. It is generally listed as PENodeTest(class)>>New:. The colon indicates that an argument is expected.
  6. Pharo can store code in repositories, fileouts, etc; however the simplest approach is to simply save the image by clicking on the background and choosing Save. When Pharo is started again with this image, everything (including the code) will be right where it was last saved.

Posted by John Borden at 27 August 2018, 12:20 am link