Question

There is a kind of beauty in supervening relationships. Consider the following examples:

  1. Atoms are composed of subatomic particles, molecules are composed of atoms, cells are composed of molecules, organs are composed of cells, people are composed of organs, societies are composed of people.
  2. The complex strategies of the game of Go are built upon the need to make structures with "two eyes" so that they'll survive - however the "two eyes" thing is never stated in the rules, but is itself an emergent property of the very simple rules of Go.
  3. The Turing completeness of Conway's_Game_of_Life can be proven in terms of gliders, guns and spaceships, which are in-turn based upon the concept of on and off and very simple set of rules.

In all cases, a minimal set of objects and a minimal set of rules ultimately lead to very complex structure.

My first question: Is it possible to outline a small and minimalistic set of programming "objects" and "rules" which can be used to build up a OOP language?

Now, the clever computer scientist will probably point to the Turing completeness of rule 110 and say that this is all you need! But that's not quite what I'm looking for. Rather, at the risk of posing an ill-defined questions, what are the simplest, human-understandable concepts that can be built into an object oriented programming language?

For a bad and incomplete example that hints at what I want, define three conceptual objects: a reference, a function, and an information holder. Then (level 2?) define a structure to be be an information holder that holds other information via references to other information folders. A rudimentary class (level 3?) would augment structures with a references to functions, but additional structure would have to be built to handle concepts of private vs. public functions. Ultimately we should arrive at a full-featured OOP language that was built solely upon fundamental concepts and nowhere did we cheat by hardcoding optimizations or syntactic salt with machine code. And ideally, the end result would still be attractive and readable code.

My second question: Are there any OOP languages out there that already approach this?

Was it helpful?

Solution

Prototypes

The IO language reference gives a good hint - the simplest approch to OOP seems to be prototype based programming. All you need is basically associative arrays and first-class functions.

Since many data structures including the dictionary can be implemented in terms of functions, we're soon down to some syntax sugar and lambda calculus, which covers a whole turing-complete model of computation.

OTHER TIPS

io is probably the closest language out there to what you're looking for.

Interesting question, but I'm not entirely sure it is sensible.

Consider that 1's and 0's are our atoms in computer science. They are strictly indivisible. And varying combinations of them give rise to programs with all sorts of amazing properties. But, it isn't appropriate to write in 1's and 0's, as the level of abstraction is too low.

I think the same issue would befall your language. If it was flexible enough to allow for the construction of anything, it would be unusable, and if it wasn't, it wouldn't be meeting your requirements.

Smalltalk is built upon a very limited set of primitives, but OO ideoms are atomic there. In theory, you can build an arbitrary complex language on top of a base as simple as SK logic or lambda calculus. OO features are not any different, they can be reduced to a more primitive set. Any OO system on top of a primitive Lisp macros can be a good example.

Update: and take a look at Term Rewriting Systems in general, it's a powerful technique for defining complex semantics on top of simpler things.

I'd also recommend reading a book http://www.cambridge.org/gb/knowledge/isbn/item1132720/?site_locale=en_GB

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top