
Pharo, the Modern Smalltalk - louiscyphre
https://medium.com/smalltalk-talk/behold-pharo-the-modern-smalltalk-38e132c46053
======
edmundhuber
Is there a snippet of example code to look at? I browsed the pharo.org
website, but couldn't find an example to give me a taste. I even tried
googling "pharo example" and with a brief look at the results didn't find an
example.

Today, there are hundreds of programming languages competing for attention. It
is in your interest to put an example front and center of why one should spend
time looking into yet another programming language.

~~~
otakucode
I've always found the 'image' environment to be far more interesting than the
language of Smalltalk itself. If you do find just code snippets, you're
missing out on what I, at least, see as the most significant feature of the
whole thing. The way it goes about defining the code is clunky, but the
overall structure of 'images' and the workflow involved with them is
fascinating. I could easily see something similar being the future of
containerization when implemented in some other language.

~~~
theamk
That image environment sounds scary to me. I used to do a lot of hardware
development, and what I love most about software is that you can always
restart from the clean plate (by restarting the program) and/or undo your
previous work (with version control).

From what I understand, none of this applies to Smalltalk. You always modify
code on the fly, so you may end up with properties which exists, but no
current code ever sets them. Or your program ends up in the invalid state, and
you have no idea why -- is it a genuine bug or did it happen few minutes ago,
when the function was still incomplete?

~~~
stcredzero
_what I love most about software is that you can always restart from the clean
plate (by restarting the program) and /or undo your previous work (with
version control)._

That's what I loved best about Smalltalk. You could just hard quit out of the
image, then go back to the Change Log and replay all but the last few changes.
If you save off an image every day or so, you're always back in minutes, no
matter how dangerously you've been coding.

There are a variety of utilities which let you load code quickly. Most often,
deployment was done using one of these loading onto a clean or a stripped
image. You can certainly control changes to your environment. In fact, I'd say
you can often control them more easily than in other environments.

 _you have no idea why -- is it a genuine bug or did it happen few minutes
ago, when the function was still incomplete?_

The Change Log makes it very easy to figure that out. All of your ad-hoc
"command-line" (do-it) state changes to the image are recorded there as well.

~~~
0x445442
This is a great insight but when I read things like this it reminds me the
Smalltalk advocates need to do a better job adressing the concerns of the
broader development community. It seems like they spend too much time
addressing things that aren't concerns and not enough time on things that are.

------
flavio81
_> Smalltalk has the cleanest, purest implementation of object-oriented
concepts; not even Java, Ruby, nor CLOS can lay claim to that._

I'll take "powerful" versus "cleanest and purest" any day, thank you very
much. Sorry but i'm staying with CLOS whenever i want to do object-oriented
programming without feeling limited.

The author is on a pro-Smalltalk crusade (which I find just fine, Smalltalk is
a great lang, and in a perfect world, it would be as popular as Javascript is
today), but does so at the expense of constantly deriding Clojure, Common Lisp
and Racket, which I find silly.

~~~
systems
i would take "large ecosystem" over "powerful" or "cleanest and purest"

whenever i am in the process of picking a language for a project, i check if
there is a library for what i want to do

~~~
flavio81
Yes but on the other hand Smalltalk is an established language with a long
history, i wouldn't be surprised if you are able to find all the libraries you
need.

------
agentultra
I like Pharo. I was able to build a widget that scraped the front page of HN
in an afternoon with it just by following the built-in tutorial and googling.

One interesting "killer app" might be the Moose platform [0]. It's basically
an interactive environment for the analysis of software. Writing a parser is
rather straight-forward and turning the AST into a visualization is also quite
easy. This sort of feels like how I imagine a good IDE should be.

[0] [http://www.moosetechnology.org/](http://www.moosetechnology.org/)

 _update_ spelling.

~~~
vbuwivbiu
can confirm. My day job is coding in Clojure, which I love, but if I get a
spare Sunday afternoon I'll do some coding in Pharo, playing with Roassal

------
tangue
There's a Mooc starting in december by the INRIA ( _French Institute for
Research in Computer Science and Automation_ )

[https://www.fun-
mooc.fr/courses/course-v1:inria+41010+sessio...](https://www.fun-
mooc.fr/courses/course-v1:inria+41010+session02/about)

~~~
vesak
Oddly, I'm more fascinated that I'll be able to learn French reading through
the materials of that course. Perhaps Smalltalk will follow on the side :)

~~~
abecedarius
You're probably joking, but fwiw I'm 7 weeks into Duolingo's French lessons
right now and found most of this course page to be easily readable without
reference to the English. It's much easier than Le Petit Prince, a children's
book for which I still need to hit the dictionary a lot.

~~~
vesak
No, not joking. I have some French courses under my belt from my childhood,
but I never got very fluent with it because I never had any use for it. Having
an actual need to use the language would be great.

~~~
abecedarius
Great! I'd be tempted too if I hadn't done enough Smalltalk to feel comfy
already. (I'll have to find other stuff in French. Maybe Laplace on
probability? Or more likely Tin-tin...)

------
z3t4
They need to work on the presentation. How do you get started ? How does the
code look like ? etc. Not just "download this program and buy this book"

~~~
dwringer
FWIW the PDF of the book "Pharo By Example" is available for free. It has also
been revised for version 5 - I tried using edition 1 with Pharo 4 and kept
having to look up the new names for things, to the point where it was
frustrating to try and follow. They appear to have put a lot of work into
updating the guide.

~~~
igouy
And here it is!

[http://files.pharo.org/books-pdfs/updated-pharo-by-
example/2...](http://files.pharo.org/books-pdfs/updated-pharo-by-
example/2017-01-14-UpdatedPharoByExample.pdf)

------
tempodox
My beef with Smalltalk is that it's far too much a world onto itself for my
taste. Java is already a bad enough citizen of Unix but Smalltalk takes it to
a new level. If Lisp and Scheme can integrate well into Unix, why can't
Smalltalk?

~~~
islanderfun
Coming from a place of ignorance, how does Smalltalk not integrate?

~~~
naasking
A Smalltalk environment is practically its own operating system, complete with
its own isolated UI/window manager, shells and desktop environment.

~~~
EdwardCoffin
I'm not really sure what you are claiming here. My experiences with Smalltalk
ended 20 years ago with IBM Smalltalk and Digitalk Smalltalk/V. At that time,
they both used the host operating system (Windows or OS/2) for UI widgets,
windows, and such, and any applications you built in it could be packaged up
to be launched as any other application. One could use such an application and
have no particular sense of isolation beyond an application written in a more
mainstream language (like C or C++). Have modern Smalltalks regressed in this
regard?

~~~
naasking
Take a look at the Pharo intro on youtube, you'll see what I mean:

[https://www.youtube.com/watch?v=WLoXXFxU8lw](https://www.youtube.com/watch?v=WLoXXFxU8lw)

The images on the current website look very similar, so I don't it's changed
much in this regard. This has been my typical experience with Smalltalk
languages, with the exception of GNU Smalltalk whose specific goal is to
integrate with POSIX instead of creating a walled garden.

~~~
EdwardCoffin
Do you want to perhaps point to a specific time in that video, and compare it
to a non-Smalltalk environment in a way that makes this purported isolation
apparent, because I don't see what you mean.

I don't recognize whatever operating system the demo was done on, so if the
Pharo system is not using native widgets I would not know, you'll have to
explicitly state if this is the case.

~~~
ihumanable
The presenter is in the host operating system (Mac OSX) until the Pharo image
is "up and running" at the 0:40 mark. Everything until the presenter opens up
debian at 5:00 is custom Pharo based desktop / window management / even the
mouse cursor if you look closely.

~~~
EdwardCoffin
Then this just means that Pharo is one of the Smalltalks that does its own
window management. I think Squeak might be the same. It is not a general
characteristic of Smalltalks though, and certainly is not part of their
essential nature. As I said, IBM Smalltalk used native widgets and windows,
and had good interaction with the rest of the operating system.

I don't think you can draw a general conclusion about Smalltalk from a
specific example, especially like this one.

------
t420mom
My personal experience has been that the live coding aspect makes a huge
difference to my development speed. A while ago I was going through Project
Euler in less-mainstream languages, just as a warm-up/distraction from work. I
would do one problem at a time and then go back to work. One day I switched
from Object Pascal (with Lazarus) to Pharo. I completed the problem (which I
hadn't attempted before, so no prior knowledge) so quickly, that I proceeded
to complete five problems in the time it usually took me to do one. Because
everything was so immediate, it was really easy to maintain a flow state. I
had to force myself to stop and get back to work.

The object inspector is really nice, also being able to redefine methods in
the debugger and continue the current computation is super cool. Beats poring
over Java stack traces.

It would be nice if there were more open source libraries available, but
SmalltalkHub is getting better:
[http://smalltalkhub.com/list](http://smalltalkhub.com/list)

------
baldfat
I start from stupid since I was 8 on Programming Languages. I taught myself
Assembly and Pascal before I was a teenager.

I learned Racket and Smalltalk to be a better problem solver. I ended up
becoming a MUCH better programmer due to these two. Racket stuck and I use it
for all my personal projects but Pharo is a great learning tool at the very
least.

~~~
muraiki
After starting out in Python, I did exactly the same thing with Racket and
Smalltalk, which substantially improved my programming ability. I'm glad to
know that I'm not the only crazy person here. :) I haven't used Pharo
recently, but when using other languages (especially dynamic ones) I really
miss it!

------
vanderZwan
I enjoyed playing around with Pharo a few years back, and often look at what
else the people working on it have been thinking of lately.

Having said that, the PharoJS website mentioned in the article could use some
love, I just get an unstyled webpage[0]. Now, I love avoiding website bloat as
much as the next guy, but from the point of view of a web developer who might
be interested in exploring what Pharo and Smalltalk in general might have to
offer, that seems a bit too minimal.

Amber, by comparison, runs a full SmallTalk on the website itself, which is
pretty cool[1]. Doesn't seem to have maintained momentum beyond 2014 though.

[0] [https://pharojs.github.io/](https://pharojs.github.io/)

[1] [http://www.amber-lang.net/index.html](http://www.amber-
lang.net/index.html)

~~~
scroot
FYI for anyone reading / interested: Amber is apparently still under active
development, but they moved from Github to a self hosted platform [1]. Last
code update was 3 days ago.

[1] [https://lolg.it/amber/amber](https://lolg.it/amber/amber)

~~~
vanderZwan
Oh, that's good! But the website and documentation is pretty outdated then. I
guess all current development goes into code?

------
paulajohnson
I wouldn't take Capers Jones' estimates of SLOC/function point as evidence of
anything. In most cases (including these two) this seems to be Jones taking a
look at the language Wikipedia page and guessing a number.

~~~
louiscyphre
Capers Jones is a well-respected expert in software metrics. He's done some
ground-breaking work in this area. Unless you're an expert too, I wouldn't
denigrate him.

------
ScottBurson
_Smalltalk’s use of live coding is easy and elegant; not even Common Lisp,
Forth, nor Java (hot swapping) can lay claim to that._

Does anyone understand what this is talking about? I may not understand
exactly what is meant by "live coding", but I think I do it in Common Lisp
(via SLIME) all the time. How is it better in Smalltalk?

~~~
i_feel_great
In Smalltalk, you can pause your application and inspect the objects alive in
a stack at the time you paused it, go backwards and forwards in the stack,
change them to see an alternative future, make changes and resume. It is the
weirdest shit.

~~~
igouy
And because it's been around for decades, people figure out how create
something like that functionality for other languages:

JavaScript Time-Travel Debugger

[https://www.microsoft.com/en-
us/research/project/javascript-...](https://www.microsoft.com/en-
us/research/project/javascript-time-travel-debugger/)

[https://channel9.msdn.com/blogs/Marron/Time-Travel-
Debugging...](https://channel9.msdn.com/blogs/Marron/Time-Travel-Debugging-
for-JavaScriptHTML)

------
stutonk
For those wondering what it's like to program in Pharo or why there aren't a
lot of code snippets floating around in Pharo materials: it's because the way
you program in Pharo somewhat different than most languages. Pharo is an IDE
in the true sense, i.e. while it's technically possible to open up a workspace
(text editor) window and write a new class all on one screen this is not how
things are done in practice.

Programming in Pharo is usually done either in the class browser or the
debugger so that you're only ever seeing the code for one method (called a
message in Pharo) at a time. Pharo and other Smalltalk variants tout
simplicity of syntax but leave off the fairly complicated class hierarchy and
message coupling semantics ergo the necessity for an extremely powerful
browser. In the browser, messages for each class are further separated into
'protocols' such as methods for 'accessing' or 'initialization' (these are not
part of the Smalltalk syntax, just a convenient layer of organization). At
each level in the hierarchy, the Pharo code browser gives you a nice template
to edit when you want to make a new package, class, or message. The overall
effect is that you're only ever working with a handful of lines at a time and,
indeed, Pharo will warn you if it thinks your message is too complex. Doing
things this way actually makes everything quite manageable. One of the nice
features of being pure OO is that everything is a pure black box so you just
need to know that a class exists and take a peek at its interface to use it
effectively.

To that end, Pharo actually has an excellent search tool that's not present in
other Smalltalk variants like Squeak or Cuis. It does some kind of intelligent
voodoo and can find anything from definitions to instantiated objects to
senders and receivers of a certain message and so on. You can also open up a
playground window to experiment with whatever code in the REPL style. But it's
actually a little bit more robust than a traditional REPL because of the pure
OO nature of Smalltalk. The thing you get back from evaluation isn't just some
text. It's an object with all the associated possibility of reflection and
manipulation (which can all be done from a UI, not just from evaluating more
code).

One of the things Pharo does better than almost every other language is
debugger integration. Pharo is like LISP in the sense that you can start an
application, have it encounter an error (or just pause execution at will),
drop into the debugger and change some stuff, reify whichever execution stack
frame, then resume the program as if nothing ever happened. This is the
essence of the other common Pharo workflow: write some partial code and then
fill it in incrementally in the debugger until you have a fully functional and
bug-free application. In addition, Pharo has its own robust unit testing
system called Sunit that, coupled with the debugger workflow, creates a
fantastically ergonomic TDD experience.

No matter where you are in the Pharo environment, Smalltalk code gets full
treatment (E.G. syntax highlighting, code completion). So what does the syntax
look like? Well, it actually has that concatenative elegance of Forth plus a
few other constructs. Pretty much everything is a message send. Message sends
come in three flavors: unary, binary, and keyword. Constructs like
conditionals are also just message sends. In addition, there are first-class
lambdas (called blocks in Smalltalk). Here's the canonical factorial program:

"Factorial function" fac := [ :n | (n = 0) ifTrue: 1 ifFalse: [ n * (fac
value: (n - 1)) ] ].

where " ... " is a comment, ':=' is assignment, '[ ... ]' is a block, ':n' is
the block's argument, arithmetic operators are actually binary message sends,
things like 'ifTrue:' are keyword message sends (unary message sends are
similar but don't have colons or parameters e.g. 'SomeObject new.'), and the
statement is terminated with a period. Apparent recursion is fine because
Smalltalk uses late binding. Aside from some syntax for strings and class
declaration, that's basically it.

Pharo also has a lot of other nice features such as keeping a log of code
changes in case of program crash or power outage, an integrated package
manager/version control system, and optional git integration. It's all pretty
easy to use and overall the system is quite impressive with a high degree of
polish and decent performance (comes close to or exceeds node in my
experience). However, as others have stated, it's a walled garden. All UI
interaction happens within the Pharo environment with no option for native. If
you want to break out on UNIX, you have write some kind of server and use
sockets or the filesystem (which isn't a huge handicap in the grand scheme of
things). On the other hand, application deployment is a little iffy. There's
no readily apparent scheme to pare an image down to just what your project
uses and then distribute that; users would have to install your package from
within their own Pharo environment.

~~~
i_feel_great
>This is the essence of the other common Pharo workflow: write some partial
code and then fill it in incrementally in the debugger until you have a fully
functional and bug-free application.

This way of developing, called by some as "Living in the Debugger", is
strangely not promoted all that much by the Pharo community as far as I can
see. It is quite astounding for productivity. In essence, you write some very
high level code in a space, "do it", and Pharo will prompt you all the way for
what it needs to make that high level code work. So you end up with code you
need and no more. I have changed my whole thinking about writing software
according to this pattern, even when writing in other languages (Guile,
Erlang, Ada, Lua...). My Pharo remains my favourite.

------
Tepix
If you want to get into Pharo, there's a MOOC by France Université Numérique
starting October 16th:

[http://files.pharo.org/mooc/](http://files.pharo.org/mooc/)

~~~
louiscyphre
You gave the wrong URL. See [https://www.fun-
mooc.fr/courses/course-v1:inria+41010+sessio...](https://www.fun-
mooc.fr/courses/course-v1:inria+41010+session02/about)

~~~
Tepix
"Wrong"? That URL is linked from the page I posted. Click on "France
Université Numérique".

------
JohnStrange
Okay, so lot's of praise for a language. But I have three questions that
aren't answered by the article:

1.) How fast are programs written in Pharao?

2.) Is it possible to write complete and halfway modern looking desktop end-
consumer GUI applications in Pharao?

3.) How good is it at parallel programming (i.e. multicore support, not just
concurrency with green threads)?

I'm always interested in learning a new language, if not just for fun.
Currently my new language on the Todo list is Nim. However, I do not want to
take a look at a language for which the answer to all of the above questions
is "Meh".

~~~
pathsjs
1) Last time I tried it was reasonably fast for a dynamic language - somewhat
slower than javascript (V8) but faster than python (cpython) to give you a
ballpark

2) Yes, but ou will not use native widgets. The way you write applications is:
you write code by modifying the behaviour of objects in the Pharo application
(which is your editor, debugger, GUI, version control system and so on), then
you strip off the parts you don't need (such as what you used to write the
application in the first place). Hence you will probably use the default Pharo
widget system (take a look at some Pharo screenshots to get an idea)

3) Last time I checked it was planned, but there was nothing yet

~~~
JohnStrange
My current main language for my own projects is Racket, but there are
performance issues with text% and the support for parallelism is not good
enough. So I guess with this respect Pharao will not be a good alternative for
me either.

However, I've looked at screenshots and the default widget system seems fairly
reasonable. So I'll check it out anyway.

Thanks a lot for the replies, they were helpful!

------
claystu
How do you get started with GUI programming? I can't seem to find anything on
this for Pharo6...and barely anything for earlier versions (which I'm assuming
are now obsolete).

~~~
scroot
Spec [1] is one way. You can also find a list of books on the Pharo website
[2].

[1] [http://files.pharo.org/books/spec-
tutorial/](http://files.pharo.org/books/spec-tutorial/) [2]
[http://books.pharo.org](http://books.pharo.org)

------
Koshkin
To an inexperienced eye, Smalltalk's syntax seems to be suffering from colon
"cancer". (I don't get a similar feeling from Lisp, for some reason.)

------
jmarinez
*ACM, want to see how bad things are, read this thread....

To understand Smalltalk in general one neeeds to understand the impetus; and
behind it is Alan Kay. What we do today isn’t really “computing” as envisioned
and then created in the 70s. Lots of those terms used back then are used now,
but the meaning has been transformed into something entirely different.

It’s unfortunate that most of the things we call “state of the art” are
bastardized and horrible versions of those from the 60s and 70s. Yet here we
are in 2017 and we can’t have the majority of “computer users” create an essay
defending his/her views on climate change with an actual editable running
model upon which a civil discussion could be based on. But hey, we will have
an iPhone X, so who cares?

Smalltalk is like a gem, a remnant from a magical world that existed and went
away - but still possible - if we just took a look way, way back as to where
it all originated.

For the CS students out there, get your money’s worth and start asking where
all this stuff we have now came from and more importantly, why.

Here’s a good start:

A Personal Computer for Children of All Ages:
[https://www.mprove.de/diplom/gui/kay72.html](https://www.mprove.de/diplom/gui/kay72.html)
“The basic idea is to exploit the duality between functions and tables (or
processes and memory). English has nouns which refer to "objects", and verbs
which refer to "actors" and "relators". This is a Newtonian epistemology.
Modern physics and philosophy tend towards the idea that both "objects" and
"actors" are just different aspects of the notion of process. A process has
state (a set of relations having only to do with it) which changes as time
(defined as interactions with other objects) passes. Using this view "data" is
a process which changes "slowly", "function" is a process which changes more
rapidly. Each process has the logical attributes of a complete "micro"
computer: they can have inputs, give back outputs, act as a memory on file
system, perform computations, be interrupted, etc. Since a "computer" can
simulate all other computers (modulo time and space), having the notion of a
process in a language allows useful idea such as arrays, records, recursive
procedures, etc., to be added to the the repertoire at any time.”

------
dmzkrsk
Any good article describing Smalltalk features for C/Python/Go/JS developer?

------
keithnz
Is Pharo open source?

~~~
dragonwriter
Yes. MIT license.

------
akkartik
On a tangent: I wonder how everybody who writes for Medium feels about the new
Quora-style nag screens.

(I can only go on tangents since I saw the nag screen and bounced.)

~~~
eadmund
No nag screens with NoScript!

------
thedaemon
I'm sorry but the 3d image of the light house is horrible. It reminds me of
POV-Ray renders from the 90s. Is Medium so poor that they can't afford a
competent artist?

~~~
magnusdeus123
Medium is just a platform for posting content. The image was selected by the
author.

