Well… One year ago I was talking with a friend. He talked to me about some nice community where he is contributing for, some nice environment called Pharo and a strange language called Smalltalk… A bunch of thing that I never heard before.

At first I was not interested at all… at that time I was learning C++. That thing (C++) was killing me inside and for some reason I needed to find something else to do in my free time. So… I started to read a book that Pharo community wrote for the beginners “Pharo by example”. I developed my first ‘hello-world’ projects kind in Pharo and learn Smalltalk. The thing is that I fell in love instantly of Pharo.

Probably you won’t undestand fully the reasons why I love pharo and smalltalk until you read [What is Pharo?] part further on but here they are only a few:

The syntax of this language make you feel like you are talking to the machine telling her how to behave.

Is a source of constant learning because it was and continues to be written by people known world wide and the code is open source therefore I can read, understand and improve every line. To know the main contributors please check: Pharo Contributors

I’m a Java Programmer… I learn to develop in Java and for many years only that language was my world. When I started to develop in Pharo I just used the Pharo IDE’s code browser since everything is there and fully accessible/changable. I can care about solving a problem instead of constantly looking up Java API and framework descriptions, bug reports, etc.

Smalltalk is just gorgeous. 😀

Rigth now the community has a bunch of projects waiting to be done to improve Pharo. You can access them here: Pharo Topics. The projects listed here can provide you an interesting thesis subject. Brilliant people is part of this community and if you have any question everyone tries to help you as quickly as they can via this mailists:

At this point I’m contributing creating test for the String class to later work in its analysis and find ways to improve the string management in Pharo. If you want to know more about Pharo and Smalltalk you have to read the rest.

What is Pharo?

From the book “Pharo by example”:

Pharo is a modern, open source, fully-featured implementation of the Smalltalk programming language and environment. Pharo is derived from Squeak, a re-implementation of the classic Smalltalk-80 system. There is an important aspect behind Pharo: Pharo should not just be a copy of the past but really reinvent Smalltalk.

Pharo lives under the statement: LESS IS BETTER.

No constructors

No types declaration

No interfaces

No packages/private/protected

No parametrized types

No boxing/unboxing

Pharo also follow the Smalltalk Object Model that applies uniformly 5 rules in its environment:

Everything is an object. Every object is an instance of a class. Every class has a superclass. Everything happens by sending messages. Method lookup follows the inheritance chain.

Probably you are you doubting about their power but don’t rush. Here you have a tip of the iceberg about the things you can do in Pharo.

From Java to Smalltalk

As I said before, I was a pure Java developer once. The first time I saw this I understood why Smalltalk received that name. It’s like writing in a chat, like a small talk. Your code becomes much more understandable.

At the beginning you have to change a little your mindset to get it but then it becomes natural. Also we always have to keep in mind the rule number 4 of the Smalltalk Object Model.

postman . send ( mail , recipient ); postman send mail recipient postman send mail to recipient postman send: mail to: recipient.

And here is another little example:

Java Style ArrayList<String> strings = new ArrayList<String>(); Smalltalk Style strings := ArrayList new.

Fun with numbers

Probably the numbers are one of the thing you most use when you develop. Here you have fun stuff that you can get in Pharo.

Get the class of a number 1 class => SmallInteger

Make the number bigger than their type bound 1 class maxVal + 1 => 1073741823 (1 class maxVal + 1) class => LargePositiveInteger

Work with fractions (1/3) + (2/3) => 1 2/3 + 1 => 5/3

What about characters and strings?

As I told before in Pharo doesn’t exist primitive types, everything is and object, even the character and String are just collections of characters.

$a A Character 'lol' A String

Get the space character is just send a message to Character class Character space => $_

The same with other characters Character tab => $____ Character cr => $



All the classes can get its string representation 12 printString => '12'

Get a character from a string. Send a message to the string. ‘Tiramisu’ at: 1 => $T

Concatenate strings with the message , ‘Calvin’ , ‘ & ‘ , ‘Hobbes’

Arrays

Array representation #(‘Calvin’ ‘hates’ ‘Suzie’)

Getting the size of an array #(‘Calvin’ ‘hates’ ‘Suzie’) size => 3

Getting an element of the array #(‘Calvin’ ‘hates’ ‘Suzie’) at: 2 => ‘hates’

Replacing an element of the array #(‘Calvin’ ‘hates’ ‘Suzie’) at: 2 put: ‘loves’ => #(‘Calvin’ ‘loves’ ‘Suzie’)

Messages… You got it?

As you saw in the previous examples everything that you send to the objects are messages. And you have to know that the class of an object is an object too. So we sent messages to objects or classes because everything is an object.

Booleans too false not => true

Getting current date Date today => 24 May 2009

Getting current time Time now => 6:50:13 pm

Getting pi value Float pi => 3.141592653589793

You can have more information in: Pharo Project or the brand new page still under construction: pharo.org. If you want to find open source projects or a place to manage your code: SmalltalkHub is the best option.

Why you didn’t know about this?

A long time ago, Smalltalk used to be expensive and I mean really expensive (high licensing fees in thousands of dollars). This fact and other many (Speed and reduced hype) killed Smalltalk for a long time. That may no longer be the case but, once the reputation is ruined, it is hard for people to give it a second chance.

Some of the reasons why Smalltalk is unpopular rigth now are:

It never had a big company behind it or a good marketing strategy.

There is no natural trend. Want to program in the browser? Learn Javascript. Want to program on the server? Learn PHP. Want to program for MacOS / iOS? Learn Objective C. And so on…

The syntax and the development environment is different to other languages.

But who cares? Popularity is overrated. Keep an open mind and keep walking, one step at a time…