icon

KE Programmer

Pharo Smalltalk is like English
Published on Feb 04, 2024 11:15 by KE Programmer

java-to-pharo-syntax.png

Figure 1: Image showing progression from java to pharo syntax

I'm currently on week 2 of the pharo mooc, and it's fun and eye opening so far.

Smalltalk the language was designed by Alan Kay to be easy enough for a child to use for his dynabook project, and that is why it has such a small syntax.

In the mooc, an example I see of this is when it comes to your typical method call in C-like languages.

Let's say we have a postman object that we use to send mail to a recipient. It can be represented in Python as:

postman.send(mail, recipient);

In smalltalk in the place of calling an object's methods, we think in terms of sending messages to objects. In the example above, we would be sending the message send to the postman object with parameters mail and recipient.

To gradually convert the method call above to its pharo equivalent, we would do the following:

In this example, we're sending a keyword message send:to: to the postman object.

In pharo there are 3 different types of messages: