Pharo Smalltalk syntax fits on a postcard
Of late, I’ve been playing with the language Pharo, which is inspired by SmallTalk.
One interesting thing that I appreciate, and Pharo people boast about is how small its syntax is. So small that it can fit on a postcard. From this small base, an amazingly hackable system has been put together.
From these slides.
I made an imperfect attempt to translate it to python, with some ugly workarounds just to make it run, since there are no obvious python equivalents for some things.
import sys
a = object()
class Parent:
def __len__(self):
return 1
class Foo(Parent):
def example_with_number(self, x):
"This method illustrates the complete syntax"
# aMethodAnnotation <- some static analysis tool may use this
y: int
if not (True and not False and None is None):
breakpoint()
y = len(self) + super().__len__()
for e in ['a', a, 'a', 1, 1.0]:
sys.stdout.write(e.__class__.__name__ + "\n")
sys.stdout.write(str(e) + "\n")
sys.stdout.write("\n")
return x < y
Pharo’s syntax is explained more here. I’m currently working through the Pharo MOOC.