Visualizzazione post con etichetta smalltalk. Mostra tutti i post
Visualizzazione post con etichetta smalltalk. Mostra tutti i post

11 maggio 2011

The Observer Pattern and Syntactic Sugar

From the simplicity dept.


The Observer Pattern is a convenient way of updating collaborating objects upon status update. It happens that the .NET Framework and in particular the C# language provides native support for it, in the form of events.

Uhm. This approach to design patterns is incorrect to me since it requires to add a good amount of syntactic sugar only to handle this in a more "integrated" way. The real problem is that in this way language designers and users learn that every and each interesting capability should have its own syntax.

A radically different approach is provided in Smalltalk. The Object (yes, the Object class) provides convenient methods to handle status updates through the updating category of methods: changed, updated, addDependent, etc.

So, what's simpler? :-)

04 gennaio 2011

Smalltalk and Ruby

from the agile dept.

This is my post in the attempt to embrace the Smalltalk way of doing things. In the process, I'm following Davide's course.

The power of Smalltalk is due to the language and its environment, that of course has a bunch of native, old-style C-code for its VM. The question I want to answer is: how much power is hidden in the VM and how much in the ST part? Is the VM hiding something to us?

Let's compare the ST VM to the Ruby VM. Why Ruby? Because the Ruby and ST object models are very similar, and some principles are shared between the two - however, the Ruby syntax is far more verbose (e.g. 40 keywords vs 6 of ST). And because both are written in the old-school C language.

How big is the Smalltalk VM (SqueakVM for instance) compared to Ruby (MRI)?

squeakvm/win32 r2249

22006 .c LOC
33404 .h LOC

ruby 1.9.2 p136

722475 .c LOC
32253 .h LOC

hey, RubyVM's about 30 times bigger than SmalltalkVM! This is a raw evidence that the power of Smalltalk is not in the native/C part but in the Smalltalk part (surprise!?).