Planet Smalltalk

March 19, 2018

Pharo Weekly - New Files in Pharo – Migration Guide, How To’s and examples

Hi all,
I’ve put some minutes summarizing the new APIs provided by the combination of the new File implementation and the Zn encoders. They all basically follow the decorator pattern to stack different responsibilities such as buffering, encoding, line ending conversions.
Please, do not hesitate to give your feedback.
1. Basic Files
By default files are binary. Not buffered.
(File named: ‘name’) readStream.
(File named: ‘name’) readStreamDo: [ :stream | … ].
(File named: ‘name’) writeStream.
(File named: ‘name’) writeStreamDo: [ :stream | … ].
2. Encoding
To add encoding, wrap a stream with a corresponding ZnCharacterRead/WriteStream.
utf8Encoded := ZnCharacterReadStream on: aBinaryStream encoding: ‘utf8’.
utf16Encoded := ZnCharacterReadStream on: aBinaryStream encoding: ‘utf16’.
utf8Encoded := ZnCharacterWriteStream on: aBinaryStream encoding: ‘utf8’.
utf16Encoded := ZnCharacterWriteStream on: aBinaryStream encoding: ‘utf16’.
3. Buffering
To add buffering, wrap a stream with a corresponding ZnBufferedRead/WriteStream.
bufferedReadStream := ZnBufferedReadStream on: aStream.
bufferedWriteStream := ZnBufferedWriteStream on: aStream.
It is in general better to buffer the reading on the binary file and apply the encoding on the buffer in memory than the other way around. See
[file := Smalltalk sourcesFile fullName.
(File named: file) readStreamDo: [ :binaryFile |
(ZnCharacterReadStream on: (ZnBufferedReadStream on: binaryFile) encoding: ‘utf8’) upToEnd
]] timeToRun. “0:00:00:09.288”
[file := Smalltalk sourcesFile fullName.
(File named: file) readStreamDo: [ :binaryFile |
(ZnBufferedReadStream on: (ZnCharacterReadStream on: binaryFile encoding: ‘utf8’)) upToEnd
]] timeToRun. “0:00:00:14.189”
4. File System
By default, file system files are buffered and utf8 encoded to keep backwards compatibility.
‘name’ asFileReference readStreamDo: [ :bufferedUtf8Stream | … ].
‘name’ asFileReference writeStreamDo: [ :bufferedUtf8Stream | … ].
FileStream also provides access to plain binary files using the #binaryRead/WriteStream messages. Binary streams are buffered by default also.
‘name’ asFileReference binaryReadStreamDo: [ :bufferedBinaryStream | … ].
‘name’ asFileReference binaryWriteStreamDo: [ :bufferedBinaryStream | … ].
If you want a file with another encoding (to come in the PR, you can specify it while obtaining the stream:
‘name’ asFileReference
    readStreamEncoded: ‘utf16’
    do: [ :bufferedUtf16Stream | … ].
‘name’ asFileReference
    writeStreamEncoded: ‘utf8’
    do: [ :bufferedUtf16Stream | … ].
5. Line Ending Conventions
If you want to write files following a specific line ending convention, use the ZnNewLineWriterStream.
This stream decorator will transform any line ending (cr, lf, crlf) into a defined line ending.
By default it chooses the platform line ending convention.
lineWriter := ZnNewLineWriterStream on: aStream.
If you want to choose another line ending convention you can do:
lineWriter forCr.
lineWriter forLf.
lineWriter forCrLf.
lineWriter forPlatformLineEnding.
6. About performance questions
Well, I’d say it we did it in the name of modularity. And yes, I believe that having separate responsibilities help in designing, testing and ensuring more easily the correctness of each of the parts in isolation.

I’ve done also some profiling and it does not look like we’ve lost in performance either (reading and decoding a 35MB file):
[file := Smalltalk sourcesFile fullName.
(File named: file) readStreamDo: [ :binaryFile |
(ZnCharacterReadStream on: (ZnBufferedReadStream on: binaryFile) encoding: ‘utf8’) next: binaryFile size.
]] timeToRun. “0:00:00:01.976”
[file := Smalltalk sourcesFile fullName.
(MultiByteFileStream fileNamed: file)
converter: (TextConverter newForEncoding: ‘utf8’);
] timeToRun. “0:00:00:02.147”

Pharo Weekly - Woden with Vulkan and openGL on Windows

woden_windows.png I just managed to get Woden working with Vulkan, and OpenGL on Windows. Finally, smooth movement (My tearing was Linux failure). My only complain is that it takes too long on loading a Pharo image on Windows.

Ronie Salgado

March 18, 2018

Pierce Ng - OpenSSL RIPEMD160

I've just added RIPEMD160 to the EVP interface in OpenSSL-Pharo. This post serves as a HOWTO.

OpenSSL's C interface defines RIPEMD160 thusly:

const EVP_MD *EVP_ripemd160(void);

Create LcLibCrypto>>apiEvpRIPEMD160 for it:

  ^ self ffiCall: #(EVP_MD* EVP_ripemd160 ())
    module: self library

Next, create LcEvpRIPEMD160 as a subclass of LcEvpMessageDigest:

LcEvpMessageDigest subclass: #LcEvpRIPEMD160
  instanceVariableNames: ''
  classVariableNames: ''
  package: 'OpenSSL-EVP'

  super initialize.
  handle := LcLibCrypto current apiEvpRIPEMD160.
  self errorIfNull: handle

Add class-side accessors:

LcEvpRIPEMD160 class>>blocksize
  ^ 64

LcEvpRIPEMD160 class>>hashsize
  ^ 20

And that's it! Using the test vectors from the RIPEMD160 home page and RFC 2286, the unit tests verify that we can now use RIPEMD160 for hashing and HMAC from within Pharo:

  | msg result |

  msg := ''.
  result := ByteArray readHexFrom: '9c1185a5c5e9fc54612808977ee8f548b2258d31' readStream.
  self assert: (md hashMessage: msg) equals: result

  | msg result expectedResult |

  msg := 'Hi There'.
  key := ByteArray readHexFrom: '0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b' readStream.
  expectedResult := ByteArray readHexFrom: '24cb4bd67d20fc1a5d2ed7732dcc39377f0a5668' readStream.
  result := (HMAC on: LcEvpRIPEMD160)
    key: key;
    digestMessage: msg asByteArray.
  self assert: result equals: expectedResult

March 16, 2018

Torsten Bergmann - Pharo to Anki

Using Pharo to create Anki decks that help to deliberately practice Japanese grammar by visualizing.

March 15, 2018

Nicolas Cellier - Importing Mat-file in Smalltalk

A very long time since I did not write anything here...

I've been busy, but finally found time to release a small utility in Cincom Smalltalk public store: it's a package named MatFileReader.

The package is capable of importing data from the .mat files produced by Matlab, into Visualworks. Nothing spectacular, but it may be useful for scientific applications. Usage is fairly simple, just do-it:

     (MatFileReader on: 'foobar.mat' asFilename readStream) decode.

I had developped the package around 2005, but it was messy and full of personnal dependencies. The dependencis are now reduced to the BinaryStreamRawArray and MultipleDimensionArray packages.
  • RawArray are collections holding bits of data efficiently in space - bits are translated into/from Smalltalk objects with at: and at:put: operations like a ByteArray or a WordArray.
  • BinaryStream is just a Stream wrapper with convenient messages for reading chunks of binary data, especially into RawArray.
  • MultipleDimensionArray is just a SequenceableCollection wrapper which let the single dimension raw storage be viewed with multiple dimensions. The layout is that of FORTRAN and Matlab, column-wise (first index varies first).
Also two other dependencies are the unzip from PNG readers and EphemeralValueDictionary from Glorp which have been used for reading compressed data and automatically reclaiming classes respectively (classes are created on the fly for holding Matlab struct data). When Ephemerons will be ready in Squeak, this package can provide a good test.

The package would be more useful if data were imported into some application specific classes (like Smallapack for example), but for that one just have to either subclass MatFileReader, or post-process with a tree visitor.

License is M.I.T.

When I'll have time, I'll also handle the export to mat-file, and try to port into Squeak/Pharo. Such package could be useful for Polymath (

Torsten Bergmann - Instance inspection in Pharo

The Pharo Inspector on classes now has “instances” view. I added this a a few days ago and forgot to send a message to the list so anyone knows. Looks like I should blog more about my contributions again.

Torsten Bergmann - Pharo AWS SDK with SNS support

The Pharo AWS SDK now supports Amazon Simple Notification Service (SNS)

March 14, 2018

Torsten Bergmann - Feenk work on a Diagrammer for Pharo in Bloc

The Feenk team is working on on Diagrammer in Pharo. The idea is that developers should not have to leave the IDE - not even for drawing diagrams and they give a nice graphic preview on a more elaborate control of lines and figures in this tool with some screenshots on their twitter account.

 - Preview 1
 - Preview 2
 - Preview 3

This nicely shows what is already possible in Bloc.

March 13, 2018

Cincom Smalltalk - Smalltalk Digest: March Edition

In this edition, Arden Thomas continues his DomainMaster Hidden Gems series and David Buck explains why he chose Cincom Smalltalk for his mobile app development and why garbage collection matters.

The post Smalltalk Digest: March Edition appeared first on Cincom Smalltalk.

Torsten Bergmann - Pharo-sentry v0.2.2 releases

The unofficial Pharo SDK for Sentry error tracking platform from Peter is available with a new 0.2.2. release. Now with support for breadcrumbs and basic context.

Code is here:

Stefan Marr - How to Design Collection Libraries?

Programming languages naturally come with a library of containers or collection types. They allow us to easily work with arbitrary number of elements, which is something all major languages care about. Unfortunately, it seems like there is not much writing on how to design such libraries. Even asking a few people that worked for a long time on collection libraries did not yield much of a structured approach to such a central element for our languages. The one major piece of writing we found is the Scala people describing their experience with bit rot and how they redesigned their collection implementation to avoid it.

There do not seem to be any concrete answers on what one should include in a collection library however. So, which types of collections are useful? Which ones are must haves, and which ones would be nice to have? What should the overall shape of the library be and how should collections be designed to work well together?

Trying to find answers to at least some of these questions, we started to look into the libraries of various languages to get a feeling of common design aspects and design dimensions. And the possible design space seems huge. Some languages have only a minimal set of standard collections, for instance, C and Lua. Languages such as Java and Scala have however large numbers of collections.

To weight the various options against each other, we chose to discuss the design dimensions we found in the context of exploratory programming. The discussion is part of the write-up below.

We will present this work in about a month at the PX/18 workshop in Nice, France.


While an integral part of all programming languages, the design of collection libraries is rarely studied. This work briefly reviews the collection libraries of 14 languages to identify possible design dimensions. Some languages have surprisingly few but versatile collections, while others have large libraries with many specialized collections. Based on the identified design dimensions, we argue that a small collection library with only a sequence, a map, and a set type are a suitable choice to facilitate exploratory programming. Such a design minimizes the number of decisions programmers have to make when dealing with collections, and it improves discoverability of collection operations. We further discuss techniques that make their implementation practical from a performance perspective. Based on these arguments, we conclude that languages which aim to support exploratory programming should strive for small and versatile collection libraries.

Smalltalk Jobs - Smalltalk Jobs – 3/12/18

  • Quebec, CanadaAnalyste programmeur Smalltalk – VisualWork/VisualAge through Procom
    • Required Skills:
      • Doit être motivé à apprendre et à travailler en SmallTalk
      • Expérience pertinente en Smalltalk, VB.NET ou autre langage orienté-objet
      • Avoir travailler dans un environnement Windows avec Visual Studio
      • Expérience dans le domaine de l’assurance de dommages
      • Expérience dans un environnement utilisant les services WEB
      • Expérience en SQL et banque de données relationnelles
      • Expérience dans des projets AGILE
      • Connaissance du COBOL .NET
      • Capacité de faire de l’analyse fonctionnelle simple
Good luck with your job hunting,
James T. Savidge

View James T. Savidge's profile on LinkedIn

This blog’s RSS Feed

March 11, 2018

Pharo Weekly - Bloc, brick and GT update


Here is an update of the work on Bloc, Brick and GT. As always, please do let us know what you think.

– Improved the deletion in the text editor and covered the scenarios with examples
– Worked on the text selection. Still work needed for selection to be production ready:
– Balanced rope structure for even better performance of the editor. Overall, the performance of the text editor improved 2x.
– Selectable curves:

– Resizer overlay. The tweet below also shows how we can now easily script dragging behavior in examples:

– Diagrammer is a new engine for drawing diagrams based on Bloc. This is the first version, and we will continue working on it in the following weeks, so stay tuned for more news. This is also one of the first Bloc applications:
– Andrei put together a beautiful description of a scenario in which an application is molded interactively in the Playground & Inspector. The subject is face recognition, and the resulting code is both functional and explainable. This is intended as a tutorial material that shows what moldable development means and how it changes the way we program:

Have fun,
The feenk team

March 09, 2018

Pharo Weekly - Cruiser: A Pharo app packager

Hi Pharoers!

I pleased to announce you the first release of Cruiser: a tool to package your Pharo applications. The idea is to quickly convert an application from a development environment to a production one. A production environment means:

  • No writing on the disk
  • No access to the source code (by the shortcuts, debugger,…)
  • No error displaying on the interface
  • The only thing accessible is the user application

I let you discover it on:


March 08, 2018

Pharo Weekly - Sista VM screen cast: Tracking bugs in optimized code

March 07, 2018

Torsten Bergmann - Clean and modular stateful traits for Pharo

Pharo 7 now integrated (beside many others) a special pull request (PR) to integrate a new version of Traits, this version includes the following features:

- Stateful Traits
- Modular implementation, it is loaded after bootstrap
- Cleaner interface
- Reducing duplicate methods as Traits extends from Class

Since Pharo also has Traits, Slots, MetaLinks, ClassAnnotations and other meta facilities it is a very nice lively system to also work on the metalevel and do metaprogramming.

Clément Béra - Sista VM Screencast

Hi all,

Recently I gave a demo at HPI on how I use the Cog VM simulator to step into machine code while simulating a Pharo image. Normally I like to do blog posts and I don’t like videos (videos take more time to do and I don’t like my French accent which makes them hard to follow), but it’s really difficult to explain what I am doing in this case without a video. Therefore I made a screencast where I show how I track down bugs in the Sista optimized code and how I debug them in the Cog VM simulator through machine code single stepping. If want to read a blog post on the VM simulator instead of a video you may want to look at one of my old blog posts here.

The video shows first how I build an image crashing at start-up on an optimized Sista method. Second, it shows how I simulate it with the VM simulator, including how I set different kinds of break point in machine code compilation and execution to track down where the problem comes from.

The image used for VM simulation can be built following those instructions.

I hope you will like the screen cast. Don’t hesitate to ask questions. Sorry for the French accent.

Pharo Weekly - OSSubprocess for 64bits

Hi guys,

Thanks for Guillermo Polito we now have 64 bits support for OSSubprocess. You can see the required changes in this PR [1]. I made a branch called `support64bits` so that you can help us test it even if CI said it was good [2]. If you do test it and come back to us with the results, please tell us which OS you used.
To install from the branch:
Metacello new
  configuration: ‘OSSubprocess’;
  repository: ‘github://marianopeck/OSSubprocess:support64bits/repository’;
version: #stable;
Roadmap: Current release is v0.2.5. So I will let that release for Pharo <= 5.0. I will make a new release with the Pharo 64 bits and call it v0.3. That release should be used for Pharo 6.x. Once v0.3 is out, I will make a new release v0.4 with some changes I wanted to do since a loooong time and its a small refactor to minimize OSSubprocess dependency on OSProcesses primitives (at VM side). This is thanks to Holger Freyther and Alistair Grant [3]. As that requires a new VM, then v0.4 should be used in Pharo >= 7.0.

Torsten Bergmann - OSSubprocess - 64 bits support preview

Torsten Bergmann - Terminal Emlation in Pharo

Pavel is resurrecting Terminal Emulation for Pharo. Read more.


March 06, 2018

Hernán Morales Durand - SpecUIAddOns release

I released yesterday SpecUIAddOns, a MIT library providing additional SPEC widgets not included in Pharo Smalltalk by default. If you have any suggestions for how this package could be improved, please get in touch or suggest an improvement using the GitHub issues page. Installation, screenshot and usage instructions are provided in the GitHub page.

March 05, 2018

Pharo Weekly - Pavel resurrecting terminal emulation


Guille is working on the Iceberg improvements and he wanted to be able to open a terminal window on top of the repository and interact with it via the command line. So we looked at this issue because I already in December made some experiments with the terminal emulation in Pharo.

In past, the Squeak had a working terminal emulation that used PseudoTTYPlugin. The VM is not built with this code for a long time but I tried to replace it with a small C library and then wrote an FFI interface to it. Together with that, I ported most of the old code Squeak code to Pharo.

With Guille we tried to avoid usage of such external library and wrote an FFI interface to all the required LibC functions. We were successful but we realized that there are several issues that are limiting us.

When you want to execute a separate process for the program that you want to open in terminal (typically the Bash), you need to redirect the standard IO files, create a fork of your process, do some additional initialization in it and call ‘exec’ on it. In the parent process, you change redirected IO files back to the original values.

But the problem is that between the FFI calls from Smalltalk the VM can do a lot of things including garbage collection etc. On OS X the fork() function has the following limitation described in man:

“There are limits to what you can do in the child process. To be totally safe you should restrict your yourself to only executing async-signal safe operations until such time as one of the exec functions is called.  All APIs, including global data symbols, in any framework or library should be assumed to be unsafe after a fork() unless explicitly documented to be safe or async-signal safe.  If you need to use these frameworks in the child process, you must exec.  In this situation it is reasonable to exec your-self. yourself.”

As the result in most cases (but not all) the fork() and exec() pair from the Smalltalk side fails on OS X. Linux does not have this limitation however even there we found an issue. It is bound to the fact that fork() makes a fork of all the parent process that uses the same resources. As soon as Pharo is opened in a window and X11 is involved (the window wants to be repainted), it can lead to the VM crash.

So we learned that unfortunately we currently cannot use image-only FFI code for this task. We need a C library or VM plugin.

The repository of the terminal emulator is here:

and can be loaded using the following code:

Metacello new
baseline: ‘TerminalEmulator’;
repository: ‘github://pavel-krivanek/terminal/src’;

#TerminalEmulator asClass compileLibrary.

It compiles and links the small library with only one function using the GCC so the machine needs to have a proper development environment.
The terminal emulator is in very early stage and has a lot of issues like processes cleanup, drawing, keyboard input etc. etc. If you are interested in it, feel free to contribute.

— Pavel

Marten Feldtmann - VASmalltalk’s UI builder and modern JS frameworks …

The UI of VASmalltalk has always been in discussion since I got to know it around 1998 … one has two ways to build the UI: the original AbtBuilder stuff or the more moderized UI using via WBPro.

I started using VA with the WBPro stuff – the stuff I knew from VisualSmalltalk and loved most.

Over the year I started to hate WBPro – its getting old and the data binding stuff is not up to date any more and then I looked around the AbtBuilder stuff (and its support for data binding up to the UI) – but it was very tight binded to relational databases.

Now 20 years later I find the ideas of AbtBuilder in modern JS frameworks and so many people are getting crazy about these features. I have even seen JS UI building tools, helping building UIs (much smarter looking stuff) with so many ideas already available in VASmalltalk.

Want to have a grid ? Well, assign the content to a domain class and build columns from that domain class in that grid – now bind the grid to a CRUD-storage, make filtering, make sorting available – make paging available. All that was already available 1997 … but never updated to a more general case.

Marten Feldtmann - SQLite Extensions … or Smalltalk defined functions for SQLite

I read today about SQLite extensions and handling them within Pharo. For all VASmalltalker out there … there is an old package from 2013 in vastgoodies, which shows, how to use Smalltalk as an extension in SQLite and how to write functions in VASmalltalk and call them from SQLite … pretty crazy and heavy usage of Callbacks of Smalltalk.

Smalltalk Jobs - Smalltalk Jobs – 3/5/18

Smalltalk position in fashionable Milan.  Not much details beyond at least 2 years of Smalltalk.