Monthly Archives: February 2014

Bit fiddling in Pharo

Here is an interesting mails about BitSet. It is a bit (hahaha) covered in the chapter on little number of

Hi Pablo,

can you be more specific why you need a BitSet class other than convinience? What do you
want to do?

Note that for bit handling in Smalltalk you can easily just send messages to integers
or large integers:

Access bits:    12 bitAt: 1              -> 0
Modify bits:    12 bitAt: 1 put: 1       -> 13
Print binary:   12 printStringBase: 2    -> ‘1100’
Print hex:      12 printStringBase: 16    -> ‘C’
Large number:   67677557657 printStringBase: 2  ->  ‘111111000001111001011001001110011001’

There are also #bitAnd:, #bitOr:, #bitXor: messages:

12 bitOr: 1  -> 13
12 bitAnd: 8 -> 8

and you can use the abbreviations known from C world:

12 | 1    -> 13
12 & 1    -> 0

If you want to see the bit representation just print as a string with base 2:

12 | 2 printStringBase: 2  ->  ‘1110’

So for octal use:

12 | 2 printStringBase: 8  -> ’16’

If you disklike to stay in decimal system you should be aware that in
Smalltalk you can easily write a number in different bases directly
using the “BASE, followed by r followed by number” representation.

So you can for example write:

as  2r1100
as 16rC
as 10r12 (decimal again)
as 8r14 (octal)
or any other base that you like directly

With this you can also easily manipulate bits while writing in bit representation:

2r0001 bitOr: 2r0101  -> 5
same as:  2r0001 | 2r0101       -> 5

when you need the result again as bits:

(2r0001 | 2r0101) printStringBase: 2  ->  ‘101’

Many other convinience methods are there like:
12 hex                      -> ’16rC’
12 printStringHex           -> ‘C’
$A hex                      -> ’16r41′
$A printStringHex           -> ’41’

Feel free to mix all that

(16rFF00 | 2r00001) hex  ->  ’16rFF01′

Try to get used to these methods and you will have fun with bits
in Pharo Smalltalk easily.

If you need something more tell us, a BitSet class implementation
could be easily written using the above as a base.



New Components for Seaside Bootstrap

Torsten Bergmann announced two weeks ago two new components for Seaside Bootstrap

In case you missed it: Bootstrap for Seaside has two new components:

For the full demo visit:
Here is the old announce of the system made by Torsten


there are various frameworks out there helping you to ease common tasks in web development.
One of them is Bootstrap ( that is used more and more to easily style
web sites and web applications.

We had wrappers for Bootstrap supporting Seaside in the past already:
– the TwitterBootstrap project on SS3 from the Seaside team
– the TBootstrap project from Gaston Dall Oglio

Unfortunately these projects are not up to date with the latest Bootstrap version,
not covered by tests, had no docu or examples, no CI, …

To provide better support for Bootstrap and Seaside3 development I created a fresh project
called “Bootstrap for Seaside” (or “Bootstrap” for short).

This new project is
– nearly feature complete regarding components (Nav, Navbar, Jumbotron, Buttons, Alarms, Layouts, …)
– uses the latest Bootstrap libraries (
– covered by more than 160 tests
– completed with an example browser that shows Bootstrap components and according Smalltalk code
– available at STHub (!/~TorstenBergmann/Bootstrap)
– documented (see mentioned project website on STHub) with docu support for PharoOnlineHelp and catalog
– controlled by CI (
– easily loadable using config browser in Pharo 2.0

Attached are some screenshots from the project itself.

More details can be found in the more docu at the project site on SmalltalkHub. Just scroll down at the
info page provided there.

You can easily load it in a fresh Pharo 2.0 as “Bootstrap” from the config browser. It loads Seaside3
as a dependency. After loading evaluate

ZnZincServerAdaptor startOn: 8080

to start the webserver and go to http://localhost:8080/bootstrap to browse the samples.

Feel free to use it for your next Pharo/Seaside/Bootstrap based web project and thanks in advance
for any contribution you may give to the project in the future.



TaskIt: a Task Frameworks

Santiago Bragagnolo designed a task frameworks. Expressing and managing concurrent computations is indeed a concern of importance to develop applications that scale. A web application may want to use different processes for each of its incoming requests. Or maybe it wants to use a “thread pool” in some cases. In other case, our desktop application may want to send computations to a worker to not block the UI thread.

TaskIT is a library that eases the usage of processes in Pharo. It provides abstractions to schedule and/or parallelize of the execution of pieces of code. In this chapter we will explore these abstractions, guided by examples and code snippets.

With Guillermo Polito they are writing a nice chapter on a frameworks to manage tasks in Pharo.



Thierry Goubier announced a new version of the  GitFileTree. Here is his announce. It is interesting to have people trying to use git with Pharo. Now we will have to propose an engineered solution that hides the complexity of the command-line juggling to our end-user.

I’m announcing a GitFileTree for Pharo3.0 version with full support for working from github (and probably all other git remote repositories such as bitbucket) without touching any git command line, for Linux and Mac at least (and Windows as soon as someone on windows will write the two or three lines necessary to use the OSWindows extension).

In short, give gitfiletree: a full url to a github project and a few other parameters, and it will do:

  • clone the repo from githubset it up as you asked for (branch and all)
  • create the right local MC repository

and load whatever you want from a configuration or a Gofer script.

Example :
MCFileTreeGitRepository fromZnUrl: (ZnUrl fromString: ‘gitfiletree://’ ).

Creates a MC repository on a git clone of,

on branch pharo3.0
stored in a directory named filetree under the Pharo working directory,
and pointing to the repository/ subdirectory where the filetree packages are kept.

It is possible to add a readOnly parameter to the url: in this case, the git clone is done with a depth of 1 and the repository disable pull and push.

For configurations of a project on github, it becomes possible to ensure a load of ConfigurationOfGitFileTree and then use a gitfiletree url to clone, setup the local repository and load the package, as is done in the latest ConfigurationOfAltBrowser.

For newcomers to git and Pharo interested in github, the process is simply:

  • create a project in github- don’t forget to register your ssh key (see the doc at github)
  • install the configuratonOfGitFileTree in Pharo, either with the ConfigurationBrowser or with:

Gofer new
url: ‘’;
configurationOf: ‘GitFileTree’;

  •  Add a Git remote repository location: the ssh clone URL from github
  • you can then start to create packages and save them into that repository. To propagate changes to github, open the repository and select Push. To update your local copy from github, open the repository and select Pull. If you are a git regular user, you can keep your usual workflow with git and gitfiletree will keep up with you.



CJSolver for CodeJam

Luc Fabresse just published a little package to help loading code contest from CodeJam.  Here is his announce.

Hi all,

As a teacher, I always try to find new programming exercices for students.
I discovered the CodeJam coding contest that provides problems and their data sets. We can also upload a solution on the website and it tells us if it is right or wrong.

Example of problem:

So, I did a little framework (CJSolver) to make it easier to read data sets and write result files.

More info here:

The code is on Smalltalkhub but since I also wanted to commit data set files and correct results, I also have a github repo here:

You can checkout the code, test it, implement solution to other problems or *optimize* already implemented solutions (I did the simplest version ;-)) and sometimes it is slow on big data sets.

have fun,

Tagged ,

Miniimage becoming true

Starting in 2002 or 2003 Pavel Krivanek and Stephane Ducasse started to have the vision of a minimal core that could be bootstrapped.
And Pavel worked over the years on the the “MiniImage”: a small Squeak then Pharo image that slowly shrunk. We slowly made dependencies explicitly and we are getting there. In parallel Guillermo Polito worked on a bootstrap from files. Guillermo can boostrap several kernels: CandleLight (80k), miniimage (around 200k). So we arrive to an really exciting moment!
Soon we will have a minimal kernel and be able to reload the complete system each time we push a fix.
Now the other challenge is how can we reload package to create a nice Pharo distribution. And Pavel is getting there. Here are two posts where Pavel Krivanek announced a 5MB kernel image for Pharo3:
I finally successfully created a script that is able to unload everything *by Monticello* except kernel packages, network, Monticello, Gofer and related packages.

The script is run as an automatic build process after every update,
the build server is here.

The size of resultant image is about 6.6 MB, 4.9 MB without MC data and caches. The image has no Undeclared nor obsolete classes and is really able to load something using Gofer.

The second one is the following:

I transformed the Morphic reloading script into a configuration and it works 🙂

Jenkins job:

Configuration repository:!/~Pharo/SystemConfigurations/

it’s named ConfigurationOfIDE.

Small note, I must parse versions list from a string because the method has too many literals if I try to use standard form used in normal configurations generated by the tools.

— Pavel


A peak at the future windowing

From time to time things are happening in Pharo that are not mentioned in the mailing-lists because there are experiences or just work in progress. We want to share one with you.

Ronie Salgado and Igor Stasenko wanted to accelerate the Cairo, openGL and other renderings.

So they started to create at the image level a way to access all the OS elements for windowings (events and properties) and as such shortcut the old VM code. They can now create windows on X11 and get all the events. They convert the OS events into Morphic events and everything works. This is interesting because it is probably the architecture of future Pharo. We will need to define similar primitives to other platforms and to define some new Events and logic at the image level. They designed a OSWindow abstraction and new event hierarchies.

And this is really exciting.

Here is one of the mails that they sent internally:

Today we worked on translating most basic events like mouse and keyboard.

Things vent quite smooth and we managed to make most of things working:

– mouse movement

– mouse buttons

– and even mouse wheel events without much hassle

Keyboard was also relatively easy to convert, up to the point that most of basic keys work including control ones. But it is not quite complete..

As a bonus, now we can receive separate events generated from pressing keys like shitf/ctrl etc… the only thing which makes me sad is that morphic events tend to obscure and obfuscate things…

We do 2-step translation:

X11 event hierarchy -> OSEvent hierarchy -> Morphic event hierarchy

The OSEvent will be our new platform-neutral evens, which is similar what we did with Stef for SystemEvent(s), except that it doesn’t relies on VM and tries to preserve all of the information which original event(s) has.

Like that there is always a way to deal with special cases if extra information is needed.

Morphic events is a big mess, and translation is lossy, but we just want to make things work more or less fine, and deal with problems step by step.

What is fun, that all this event handling stuff written purely with smalltalk, with FFI and system quite responsive and there is no noticeable lags/whatever.




Scripting charts with GraphEt

GraphET is a great library to draw charts, graphs and histograms. It is built on top of Roassal, to let the user enjoy all the different interaction with the visualization. It is developed by Daniel Aviv Notario.

GraphET may be loaded using the following incantation:

Gofer new smalltalkhubUser: ‘ObjectProfile’
project: ‘GraphET’;
package: ‘ConfigurationOfGraphET’;
(Smalltalk at: #ConfigurationOfGraphET) loadDevelopment

Tagged , ,