I wrote the To2DimensionalArray method and here is the implementation if you are interested:
If you wrote this algorithm using nested for loops it would be a set of instructions to build a machine that would give you the answer. On the other hand the query is the answer. The importance of this distinction cannot be overstated. Due to the fact that the query describes the intent of the algorithm the computer is free to determine how to best execute it. The PLINQ query processor will analyze the query at run-time, giving it access to information about available system resources and allowing it to formulate a strategy that makes the best possible use of them. It could conceivably be implemented differently every time your query is run depending on how many processors are idle, how much memory there is, etc! This is yet another good reason to express every algorithm possible as a LINQ query. The more processors are added to desktops in the future, the faster your code will run.
The key to this process is the Expression Tree. PLINQ converts your query code into an expression tree in order to analyze it. I predict that languages without the ability to morph code into data will either adapt or be left in the dust in the future. There are simply too many powerful uses for this technique.
- ► 2009 (20)
- ► 2008 (18)