If only the datastructure was different

For those using a RSS reader, subscribe here: rss.xml

Algorithms and datastructures for computer science have come a long way. Optimizing code boils down to removing assumptive dependencies of your problem; formulating the problem as specifically as possible to allow the fastest algorithm.

This idea of problem formulation directly translates into programming itself: be as clear in intent of the code as you can be, it just so happens the notation is executable by the computer.

So why not leverage compilers even more? What if the basic operations you would do on datastructures, push, pop, peek, insertion-first, -last, remove-first, -last etc. would stay the contract? What if ICollection, IList,.. would be implemented by a compiler chosen implementation, matching the usage of the basic operations optimally? This could even be semi-automated, some kind of interactive process with the programmer, always allowing the programmer to override the compiler’s suggestion.

This process would go something like this: the programmer is as declarative as possible in intent. Then the compiler can internalize the collection lenghts and intersect the used operations against the available datastructures. From there it is a game of picking the best by utilizing the time complexity tables.