read


read
or learn more

Self

Dec 20, 2010

I’ve been an object-oriented practitioner for years and like many others I’ve come to find it wanting. To be fair, while I think there are valid complaints against OOP in general, the more egregious failings tend to be matters of implementation. For example, in any discussion involving Java’s OOP, the faults of Java’s implementation tends to falsely serve as a proxy for the overall failings of object-orientation proper. It’s almost as if Java’s specific implementation can serve as the template for a more general discussion point. I guess this is how humans operate — someone should figure out how to harness that for good.

Which leads me to the Self programming language.

Maybe you’ve never heard of Self? Shame on you for sure, but your saving grace is that you’ve likely heard of1 or used a least one of: Javascript, Io, Ioke, NewtonScript, Lua, or Cecil and I guarantee that the creators of these language have. To put it as succinctly as possible: Self is the quintessential prototype-based programming language and forms the nexus of influence for every other similar language.

I was initially introduced to the idea of prototypal inheritance when reading Douglas Crockford’s Javascript: The Good Parts. You see, I had been using Javascript on and off (as needed) for a long time prior to reading that book, but like many fools who use Javascript I chose to shoe-horn my notion of “good object-oriented principles” into the language. Much to my dismay, Javascript let me do it. Further to my dismay, Mr. Crockford taught me how to do it. But I don’t blame Crockford for my missing the point — the fault was entirely my own. Javascript is a very powerful programming language for many reasons that have nothing to do with object-oriented programming. Instead, the point to be derived from Crockford’s essay is not to implement classical inheritance and stop there under the assumption that you’ve reached the pinnacle of domain modeling. Instead, we should explore how far we can push Javascript’s inherent power to express our solutions in different ways. Alas, it’s always fun to mold a powerful programming language to operate under different guiding principles than its own, even if those principles happen to be less powerful.2

Which leads me back to the Self programming language.

You see, while Crockford gave me hint of the power potential for prototype-based languages, it wasn’t until I read Organizing Programs without Classes by David Ungar, Craig Chambers, Bay-Wei Chang, and Urs Hölzle that I really became excited. I’m a sucker for under-appreciated programming paradigms and techniques, so the ideal of the prototype was immediately appealing. But as I read, hacked, and explored further I’ve come to realize that there is much more potential to prototypes than I could have ever imagined. More amazingly, if you take some time to explore the excellent Self bibliography you might notice that its influence runs much deeper than just prototype-based techniques. In fact, you can explore how its implementation of polymorphic inline caches has driven much in the way that Javascript engines are implemented3 these days. The canonical implementation of Self can be found on Github, and in the coming months I plan to tear it apart to see how it ticks.

Will you join me?

:F


  1. Or maybe you’ve read section 9.2(PDF) in The Joy of Clojure

  2. That’s not to say that prototypes are the pinnacle either. 

  3. But call-site caching predates Self back to Smalltalk. (see Efficient implementation of the smalltalk-80 system by L. Peter Deutsch and Allan M. Schiffman) 

8 Comments, Comment or Ping

  1. Lars Bak who’s one of the V8 leads also worked on the Self compiler. Some of the techniques they’re using in V8 were pioneered in Self. Though it’s great to see that tech finally hit the mainstream, it’s a bit sad that it couldn’t be for a better language than (or at least a more beautiful one).

  2. @Basu

    Like many developers (I think) I have a love-hate relationship with Javascript. I think despite its aesthetic failings it will prove to be one of the (if not the) most important languages over the next 5-years. I am still reluctant to say if its importance will be felt more as a language proper or as a language host. :-)

    :F

  3. Steen

    Although my present work leaves little to no time for exploring the realm of alternative languages, your post immediately triggered my interest. And a memory of reading:

    http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html

    A good start, indeed. I’m curious where it might take you.

  4. This “tearing apart” of Self sounds interesting, maybe this could be organized through Github or something, so we could do it collaboratively?

  5. @citizen428 Absolutely! However, I am not sure how to begin.

  6. Let me think about this, but I’m sure we’ll manage to get together some sort of “study group” or something. Maybe a centralized repo describing Self, that everyone can fork, add explanations of various parts (or questions) and then send a pull request. Do you think that could work?

  7. @citizen428

    I don’t see why not.

  8. @citizen428, fogus

    Perhaps turn it into a literate programming project? Go through the source code, reading it and writing up explanations and discussions for it?

Reply to “Self”