Smalltalk a world of living Objects


When I first discovered Smalltalk, it took me a while to get my head around the fact that in image based Smalltalk systems, source code is not written in flat files. Source code in files was so ingrained into my thinking, I had to unlearn and leave a lot of assumptions I have made. In most programming languages programs are written and defined using text files, typically source code is written in text files, using a text editor or an IDE such as Eclipse, IntelliJ or Visual Studio. At this point it just “dead code” in text files, there are no running objects, this is often referred to as compile time. Before a program runs, the runtime environment is created, the program’s source code is parsed, compiled and executed, and when the program finishes the runtime environment is destroyed, so in essence every time a change is made to source code the entire program is created from scratch. Smalltalk is pure object oriented and everything is an object and everything is achieved by sending messages to objects. In Smalltalk we dont use source code in text files to define programs (classes methods etc) instead objects are used to define Smalltalk programs, objects themselves are used to define new classes method etc. Now an object can exist only at runtime, and in Smalltalk everything happens on the fly, there is no such thing as compile time, Smalltalk is a runtime, it is not just a programming language, its a living system, it is a world of “living objects”. This requires a paradigm shift and it often is one of the biggest barriers I find people face when entering into the Smalltalk world. Smalltalk pushes “Object thinking” to another level, but once you push past that barrier you enjoy all the benefits of working with living objects, you can interact with objects, inspect them modify, extended and change them on the fly. This is the main reason why Smalltalk environment have such powerful IDE’s.

So what happens when the smalltalk VM is shut down or not running ? Do the objects then die ?

No. The objects are in a suspended state or go into hibernation and are stored in an image. This is analogous to a VMware image, when you close a vmware image the operating system goes into a suspended state, so the next time the vmware image is loaded to exactly the same state it was before. In Smalltalk objects essentially never die (note objects without any references will be garbage collected), they simply go into a suspended state in the image, in a Squeak Smalltalk image it is very likely some objects are probably 30 years old !

In Smalltalk everything is an object, classes are first class object too, so they can respond to messages just like any other object, so it trivial to create new classes on the fly. The image based system of the Smalltalk might be a stumbling block for people entering into the Smalltalk world but I think this is one of the main things that gives Smalltalk its power, its awesome IDE and the ability to work with live objects makes development so much more productive.

So Smalltalk code doesnt live in files so what happens to version control systems then ?

I do most of my Smalltalk development in Squeak and I use Monticello as the versioning system, in Smalltalk source code itself are represented as objects and are basically modelled as a collection of packages, classes, and methods. Code changes then simply become addition/removal or update of these elements. Since the entire source code are modelled in objects, Smalltalk version control systems have very powerful merge and diff algorithms. The version control systems are language aware and source code changes and history can be tracked down to individual method.

Smalltalk is an amazingly powerful environment, developing in a Smalltalk made me see what incremental development is really about. I guess with GemStone now working on a Ruby VM which is primarily based on the GemStone/S Smalltalk VM, folks from the Ruby world can also experience developing with living objects

Advertisements

6 thoughts on “Smalltalk a world of living Objects

  1. markus

    But the biggest difference is that Ruby is a “scripting” language (in the sense that you can use it for tasks perl used to be) and came from a very different area. I don’t think it will thus ever become similar to Smalltalk, no matter the VM part (though its cool)

    It is interesting to see the two worlds converge in practise (not only about objects & messages)

    Reply
  2. lubos

    Wow, thanks for this introduction. I’m going to research about this language right now, it’s kind of refreshing concept when you compare it to Java or C#

    Reply
  3. Srikrishna

    Wonderful article. I was a smalltalk developer for long time over 10 years. Currently i work on java application which is rewrite of smalltalk. We still use smalltalk to refer code and for other purposes. I still love to do work smalltalk because of ease of development and debugging a big time booster. We write code in debugger which gets picked up immediately. That saves lot of time to compile and deploy cycle which is needed for java.

    The best example of image and smalltalk objects never die is: Recently, i had to debug something in smalltalk, i had breakpoint in the middle of the process and forgot to resume. I went back to smalltalk image after 3 or 4 days and i could resume the process which worked beautifully.

    Also, it is a big time confidence booster for any developer. I believe it forces to learn more into internals and makes you think of objects which is very good thing in long term.

    Today, i was talking to my long time friend who was a smalltalker. Now he works in .NET and flex applications. I asked him how he was doing with flex development and told him it is kind of difficult to fix problem without external help. He told me, most of things can be fixed after working in Smalltalk.

    I think the reason, you are allowed to see the code even the system code except for VM (Virtual machine).

    lubos — I guarantee, It will be a good experience for you.

    Reply
  4. Matt Dunn

    Kent Becks seminal quote on image-based vs file-based development was “Imagine, putting source code in files! How quaint.”, says it all really 🙂

    Cheers,
    Matt

    Reply
  5. mo

    Wow! What a great introduction to Smalltalk. I’m really interested to read more about it. Especially from an OO perspective, and how lessons from Smalltalk can be brought in to the realm of .NET.

    Thanks,
    Mo

    Reply
  6. John Gardner, CMC

    Good article. It makes you wonder, doesn’t it? Why if Smalltalk is so good, powerful and efficient (development cycle), does the marketplace prefer Java, C#, C++?

    I have returned to Smalltalk time and time again, after deviating to other languages. And you know what? It’s still terrific. I have a number of projects and will be developing in Pharo/Squeak and leveraging tools like Pier and Seaside; as well as many of the incredible built-in features. And with the COG VM, speed is incredible.

    If everything goes according to plan, I’ll develop an outsourcing/development service that offers free conversion to Smalltalk with a signed support plan.

    Also, with the power of Smalltalk, I’ll be able to compete against brute-force offshore programming with reuse and development speed.

    Finally, I think each of us needs to give ourselves a break — opportunistically use Smalltalk for new projects instead of Java, C#, C++, Ruby, Perl, Python, etc. Pharo has a stripped down image, which you can tweak, and you can do scripting, full development and web apps with Seaside.

    If all of you prefer to work in Smalltalk because of its benefits, then promote its use in your own shop. Think of ways of using Smalltalk to solve a problem, rather than existing solutions using other languages.

    To generate more Smalltalk jobs, we have to create a critical mass of Smalltalk code. Like Alan Kay said “… invent the future”.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s