I love Linq to XML

I have never really been a fan of XML files before, sure for certain tasks they are definitely the structured format of choice, they compress well and they get through firewalls, plus they allow you to navigate “jagged” data, but the pain of having to program to them via a pretty unwieldy DOM was always in my opinion a hefty price and frankly not always worth the cost.

However all that has changed for me with .NET’s Linq to Xml, I swear I am now finding that I LOVE coding to Xml now, incredible!  Hurrah the DOM is gone, the wicked witch of the west truly is dead. The new XML API as embodied by XElement (and related classes) is simply a joy to use, and the associated Linq extension methods for navigation over the document is superb.

Look at this snippet for example…

var xe = (from x in XElement.Load(spotFile).Elements("Table")
         where (string)x.Attribute("Name") == txtTableName.Text
         select x).First();
txtResults.Clear();
txtResults.Text = (string)xe.Element("SQL");

In this particular case the “SQL” element contains a CDATA section, but in reading the file back I can simply type cast the element to a string and the API realizes that I want the inner text and that if the inner text is in a CDATA section to simply extract it…brilliant.

Concurrent programming

I was watching a channel 9 video earlier by some members of the C# design team, including Anders Heijsberg and Eric Lippert, and one of the recurring themes was one about programming for concurrent processing. (Video is here http://channel9.msdn.com/posts/Charles/C-40-Meet-the-Design-Team/)
Of course the holy grail is for a developer to be able to cut code as if it were to be processed in a single thread, and then for the framework to run it cuncurrently when its deemed safe to do so. It's pretty clear though that the holy grail is not that close yet, sure we are talking about it and things like PLinq are already in beta but we are not there yet, largely because this is a very difficult problem to solve. One thing that the video did bring home to me though was the fact that I have not really turned that switch on in my head yet, I have of course written threaded apps, but only when its been very necesarry for a specific task, mainly because its hard to write, and its hard to maintain, concurrent programming is not yet a regular tool in my toolbox, I think I need to address that.