Sunday, January 09, 2011

IO, objects and messages

I mentioned that one of my Christmas projects involved playing around with the IO programming language. I took it a little further than I'd planned originally and started to look at integrating transactions with it (in the form of the C++ version of Arjuna). I got to know the language pretty well, despite the poor documentation which often caused more delays and hair pulling.

One of the things I realised about half way through was that I really like IO because it has a lot in common with Smalltalk: everything is an object and methods are invoked via the exchange of messages. In some ways it made me realise how much I miss programming with Smalltalk, though that's not to suggest that I preferred one language over the other; it's been a few years since I really used Smalltalk so I'd have to refresh that knowledge to make a qualified judgement.

IO also reminded me that while I love C++ and probably still like it above others, as an object-oriented language it has a number of quirks that don't make it, or similar languages, ideal for beginners learning the ins and outs of OO. One of the things I miss, which was part of the original Smalltalk implementation and Simula, though removed from Smalltalk-80, is the concept of message passing to interact with objects. I always found this concept more natural when thinking about object orientation.

It's probably one of the reasons I took to distributed systems: in the early days of Arjuna, when C++ was chosen as the implementation language over Concurrent Euclid and others, we (mainly Graham) spent a lot of time on making C++ (opaquely) distributed (trailblazing this at the time). Obviously what we ended up with was a system where C++ objects interacted via messages! Since the work Graham did also supported multiple inheritance as well as overloading, it went much further than simply distributing an object's implementation.

Looking back at that period now, I could imagine doing something with that work to move a non-distributed C++ language varient in the direction of message passing, but that would probably have been pointless. C++ is good for what it was aimed at. But I think it, and similar languages such as Java, may not necessarily be the right basis from which to learn initially about object orientation (I still long for multiple inheritance and operator overloading in Java!) I believe that programmers should always have a broad knowledge of languages under their belts and I'm glad I came at C++ through the likes of Simula, Smalltalk, Lisp, Fortran and Forth, to name just a few. Some of them have little to say about object orientation, but I'm sure that all of them have influenced the way in which I think about and approach problems, no matter what the implementation language.

So back to IO. It may have a small following compared to the mainstream languages and it may suffer from poorer documentation than most, but if you've used Smalltalk or thought about learning it, then I'd recommend looking at IO as well. It's not perfect (which language is?) but I'm sure you'll learn something, or perhaps it'll refresh your memories about other languages as it did for me. The result may well be that you chane the way in which you think about object orientation or at least the way you use your favourite language today.

No comments: