Monday 20 April 2015

Learn Smalltalk With Pharo

Longtime readers of Bitwise will know that I am wildly enthusiastic about Smalltalk. This is quite simply one of the most influential programming languages ever created. But, even so, while other languages and IDEs have ruthlessly ripped off Smalltalk’s best ideas, the language itself has dwindled to such an extent that hardly any modern programmers have even used it. Which is a gigantic shame.

Pharo - bringing Smalltalk up to date
Pharo might change that. Built as a fork of the open-source Squeak Smalltalk, Pharo’s stated aim is “to deliver a clean, robust, innovative, free open-source Smalltalk inspired environment. We want to provide a stable and small core system, excellent development tools, maintained libraries and releases, and to continue making Pharo an attractive platform to build and deploy mission critical Smalltalk applications.”

I have only just started using Pharo so I can’t yet comment on how well it meets these aims. What I can say is that at first sight it seems to be a nice Smalltalk variant with a good programming environment. The system is quite small (about 120Mb to download), cross-platform, and free. It has an active community and there are some interesting ‘side projects’ such as some robotic-control systems. There is also excellent documentation to help you learn Pharo programming, notably the two free eBooks Pharo By Example and Deep Into Pharo. Unfortunately the revision of the documentation is some way behind the development of the software itself. So, for example, you will find numerous differences between the tools of the current Pharo IDE and the tools described in the books. At a trivial level, this involves things such as renamed windows (the dull-sounding ‘Workspace’ has now been renamed as the more fun-sounding ‘Playground’).

A more serious deficiency of the documentation is that the demo programs described in Pharo By Example are no longer supplied as standard with the software. You can easily fix this, however, by downloading the demo projects from an online repository. This is how to do that.

Left-click in Pharo to pop up a menu and select Playground. In the Playground window enter this code:

Gofer it 
     url: 'http://smalltalkhub.com/mc/PharoExtras/MorphExamplesAndDemos/main';
     package: 'MorphExamplesAndDemos';
     load.

Select all the code, right-mouse-click and choose Do it. This will install the demo code. Now you can run the demos. For example, to run the ‘bouncing atoms demo, enter this into the Playground, then select it, right-click and Do it.

BouncingAtomsMorph new openInWorld.

Pharo looks like a lot of fun. I’ll have more to say later…