Tuesday, May 17, 2011

Looping... it's been driving me crazy

I've been told I am stupid and / or crazy, but looping concepts have been bothering me.

For each, iterators, next, while, whatever. All that spinning, all the indexing, all the positions, the head, the tail, push, pop, sorting, reversing, slicing, dimensions... So much one after another, so much sequence. I really don't like it. Whenever I see a loop I think "blocking", I think "waiting". I think about people in lines waiting to get to the front. I think about the length.

I've convinced there has got to be a better way, but I am not sure what it is yet. The associative array is a little better, but its still a collection that demands iteration. Hash tables are close, but I always find myself wanting the keys.

The array has been burned into the computer science mind since the beginning. We've been forced to think this way based on text books and forced given the current computer architecture.

So what if we remove the commonly known ways to act on a collection of elements? What would we replace them with? How would we think differently about acting on that collection?

Maybe events and listeners? When the collection is alive and an element meets a condition then the listener is executed. I like how jQuery selectors work agains the window as the container. Window contents can be a result of many selectors, but remains in the general window container. Then you can execute events on items in the window. The binding and the triggering is more of what I am suggesting in general element interaction. With this, you wouldn't really collect elements, you'd create them.

Maybe distributed accessor to adjust the collection? As cycles are available, act on the collection. Then I can at least work on more then one part of the collection at a time. The listeners mentioned above would be threaded in this mannor.

I want to remove the "element" concept and focus on the collection. What does the collection mean? What will I gain from something being collected?

Meditate on this, I will.

No comments:

Share on Twitter