Monday, September 29, 2008

Relationships as the Semantic Heart of a Language

I've been thinking a lot about intentional programming and the idea that behavior doesn't simply belong to an entity but to the collaboration of two entities and the surrounding context in which they find themselves.

It's an old pattern in database and data modeling to represent rich relationships between two entities with three entities rather than two, where the third entity contains the new information created by the relationship between the first two.

Dependency Injection is a mechanism for permitting this same basic pattern for OO programming languages, where the third entity is really the larger enclosing context in which both of the primary entities exist.

I'm chewing on an intersection of two interesting ideas that elaborate on this concept.

The first idea was inspired by reading maverick physicist Julian Barbour's book "The End of Time: The Next Generation in Physics." One of Barbour's pet conceits is that there is no causality. That all moments in time exist simultaneously as bubbles in a higher order dimension and that causality is really the apparent ordering which is evident when you look in any direction across the sea of bubbles.

This notion got me thinking about entities being nested inside of other entities and the whole notion of hierarchical scope being turtles all the way down. Infinite hierarchical inclusion is a comfortingly attractive idea but in practice it proves a stumbling block when trying to cope with cross-tree relationships. Instead of having a fundamental notion of all entities being defined somewhere in a single-footed hierarchy which owns them, what if we instead said that all entities are their own single-node trees, living in their own world and that their presence in any other larger "enclosing" context was by relationship.

That gives us a model where container->contained relationships are not special cases. They are the normal case. And A->B relationships might be modeled as A->container->B. This is vaguely less efficient than simple A->B, but vastly more powerful because concepts like friction, physics and indirect coupling can now be modeled explicitly.

It also meshes nicely with my second thought, which is that instead of an OOP-driven point of view where behaviors belong to entities, it seems more rational to think of behaviors as belonging to relationships. So that what is possible for entity A to do or have done to it within context C, is a function of the relationship between A and C. Likewise, what A can do to B within enclosing context C is a function of the relationship of A->C and of C->B.

I'll post the math for this when I get further along in working it out. It seems to me though that the confluence of these two simple thoughts is a powerful basis for a language that permits entities to be used differently in different contexts with higher levels of reuse and repurposing than is found in other systems.

Friday, August 01, 2008

Embedded Equation Test

Well, LaTex equations work now, thanks to a 3rd party equation rendering javascript package. MathML is still problematic though.

A sample LaTex equation:

\int_{0}^{1}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx
=\frac{22}{7}-\pi

The Sleeper Awakes

I know I've always said that this blog would be a sporadic affair, updated as and when I had a chance to come up for air. However two and a half years is stretching the point a bit.

I have a number of things I've been working on that I'll post the details on as I get a chance, including some ideas for a possibly novel approach to a computer language but I thought I would celebrate the re-inauguration of this blog with the invention of a new term.

I've coined a new sniglet hodgepourri to describe the analytical approach many new web languages take to choosing the features of the language.

This word can be used in a sentence:

Perl contains a hodgepourri of features.

My apologies, Larry Wall but you know it's true.