Monday, March 12, 2007

Dreaming of PLINQ

PLINQ is project that aims to parralellize your LINQ queries so that they can make use of the extra processing power available on multi-core machines. I'm very much hoping that it will be released in the Orcas timeframe because it's such a killer app. It will give .NET a HUGE advantage over most other mainstream languages including Python, Javascript, Ruby, and Java. People tend to believe that LINQ queries are only good for data access because they look so much like SQL. In fact a huge number of general programming problems that have nothing to do with database access can be expressed as queries. For example here is a function that multiplies two matrices:

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.


Anonymous said...

I have to say, reading your blog, and one or two others like it, has got me very excited about the future of C#. One shortcoming I have is a solid understanding of functional programming, which seems to be key to implementing solutions in this fashion. Can you recommend any good resources to help me get into this mode of thinking? I'm always trying to add more tools to my tool belt.

Jafar Husain said...

1. Structure and Interpretation of Computer Languages

It's an MIT class taught in LISP with textbook and video all available online! Don't worry about LISP, it's probably the simplest general programming languages there is. You'll pick it up in no time. Almost everything you need to know about functional programming you can learn this way.

2. Why functional programming matters. (

This is a paper that describes the benefits of functional programming. It uses Haskell for its examples. Haskell is a pure functional language that is very new (98) and is one of the forefathers of C# 3.0.

Anonymous said...

In you comment you wrote both the "Structure and Interpretation of Computer Languages" and the "Why functional programming matters" with the same link (URL) - (

Is it a mistake?
And bisides, aren't those courses a little bit old(1981)?

Anonymous said...

Awesome! Thanks very much. This is better than what I was expecting.

Jafar Husain said...

Vladamir: You're right the link was a mistake. Here's the correct link to Why functional programming matters (

As for the courses being old it's not really important. That's because as far as programming language theory goes, most of the important stuff was discovered 40 years ago. :-) There's been some new stuff since, but even that is pretty old.

Haskell is relatively new (1998) and it picks up where SICP leaves off with lazy evaluation, monads, and so on.

Jafar Husain said...

URL got cut off in the comment, here is for the final time:

Judah Gabriel Himango said...

Jafar, you'll be happy to know that Joe Duffy, the mind behind PLINQ, has resigned as a CLR program manager to work full-time on PLINQ.

Jafar Husain said...

I heard. I'm dying for some more info on PLINQ. Getting so excited about technology that's not going to come out for so long is exhausting. :-)

In the meantime I'm amusing myself with Haskell.

Anonymous said...

Aston Villa rode their luck at Hull City where an 88-minute own goal from Kamil Zayatte saw them leapfrog three points clear of Arsenal and into fourth place in the Premier League wow gold with a 1-0 win.

Villa had to survive Hull penalty wotlk gold appeals for a handball against Ashley Young in time added on, television replays showing that referee Steve Bennett wow gold correctly rejected the claims after consulting a linesman.

Bennett had been involved in controversy after just five minutes when American goalkeeper Brad Friedel looked to have handed Hull the initiative and threaten Villa's return to the Champions League qualifying wow gold zone.

Friedel spilled wow gold the ball under pressure from Nick Barmby and stand-in right-back Nigel Reo-Coker turned it into his own net as he attempted to wow gold clear.

But Bennett cut short wow gold celebrations at the KC Stadium -- and let Friedel off the hook -- when he ruled out the score for an wow wotlkapparent infringement by Barmby.

Zayatte's intervention from a Young cross bound for wow gold Gabriel Agbonlahor then saw Villa leapfrog Arsenal and draw level with Manchester United on 38 points -- seven adrift of leaders Liverpool and four wow gold behind Chelsea.

Stung by an on-pitch dressing down wow gold by manager Phil Brown at Manchester City last week, Hull showed five changes and a vastly improved performance.

Promoted Hull were looking for only their second win in 11 games while wow gold Villa arrived unbeaten in seven and it looked to be heading for a goalless draw when the home side suffered a cruel late blow.

Anonymous said...

Premier League leaders Liverpool thrrew their "full support" world of warcraft gold behind Steven Gerrard after their captain was charged with assault on Tuesday following an incident at a local nightclub.

Gerrard, 28, and two other men were charged with assault occasioning bodily harm and affray, Merseyside police said.

They are scheduled to world of warcraft gold appear in court on January 23.

In the wake of the charges, Liverpool issued a wow power leveling statement on their official Web site.

"Steven has been an outstanding servant to world of warcraft gold Liverpool for the last ten years and the club will give him all the support he needs at this time," it read.

The offenses with which Gerrard have been charged carry cheap wow gold a maximum penalty of five years in prison.

Three other men, who were also arrested, were world of warcraft gold released without charge pending further inquiries.

Gerrard was arrested cheap wow gold in the early hours of Monday morning and eventually charged after over 20 hours in police custody.

His wife Alex Curran was seen near the police station where world of warcraft gold he was held but drove off without talking to reporters.

Gerrard had been celebrating his side's 5-1 buy wow gold win over Newcastle on Sunday when the alleged altercation occurred.

He had scored two goals in the victory at St James' Park which left world of warcraft gold Liverpool top of the English Premier League and on course for their first English title in 18 years.

He was released on bail to wow power leveling appear in court on January 23 with John Doran, 29, and Ian Smith, 19, who were charged with the same offenses.

Gerrard, who has spent his entire career with Liverpool, world of warcraft gold is one of the most celebrated players in the club's history and renowned as a model professional.

In 2005 he lifted the European Cup -- Liverpool's fifth -- wow gold kaufen after a thrilling penalty shooting victory over AC Milan and turned down the advances of cash-rich Chelsea to stay with his local club.

The midfielder has also made 70 appearances for England, dofus kamas captaining his country on four occasions.

He was made an Member of the British Empire (MBE) last year and received an honorary fellowship from Liverpool's John Moores University.

Liverpool's next match is against Preston in the kamas dofusEnglish FA Cup on Saturday, a game Gerrard was due to sit out because of suspension

Anonymous said...

Joy in warcraft leveling living comes wow lvl from having wow lvl fine emotions,wow power level trusting them,power leveling giving them power leveling the freedom of wrath of the lich king power leveling a bird in the open.wlk power leveling Joy in living can age of conan gold never be assumed as a pose,or put on from guildwars gold the outside as a mask. People who have this joy don not need maple story mesos to talk about it; they radiate it. wow gold They just live out their joy and let wow power leveling it splash its sunlight and glow into other lives as naturally as bird sings.

Anonymous said...

Welcome to the maple mesos, In here you can buy the mesos, Do you know that the maple story mesos in the game is very important, If you had more cheap mesos. I think you can get the tall level, quickly come here to buy maplestory mesos.

Anonymous said...

I like Archlord gold very much. Since I entered into this game, I learnt skills to earn Archlord money. Thanks to archlord online Gold let me know a lot of friends. It is my habit to buy Archlord gold, and I get some cheap Archlord gold from my friends and Internet.

I like to play Asda Story, because I like its name, also I like Asda Story gold. My friend told me that she would buy Asda Story money for me, and I was so happy. I do not like to go shopping, because it always spends a lot of money, but I never hesitate to buy Asda Story Gold. You can buy cheap Asda Story gold; it is so easy and convenient.

Anonymous said...

aion chinaaion china gold,
aion cn goldaion chinese gold,
aion gold chinaaion gold chinese,
china aion goldchinese aion gold,
aion china kinaaion chinese kina,
aion kina chinachina aion kina,
aion china buybuy aion china,
aion chinese server goldaion cn server gold,
aion china server goldchina aion server gold,
chinese aion server goldaion chinese server gold,
aion cn server kinaaion china server kina,
china aion server kinachinese aion server kina

cheap Perfect World Gold said...

I like play online game, I also Buy metin2 gold and Metin2 gold, the Metin2 yang is very cheap, and use the Cheap metin2 yang can buy many things, I like Cheap metin2 gold, thanks, it is very good.

I like play online game, I also Buy Perfect World Gold and Perfect World Gold, the Perfect World Silver is very cheap, and use the Perfect World money can buy many things, I like cheap Perfect World Gold, thanks, it is very good.

Affordable Luxurious Wedding Dress Blog said...

cheap wedding gowns,
discount bridal gowns,
China wedding dresses,
discount designer wedding dresses,
China wedding online store,
plus size wedding dresses,
cheap informal wedding dresses,
junior bridesmaid dresses,
cheap bridesmaid dresses,
maternity bridesmaid dresses,
discount flower girl gowns,
cheap prom dresses,
party dresses,
evening dresses,
mother of the bride dresses,
special occasion dresses,
cheap quinceanera dresses,
hot red wedding dresses

Anonymous said...

I am grateful to you for this great content.aöf thanks radyo dinle cool hikaye very nice ssk only cinsellik very nice ehliyet only home free kadın last go korku jomax med olsaoy hikaye lesto go müzik dinle free only film izle love aşk only mp3 indir only radyolar lest go açıköğretim free net only filmler

Anonymous said...


eda said...


About Me

My photo
I'm a software developer who started programming at age 16 and never saw any reason to stop. I'm working on the Presentation Platform Controls team at Microsoft. My primary interests are functional programming, and Rich Internet Applications.