David Stone's Blog

I'm open to suggestions for a subtitle here! (Really!)
May LINQ CTP - Update Goodness

The new May LINQ CTP is out and it brings a slew of updates to the previous CTP. I, of course, grabbed it as soon as I could and installed it. I've been working on an XLinq article for CodeProject in between classes, midterms, school project, and work, so I popped open that solution in Visual Studio first. I noticed a few changes right away.

VB.NET Changes

One of the first things I noticed in my solution was that all my VB queries were completely broken. That's because this CTP comes with the changes to the VB.NET LINQ syntax that Paul Vick posted about a few days ago. I think this is a great thing as it enabled Intellisense in queries in a way that wasn't there before. Also, as I stated in the comments on Paul's blog:

...with XLinq being such a key piece of Linq for VB.NET (Obviously. I mean, you guys are including XML literals. That's got to mean something.), I would almost think you would have wanted to adopt the FLWOR style queries that XQuery has in the first place. It seems to me that would certainly make VB.NET a more attractive option for those who do a lot of work with XML.
As soon as I re-ordered the queries, they worked perfectly. And, what's more, I had nice Intellisense in these queries. A much welcome change.

C# Changes

Some of my C# queries were broken as well. Now, I might have missed this before, but everywhere I looked the way to do nested queries looked like this:

var entries = from log in EventLog.GetEventLogs(),

                   entry in (EventLogEntries)log.Entries

              where log.Log == eventLog

              select entry;


Now, as I said, I could be wrong. But that compiled and worked before. And that was all I could get to work. The new CTP introduces the join operator. But that's not really what I wanted. So I looked at the new nested query syntax in the SampleQueries samples and I reworked my query to look like this:

var entriesByCategory = from log in EventLog.GetEventLogs()

                        where log.Log == eventLog

                            from entry in (EventLogEntries)log.Entries

                            select categories;


Which is great! This is, to me, a much more natural way to query hierarchical data than the previous way. (If indeed I am correct in thinking that this wasn't the way to query data like this before.) (BTW, in case you were wondering, the EventLogEntries class is just a wrapper I wrote around EventLogEntryCollection because it doesn't implement IEnumerable<T>

ASP.NET Support

This CTP also introduces two things to integrated LINQ into ASP.NET apps. The first is an ASP.NET LINQ Application template under File|New|Website. This has references to System.Query and family and uses the experimental LINQ compiler. This will be useful for me as I can integrate my XLinq stuff into an IHttpHandler to return some RSS. Good stuff.

The second thing is a new DLinqDataSource provider. This provider acts just like the other DataSource classes. So you can hook up your data driven controls to DLinq queries rather than straight to the DataSet or whatnot.

Samples

There are a bunch of new sample applications in the /Samples directory. The SampleQueries application has been updated with the new standard query operators (Join, First, ElementAt, etc.) There are also a few databinding example applications. The WCFLinq app. 

One of  the applications that really intrigued me was the ExpressionTreeVisualizer addin for Visual Studio. With it, you can see what your Expression tree looks like in an intuitive sense. Hovering over the following:

Expression myExp = Expression.Add(

    Expression.Multiply(

        Expression.Constant(5),

        Expression.Constant(10)),

    Expression.Constant(20));

Gives me the normal debugger tooltip that shows me that I've got:
{Add(Multiply(5, 10), 20)}

Which, if you ask me, is pretty dang sweet in and of itself. But, using the debugger visualizer, I can see it in a tree view. And, since these are called Expression Trees, that seems kind of appropriate. Very nice work guys. This is good stuff.

Another of the sample applications that caught my eye was this LogicProgramming sample. There is some heady stuff in here that it's going to take me a while to wrap my arms around.

IQueryable<T>

This is the magic that makes DLinq happen. This converts your Expression Tree into SQL for you. And, theoretically, could convert your Expression Tree into...anything. I wouldn't do nearly as good of a job describing it as Matt Warren does here.

Anyway. Those are the things that caught my eye in this release. Good stuff to think about. Once I get done with that XLinq article, I'll start one on Expression Trees. There's a lot there.
Posted: May 10 2006, 06:14 PM by David Stone | with 7 comment(s)
Filed under:
ASP.NET PropertyGrid Control

leppie just posted this to his blog.

It's an ASP.NET PropertyGrid control. I've got to say, I think he did a great job on this. The generated JS, CSS, and HTML is very clean. CodeProject article forthcoming. :)

SapphireSteel - Ruby in VS 2005

Sweet. There's finally a good environment to try out Ruby in. This one.

The guys over at Sapphire In Steel have managed to put together a pretty good Ruby plugin for VS.NET. They just got it integrated with the debugger.

We’ve made much better progress than we’d anticipated with the Ruby debugger for Visual Studio. Initially we had planned the debugger in 0.6 release of Ruby In Steel to take the form of breakpoints plus a ‘code evaluation’ window. In fact, we have come much further than that. It will now include the following features:
* breakpoints
* locals window
* drag-and-drop watch variables
* call stack
* tracing with step into / step over
* interactive debugging console

And yes, Rails support is coming (eventually). Looks like I'm going to have to give this a spin. That's honestly been one of the things holding me back from looking at Ruby is that yeah...text editors are nice, but I'm a pampered developer. I like my Visual Studio. I'm not willing to give it up.

UC Berkeley Podcasts

Tim Sneath wrote a post on Berkely's CSE podcasts and I have to agree with him on how awesome it is that you can actually listen in on lectures (or even watch them, if you're willing to put up with the Real Media format for the webcasts) given at Berkeley for free.

I'm an Applied Math/Computer Science major here at UCSD, so I know how much these courses cost to actually take. And believe me, the value in them is huge. When I'm in the car, I'm usually either listening to music (on my iPod or my local alt/indie station) or to one of the CS 162: Operating Systems and Systems Programming podcasts. It's been so informative that I've started recommending it to all my friends as well.

Of course, the best part IMO, is that I don't have to take any midterms or finals for these classes. ;)

Finally...
I just got my copy of Framework Design Guidelines. I'm so happy. :-D
Ribbon + VS.NET ?
Pardon me if this has already been discussed, but I haven't seen it anywhere. There's been a lot of talk about how Office 12's UI is being revamped with the new Ribbon feature, whose primary purpose is to clean up the menu and toolbar bloat that has happened over the years. And I was wondering today, are we ever going to see this in Visual Studio? Aside from Word, I can't think of a single application that has more features and more menus and toolbars to go along with than Visual Studio.

I know the roadmap says that Visual Studio's UI is due for an overhaul in the Hawaii timeframe...I was just wondering if the Ribbon is a precursor to the new UI for VS.

Thoughts?
On Hashtables
I've been working on writing up a Hashtable for my CSE 100 class at UCSD. The assignment is to implement a Hashtable using Double Hashing with Multiple Passbits (my professor is one of the authors of that paper...yikes). So, naturally, this piqued my curiosity as to how the BCL's System.Collections.Hashtable is implemented. I started digging around with Reflector and the source is really very interesting.

I was wondering what group is in charge of the BCL Hashtable and what the reasons were behind the choice of implementation (if there's one thing I've learned in these CSE courses, it's that professors love to make you implement hashtables in a bunch of different ways).
C# Getting Unreadable?
Mike Gunderloy remarked, in today's Daily Grind,

"Ian Griffiths explains some of the advanced syntax of C# 3.0. I freely admit that my eyes glazed over. As far as I'm concerned, C# is now going the way of C++: it's got syntax that I will never, ever use and is well on its way to complexifying its way out of my life."

I find it interesting that people keep saying this. There was one guy at the PDC during the Linq End-To-End panel that was very convinced that C# was quickly becoming too complex, and ergo unreadable. He stated that he believed that the introduction of generics made the BCL look too much like C++’s STL and made the code produced too complex for the average developer to learn. From there, he transitioned into voicing concern over the new languages features in C# 3.0.

I, personally, can’t understand this aversion to Linq and the new C# 3.0 language features. Let’s look at the following code, shamelessly stolen from Ian Griffith’s post. First, we’ve got the C# 2.0 anonymous methods version of it. (I’m not even going to bother reproducing the C# 1.0 version. That would be pointless. Whidbey is here, people. Get used to it.)  

public static void ShowDivisible()
{
    for (int d = 1; d < 10; ++d)
    {
        Console.WriteLine("Numbers divisible by " + d);
        PrintMatchingNumbers(1, 10,
            delegate(int i)
            {
                return (i % d) == 0;
            });
    }
}

Now I think we can all agree that anonymous methods are pretty cool. It saves a lot of work when constructing one time use methods just to fulfill a delegate. Also, I believe the code is more readable than it’s C# 1.0 counterpart due to the fact that I don’t have to go hunt down a method somewhere else in my codebase. I’ve got it right there in the place where I’m using it. So, having seen that, lets take a look at the C# 3.0 version of the same code.

public static void ShowDivisible()
{
    for (int d = 1; d < 10; ++d)
    {
        Console.WriteLine("Numbers divisible by " + d);
        PrintMatchingNumbers(1, 10, i => (i % d) == 0);

    }
}

Now, as I said, I personally think this is much more readable. The new lambda expression syntax puts the focus more on the actual intent of the code (the fact that I only want to print out numbers where i % d == 0) than the construction of the delegate. In addition, thanks to C# 3.0’s new local variable type inference abilities, I don’t have to worry about how to construct my delegate and what the signature looks like. The compiler just knows. I get all this at the cost of…what? Learning a new => operator? If it means that I don’t have to worry about those delegate signatures anymore, then count me in. I’m a big fan of the fact that I can let the compiler worry about that for me.

What I really can’t understand is the aversion to the new language syntax for the standard query operators. They’ve introduce querying ability baked directly into the language that supports query operations over anything that implements IEnumerable<T>. First, you get one query language for any type of data, be it relational, XML, in-memory collections, etc. Second, that query language is not only going to be full of IntelliCrack goodness., but it will be checked for you at compile time, eliminating the need for nasty errors that crop up at runtime when SQL Server decides you don’t know anything about how to write SQL queries. Third, there’s a very short migration path from SQL (Unless you’re using VB 9, at which point there’s almost no migration path) or XQuery, so it’s not that hard to learn the new keywords and syntax.

Maybe someone from the other side of this argument would like to explain to my why they think these new features are unreadable, too complex, or why you wouldn’t use query capabilities built into the language. And, by the way, if you think that C# is too complex because it’s got these things in it, where are you going to go? Because VB 9 is going to have them as well.

Trouble installing Vista on my Alienware
Alright, after the PDC I finally decided that it was time to take the plunge and install Vista on my laptop, rather than in VMWare. (That, and the fact that my laptop, like all good dev boxes, is in need of it's quarterly repave.) The problem I'm having, though, is that my laptop is an Alienware Area 51m 7700 series with a Promise FastTrack 378 SCSI RAID controller. That wouldn't be such a big deal except for, when I go to install it (not through XP, but from boot), Vista doesn't recognize my hard drive. So I got the drivers from the Alienware site, unpacked them onto a CD, and used the new Load Driver button in the hard drive selection screen to load up the drivers. Vista install finds the INF file, parses it, shows the available drivers, but when I click on one, it tells me that the driver is either incorrect or that it's missing. Now I know for a fact that it's there, but it won't install no matter what I do.

Has anybody else had the same issue?
Best picture from the PDC...
I think I definitely captured the best pic from the PDC. Add your own caption... ;-)

Scoble at the PDC

More Posts « Previous page - Next page »