Contributing to Pharo By Example

Background

When I was learning Pharo Smalltalk, I found the Pharo By Example book a great help.  It was well written and available at a good price ;). However as Pharo advances at great speed and the original authors are busy documenting and implementing new and advanced features – this learning resource has become out of date with some of its examples.  So I thought I’d contribute back to help update it to the latest release.

For those that came in late, Smalltalk is a programming development environment that has been around since the 1970s.  Derived from the original Smalltalk-80,  Apple Computer released Squeak around 1996 as a platform for developing educational software.  In 2006 Squeak was released open source.  This was later forked to focus on business software development and released in 2009 as Pharo 1.0.  At this time the 2007 book Squeak By Example was updated and published as Pharo By Example.  Since then there have been several revisions of Pharo, with the most recent release in April 2012 of Pharo 1.4.

Pharo has a goal of refurbishing a lot of the inherited infrastructure, so it is uncertain how closely the book aligns with the current release.  Now I could just mark changes and submit for someone else to integrate these into the document, but that is really only half the job and creating work for someone else.  Since the LaTeX source of the PBE1 book has open access on github, I’ll decided I would have a crack editing the source direct – except I haven’t used LaTeX or git before.  So here I am documenting my setup for two reasons:  One is that some adept might point out improvements in my process; the other is to see if I can spark an interest in anyone else to come along for the ride.  Now lets see what I’m getting into…

Getting started

The PBE1 book is written in LaTeX , the source of which is managed on github.  This is my first experience with both LaTeX and git, so I’ll be happy to update this post with any hints from readers.  The README describes an overview of the contribution process.  What I document here is my particular circumstance of doing this with Windows 7 – as much for my own reference as trying to draw in an army of willing helpers.

The README specifies use of TeX Live, for which I first used the Windows installer.  Serge Stinckwich suggested starting with help.github.com which I found useful create an account and install Git For Windows as instructed here – and also play with some tutorials.  However while I successfully cloned the PBE1 repository to my local machine, when I went to do my first build to reproduce the existing book prior to any changes, the lack of make on the Windows platform became problematic.

To get make, I ended up choosing Cygwin.  However it seemed awkward to get the make from inside Cygwin to play well with TeX Live outside its root in Windows.  Since Git For Windows was only a text shell anyway, I chose to discard the Windows versions of git and TeX Live and use these both from inside Cygwin. So my Cygwin install (currently version 1.7.14-2) went like this:

  • Logged in as admin user (since my daily use is under a non-admin account)
  • Download and run setup.exe
  • Install from Internet
  • All Users ; Root Directory=C:\Apps\Cygwin\root
  • Local Package Directory=C:\Apps\Cygwin\installer
  • Direct Connection & Download Site – ftp://mirror.aarnet.edu.au
  • Selecting packages…
    • searched “make” and selected “Devel > make”
    • searched for “git” and selected “Devel > git,  git-completion” (I did wonder about git-gui & gitk but wasn’t sure about about the operation of a gui from Cygwin and what dependencies would be loaded)
    • searched “texlive” and selected every “Publishing > texlive” package that did not have a foreign language in it.  I did this by changing Publishing from “Default” to  “Install” then searching on “live-collection-do” and “live-collection-lan” and deselecting all but English packages.
    • searched “ssh” and selected “Net > openssh”
    • search “vim” and selected “Editors > vim” (since I know ‘vi’ from long ago, but you might like something else if you browse the whole list of Editors – actually ‘lyx’ looks interesting to try later so I selected that also)
    • searched “time” and selected “Utils > time”
  • Ticked “select required packages to resolve dependencies.”

The install took quite a while (upwards of 20 minutes with most of that being TexLive) after which I switched back to my non-admin user.

Github setup and practice

After running Start > Programs > Cygwin > Cygwin Terminal, I followed the instructions for linux-set-up-git jumping in at “Set Up SSH Keys.”  I then created directory ~/dev and changed into it before doing all parts of Create a Repo for Hello-World.  For this learning experience I unticked “Initialize this repository with a README”.  I followed up doing the fork-a-repo tutorial to test creating a fork of the “spoon-knife” project.

So now it was time to get my own local fork of PBE1 to work on.  Branch for working on Pharo By Example 1.4 Update Serge Stinckwich had already created a 1.4 branch seen on the right and here.  This is where I first thought I needed to fork from, so I first selected the branch to 1.4 at (1) below and then created the fork from that by clicking at (2)….

PBE Forking Branch Image

…but actually it doesn’t seem to operate that way.  Doing the following clone ended up with my  repository having both master and 1.4 branches.

$ cd ~/dev
$ git clone git [at] github [dot] com:bencoman/PharoByExample-english.git
(which downloads about 70MB)
$ cd PharoByExample-english
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/pharo1.4

So it seems that I only select a particular branch for editing on my local machine.  After reading ‘man git-remote’ and ‘man git-branch’ from the Cygwin shell,  I continue with the tutorial…

$ git remote add upstream git://github.com/SquareBracketAssociates/PharoByExample-english.git
$ git fetch upstream
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/pharo1.4
remotes/upstream/master
remotes/upstream/pharo1.4

So at this point I’m not sure if I should checkout remotes/upstream/pharo1.4 or just pharo1.4, or create my own pharo1.4 branch.  However I try this, which you can see moves the current-marker from master to pharo1.4…
$ git branch pharo1.4
$ git checkout pharo1.4
Switched to branch ‘pharo1.4′
$ git branch -a
master
* pharo1.4
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/pharo1.4
remotes/upstream/master
remotes/upstream/pharo1.4

Now at this stage, the upstream/pharo1.4 changes have have not been merged into my pharo1.4.  For example, I know that Serge Stinckwich has updated worldMenu.png in the upstream/pharo 1.4 branch – but at the moment if I browse Windows Explorer to “C:\Apps\Cygwin\root\home\Ben\dev\PharoByExample-english\QuickTour\figures” I see worldMenu.png looks like “Old World Menu” below.

To get the New World Menu above, I executed the following line the reopen worldMenu.png from Windows Explorer.
$ git merge upstream/pharo1.4
Removing QuickTour/figures/SqueakMap.png
Merge made by the ‘recursive’ strategy.
QuickTour/figures/SqueakMap.png                   |  Bin 23867 -> 0 bytes
QuickTour/figures/worldMenu.png                   |  Bin 36937 -> 27729 bytes
QuickTour/figures/yellowButtonMenuOnWorkspace.png |  Bin 36518 -> 38602 bytes
pbe1-examples.txt                                 |    2 +-
4 files changed, 1 insertions(+), 1 deletions(-)
delete mode 100644 QuickTour/figures/SqueakMap.png

Producing the book

Before starting making any changes of my own and potentially break something in the build I thought should confirm I could produce the existing book.  This is actually its pretty damn simple.  I just tried the obvious and this worked….
$ pwd
~/dev/PharoByExample-english
$ make
[lots of stuff]
Output written on PBE1.pdf (338 pages, 13825502 bytes).
Transcript written on PBE1.log.
real    0m45.536s

So now browsing Windows Explorer to…
C:\Apps\Cygwin\root\home\Ben\dev\PharoByExample-english
and opening PBE1.pdf to page 6 shows the updated WorldMenu.

Making a change, commitment, collaboration

(Note this section will change slightly when hopefully my addition of file gitDummyPlay.txt is accepted into the upstream/pharo1.4.)

File gitDummyPlay.txt file in ~/dev/PharoByExample-english is proposed for new contributors to practice pushing changes back to github.  If it does not currently exist, do this…
$ touch githubDummyPlay.txt
$ git add githubDummyPlay.txt
$ git commit -m ‘Added dummy file to experiement with while learning git’
$ git push

Now edit the file ~/dev/PharoByExample-english/githubDummyPlay.txt. Compare this to the same file currently on github.com/{your username} under PharoByExample-english/tree/pharo1.4.   Now do the following and compare both again…
$ git commit -m ‘Test pushing changes to github’
$ git push

This produces the following network graph, which will disapper when the changes are merged into the mainline.

Now the idea would be to issue a Pull Request to the upstream project, but I am waiting on some feedback.

I wonder if it would be useful to take a git branch for each chapter.  This would be similar to one git usage of having a branch for each new feature – perhaps allow more independent updates by multiple editors.

Conclusion

So you can see it is not too difficult to participate at the level of helping out with documentation.  Particularly if you are new to Pharo, you may pick up gaps in the doucmentation that are missed by others more familiar with it, so your input here can be valuable.  Now that I have this process reasonably sorted out in my mind, I just need to learn LaTeX better.

Posted in Pharo | Leave a comment

Windows 7 Pharo DBXTalk – “my hack”

Having just got ConfigurationOfODBC working from Pharo Smalltalk, I had some trouble determining exactly how to get at the individual data items.  So I thought I’d check out DBXTalk for comparison.  DBXTalk is a lot more comprehensive solution leaveraging OpenDBX which includes its own ODBC interface along with several other backends.  However all the ODBC connection examples I saw were for database servers with connection strings that were not of the “DSN” form that I think is required for Microsoft Access – so I ended up returning to ConfigurationOfODBC and resolving the issue above.

Yet I was most of the way through getting DBXTalk working, so I record my experience here for posterity.  It is the “hack” version since to resolve library dependencies I simply copied everything next to virtual machine executable.  I’ll look into resolving these more correctly later.  So I…

  1. Created a new folder Pharo-1.3-13315-cog2522-dbxtalk and into it:
    a. Extracted the “Contents” folder only from Pharo-1.3-13315-OneClick.zip
    b. Extracted all files from cogwin_r2522.zip
    c. Updated croquet.ini file with: ImageFile=Contents\Resources\pharo.image
    .
  2. Ran croquet.exe and then:
    World Menu > Monticello Browser.
    .
  3. From the Monticello Browser opened:

    http://www.squeaksource.com/MetacelloRepository

    and loaded:
    ConfigurationOfOpenDBXDriver-GuillermoPolito.13
    .
    then from a Workspace executed:
    (ConfigurationOfOpenDBXDriver project version: #’stable’) load.
    .

  4. From a Workspace found the required OpenDBX library to be 1.4.4 by executing:
    OpenDBX currentOpenDBXVersion
    .
  5. Extracted all nine files from http://linuxnetworks.de/opendbx/download/opendbx-1.4.4_win32.zip into folder Pharo-1.3-13315-cog2522-dbxtalk
    .
  6. From a DBXTalk developer I asked which version of PostgreSQL to try, and the prompt response came back as 8.3. I installed the current version at this time (postgresql-8.3.17-1-windows.exe) choosing all the defaults.
    .
  7. Now possibly step 3 is made redundant by the following, but this post is a record of what I actually did.
    .
    In Monticello Browser I opened repository:
    http://www.squeaksource.com/DBXTalk
    .
    then loaded:
    ConfigurationOfGlorpDBX-GuillermoPolito.70
    .
    then in a Workspace I executed:
    (ConfigurationOfGlorpDBX project version: #’stable’) load.
    .
    which left the following message in Transcript 

    IMPORTANT FOR GLORP AND OpenDBXDriver DRIVER
    In order to run sucessfully Glorp tests you should need to change the database connection settings used by them. To do this, change the following methods:
    -GlorpDatabaseLoginResource>>defaultPostgreSQLInternetLogin
    -GlorpDatabaseLoginResource>>defaultPostgreSQLLocalLogin
    -GlorpDatabaseLoginResource>>defaultPostgreSQLLoginForGlorpStore 

    After doing this all Glorps tests must be green.

    Evaluated -> GlorpOpenDBXDriver >> postLoadGlorpDriverDBXTalkPharo

    …finished 2.4

    Looking at GlorpDatabaseLoginResource>>defaultPostgreSQLLocalLogin shows:

    defaultPostgreSQLLocalLogin
    “To set the default database login to PostgreSQL, execute the following statement.”
    “self defaultPostgreSQLLocalLogin.” 

    ^DefaultLogin := (Login new)
    database: PostgreSQLPlatform new;
    username: ‘sodbxtest’;
    password: ‘sodbxtest’;
    connectString: ’127.0.0.1:5432_sodbxtest’.

    Now rather than changing these connection settings, for a first attempt I thought it might go easier the other way making the database match the tests, so…

  8. From the Windows Start Menu ran pgAdminIII.
    .
  9. From pgAdminIII created a new user sodbxtest:
    Servers > PostgreSQL 8.3 (localhost:5432) >Login Roles > New Login Role.
    with the widest privileges possible.
    .
  10. From pgAdminIII created database sodbxtest:
    Servers > PostgreSQL 8.3 (localhost:5432) > Databases >> New Database
    Name=sodbxtest
    Owner=sodbxtest
    Privileges=ALL, Role Public
    .
  11. Then for later comparison I checked that the number of tables in this new database is zero: Servers > PostgreSQL 8.3 (localhost:5432) > Databases > sodbxtest > schemas > public > Tables
    .
  12. Now “the hack” (since I was in a rush and would have needed to log out and back in as Admin to adjust the search paths.)
    .
    In Pharo I ran some Glorp Tests and got an error “could not find libpq.dll.”  After finding this file in folder PostgresSQL/8.3/libs, rather than properly resolving the lookup, the quick fix was copying everything from that folder next to the virtual machine in folder Pharo-1.3-13315-cog2522-dbxtalk.  A subsequent error “could not find ssleay32.dll” was fixed similarly by copying the contents of folder PostgresSQL/8.3/bin next to the virtual machine.
    .
  13. Then in Pharo from World Menu > Test Runner all 823 tests for GlorpTests-Models, GlorpTests-Database & GlorpTest are successful.
    .
    In addition, if I recheck the number of tables noted in Step 14 and find there are now 75 tables – full of data.
    .
    Excluded from this are GlorpTests-DatabaseTypes, GlorpTests-Extras, GlorpOpenDBXDriverTests since they seem to cycle through testing databases  that I don’t have installed – in particular OCI.dll for Oracle.

One small annoyance is that once a “missing OCI.dll” error occurs, it continues to occur even when the previously successful tests are rerun.  This remains until reset by: GlorpDatabaseLoginResource defaultPostgreSQLLocalLogin.

So this is a good result and I’ll be glad to further DBXTalk later on.  However for now, for my current requirements (a one-time one-way import from an mdb file into Pharo) I think that ConfigurationOfODBC is more suitable.

Posted in Uncategorized | Leave a comment

Pharo 1.3 ODBC working on Windows 7

Wow. Eight months since my last post.  It is now apparent the impact over that time of my 60-70 hour work week onsite at a mine expansion.

This post summarises the result of discussion on the pharo-project mailling list where I sought assistance getting ODBC working on Pharo 1.3.  Credit goes to Mariano Peck and Eliot Mirranda for assistance troubleshooting, providing a slightly older configuration that worked, and then the latest VM build.  I am happy to report that ODBC appears to be working with the Pharo 1.3 image on MS Windows 7 using CogVM version 2522.

The purpose of this is that I have a UML design an application has stored in a Microsoft Access database.  I want to use Pharo to implement that design directly into Smalltalk classes since I could not find a common export/import format.  ConfigurationOfODBC looked promising so I followed instructions at http://www.pharocasts.com/2010/12/access-database-through-odbc.html, except that rather than using SQLLite I started with a blank Microsoft Access database.  This worked well on Pharo 1.2.1 but not out of the box Pharo 1.3.

Here is the method to get ODBC working and tested with Pharo 1.3.

1. With this  TestMDB.mdb in a local folder, set up the ODBC data source using
Start > Control Panel > Administrative Tools > Data Sources (ODBC)

ODBC Data Source Administrator

Clicked <Add…> and choose the Microsoft Access Driver

and <Select…> the TestMDB.mdb file configured as Data Source Name “TestMDB”

ODBC Microsoft Access Setup

ODBC Microsoft Access Setup

which gives…

2. Unzip Pharo-1.3-13315-OneClick.zip and then delete all files from
folder “Pharo-1.3-13315-OneClick.app”, leaving just the Contents folder.

3. Extract the files from VM.r2522/cogwin.zip into folder “Pharo-1.3-13315-OneClick.app”

4. Copy the “ImageFile=Contents\Resources\pharo.image” line from the old pharo.ini into Croquet.ini and then run Croquet.exe.

5. Load the ODBC package from within Pharo.  I had some trouble accessing Squeaksource, but I found success using a mirror (you might skip the first two lines…)

Gofer new url: ‘http://dsal.cl/squeaksource/MonticelloRedirect’; package: ‘MontiRedirect’; load.

MRManager redirectFrom: ‘http://www.squeaksource.com/’ to: ‘http://dsal.cl/squeaksource/’.

Gofer new
squeaksource: ‘ODBC’;
package: ‘ConfigurationOfODBC’; load.
(Smalltalk at: #ConfigurationOfODBC) load.

6. And then finally, the successful test of ODBC…

connection := ODBCConnection dsn: ‘TestMDB’ user: ” password: ”.
table := (connection query: ‘select * from user;’) execute asTable.
connection close.
table inspect.

Inspector on ODBCResultTable

Inspector on ODBCResultTable

Thats all.  Now time to explore that UML design….

Here are some links to the full discussion and a backup cache of the files

Update 24 Dec 2011…

7. Just recording an example for the next part of actually processing the database. Following on from the previous step…

( row := table first ) inspect.
( name := row at: #name ) inspect.
( age := row at: #age ) inspect.
( allNames := table collect: [:each | each at: #name] ) inspect.

To go with the above example I have also uploaded a new file TestMDB – 2011-12-24.zip with a few additional rows of data.

Posted in Uncategorized | Tagged , , , | 3 Comments

mouse buttons and menus

My mouse is a Logitech Wireless Nano Mouse M305.  The default function of the mousewheel (button 3) is Zoom.  To be most useful for Smalltalk, the mousewheel function needed to be configured as Middle Button.  For Windows 7 this was done via
[Start > Control Panel > Mouse > SetPoint Settings] as pictured below. Continue reading

Posted in System | Leave a comment

performance testing spreadsheet

For anyone anyone so inclined to replicate the results, or update the results for subsequent releases of the Smalltalk systems, the linked spreadsheet Squeak Graphics Framework Performance Testing.ODF was used to generate the graphs in these articles:

You are able to attach graphs to your comments in those articles.

Posted in Uncategorized | Leave a comment

workspace referencing to existing morphs

Flipping through Andy Burnett’s blog Learning Smalltalk he discusses in Getting a handle on objects from the Flaps how to get programmatic reference to morphs that have been created by direct manipulation – for example by being dragged on-screen from the tool flaps.  The “textual reference to dropped morph in  Workspaces” looked like an interesting feature that would likely to be quite useful in the future – so best to find out how it works right now… Continue reading

Posted in Debugging | Leave a comment

morphic flavour performance

Previously in morphic performance I benchmarked different actions in Squeak Smalltalk for creating, hiding, showing and deleting morphs in Squeak.

On [squeak-dev] Herbert Konig wrote: “Juan Vuletich has done a great job at simplifying cleaning and speeding up his version of Morphic in Cuis.”

So lets check that out.  We should compare some other flavours of Smalltalk.  The code used to generated the graph data is the same  “V1″ code as used for morphic performance. The software versions tested here are:

Posted in Morphic | Tagged , , , , | 14 Comments

wordpress shared hosting performance

It’s the second week of running WordPress, so I’ve been trialing a few plugins…  Suddenly, about half the time I do anything I get “Apologies, but the page you requested could not be found.” The page loads fine the second time with a simple page refresh.  The site is brand new, so there shouldn’t be any traffic.  So what gives? Continue reading

Posted in Admin | Tagged , , , , , , | 8 Comments

morphic performance

For my postgrad dissertation I’ve decided to program an engineering design tool.  I’d like to focus more on the application domain rather than the programming minutiae.  Based purely on gut feel from a long-held but unproven belief, I’ve selected Smalltalk as the development platform.  Specifically I’ve selected Squeak with its Morphic graphics system, which seems to have a lot of useful “direct manipulation” functionality.  Now some validation of this choice would be useful and one place to start is performance testing.  Continue reading

Posted in Morphic | Tagged , | 3 Comments