Mar 16, 2009

Just a crazy idea.

So i was thinking about pylog yesterday. I still haven't had time to really figure it out yet, but the idea of having bindings for a logic programming language really intrigues me. In particular I had an idea for an application for it.

Lets say i have a map class which is a 2d array of tiles, and each tile stores information about the map at the location: height, terrain, etc. I might have another class called cartographer which does stuff with the map class but unfortunately the cartographer and the tile class are interlinked. If i want the cartographer to give a certain tile a color, I would have to make a color field in the tile class.

Now obviously the solution is to have a space that can be written to in some notation (maybe xml,yaml) and then be reinterpreted by the cartographer class. This of course isn't done because its not practical and not a really common feature of any language i can think of.

But wouldn't it be really cool if these spaces for writing were actually little spaces of logic programming who all used common rules. Im not sure that this is the right encapsulation, but it would be fun.

ps. i need new hobbies for doing in class.

Mar 14, 2009

something i just thought about

Ive recently hit upon something about programming. There are two different kinds of objects that don't represent a data structure:
  • Generic objects with multiple possible meanings
  • Concrete objects with only one intended meaning
Integers, for example, can be used to represent lots of things, quantities, distances, speeds, and even the color of a pixel. Objects this basic aren't even really objects often, they don't need to be. The ability to correctly interpret the meaning of the variable is left to the programmer in the future. It is possible for example to add the number of apples on a tree to a persons height if the programmer decided to store those as ints (which they most likely would).

Most objects written by programmers have only one intended meaning. I could for example create a height class which would allow me to add heights and the embedded semantics of the operations would prevent me from adding height and apples together.

Whats interesting is creating classes of the first type and then being asked what the class is for.