LinqBinding Markup Extension

Earlier today on Twitter Aaron Erickson was berating the inability to write linq statements directly in Xaml. While I’m not totally convinced that is a good idea to begin with I decided to come up with a little proof of concept to see if it’s even feasible. I was able to get about half way to what I would like to see by creating a custom markup extension called LinqBinding. The result allows you to create bindings such as this:

<sys:String x:Key=”query”>id &gt; 1 &amp;&amp; id &lt; 4 || name==”six”</sys:String>
<ListBox ItemsSource=”{e:LinqBinding {StaticResource query}, Binding={Binding}}” />
The query in the string is the linq statement you would put into the where clause normally. I was unable to figure out how to use a Binding statement to a TextBox instead of having the hard-coded string but I’m pretty confident it is possible somehow (I’ll leave that for another blog post for now).
In order to accomplish this I used the code found in the Dynamic Linq examples talked about by Scott Guthrie in his blog.
Here is the sample: LinqExtensionSample.zip

Silverlight and Interoperability

I read something interesting on Scott Guthries blog about the release of Silverlight 2:

Interoperability

Today we are also announcing that Microsoft is partnering with Soyatec to sponsor additional tools for developing Silverlight applications using the cross platform Eclipse development platform.  Click here to learn more about this and download the free Silverlight Eclipse plugin.  Click here for a step-by-step tutorial that walks-through how to use their Eclipse tools today to build a Silverlight 2 application.

We are also announcing today that we are releasing the Silverlight XAML vocabulary and schema under the Open Specification Promise (OSP), which enables anyone to create products that read and write XAML for Silverlight.

This is a bit surprising but a good move I think. Scott Guthrie and the ASP team have also been creating the ASP MVC framework under an open source license so it shouldn’t be too much of a shock to see the focus on interoperability with Silverlight. I do like this trend though, I feel like it’s important to focus on interoperability and support open source as much as possible.

CSharp is C plus plus plus plus

I learned something interesting today while reading one of the RSS feed items in the Visual Studio start page. The article in question is an interview with Anders Hejlsberg who says that the idea for the # in C# came from taking C++++ and stacking the pluses (amongst other reasons). I always wondered why they ended up going with the # symbol…

The A-Z of Programming Languages: C#

Flash vs. Silverlight, Indeed

I was just looking at indeed.com and decided to put in Flash vs. Silverlight. The results are pretty interesting:

At the time of this posting flash goes from 0% in May ’05 to about 100% in Sept ’07 while silverlight has gone from 0 at May ’07 to 1,300% in Oct. ’07. I guess we can see that Microsoft has done a good job of getting people excited about Silverlight. Now all they need to do is devliver the goods.

Also, one other interesting thing is how F# creates a graph that sort of looks like the New York skyline:

That seems pretty ironic from a functional language.

Offline Editing With TFS Integrated Source Control

I am a big fan of TFS. I have been using it for a while both at work and through codeplex. I have used several other source control systems including CVS, SVN, VSS and Star Team. I can say without equivocation that TFS is the best hands down, my second favorite is SVN which is a really great source control system as well.

Up until today there was two areas where I would say that SVN beats TFS and makes it worth using. The first is price; SVN is free while TFS is expensive, so it depends on your budget and your need for quality. If you are working on a public project you might as well go with codeplex because you’ll get a great source control system for free along with wiki pages, forums and issues management.

The second area is the ability to work on your project offline. SVN is perfectly designed with this concept in mind, you edit offline to your hearts content then the next time you’re online you fetch and merge everything and then check it in. Very simple but with TFS, since you’re integrated, once you are offline you loose the ability to keep track of what items you’re checking out and working on then the next time you go back online you end up needing to checkout stuff as a guess and it will also cause your integrated source control settings to get messed up it is very kludgy and annoying.

Well today I ran into a bug in TFS integrated source control and looked it up on the MSDN forums to see what the answer was. I had a situation where everytime I opened my TFS bound project it would be offline and I would have to rebind to the source control server every single time. Verrry annoying. Well after reading on the forums I found out that integrated projects actually have an “offline” mode built in and by right clicking on an offline solution node in the solution explorer tree you can select the “Go Online” command which will reconnect you to the server. What’s cool is that it actually keeps track of your offline edits, adds and deletes and will prompt you to check out the items when you go online! This is really cool, it effectively solves the offline problem of TFS integrated source control. Now I’d say SVN only has one advantage.

Of course in Visual Studio 2008 pre SP1 there is a bug here, and if I had some feedback for the TFS team I would reccommend that they either automatically “Go Online” when a bound solution is opened and the machine is connected or have some sort of icon somewhere to attract attention to the fact that this feature even exists. I have a feeling it’s been there for a while but I simply didn’t know about it. Maybe give the solution node a “disconnected” icon? Maybe keep all of the regular source control icons still? Something here is a little unintuitive.

So the tip of the day is if you’re working on your laptop with a TFS project and you suddenly go offline, don’t worry! Next time you’re online just right click your solution and select “Go Online” and you’re back in business.

Lang.NET 2008 Wrap Up

I’ve recently returned from a trip to Redmond. I was at the Lang.NET conference sponsored by Microsoft. Overall it was great. Microsoft took care of us like royalty and the people and conversations were incredible. With all the big brains around I felt even more retarded than normal, I was definitely an amateur compared to a lot of the people who were attending. The only thing that was unfortunate was that I managed to get a cold just before going out there, which was mild at first, but caused me to miss out on a lot of the free beer supplied (and lots of breweries I haven’t had a chance to try out yet too!) as well as miss the 3rd day entirely! I was really looking forward to seeing the VSX presentation and get a chance to talk to someone about NBusiness and get some integration questions I have been kicking around answered. Also, based on the description of Don Box’s speech I’m really sad to have missed that.

I met a guy there named Ted Neward. He was going to hook me up with a chance to meet with Ken Levy to talk about VS integration. I had to miss it because I was too sick and had completely lost my voice but I have his email address and will probably be sending him an email with a few questions and ideas.
 
Besides Jason Bock and I there were at least two other people from Minneapolis, Wez Furlong from the PHP group as well as Charles Nutter who works on JRuby for Sun. There was another guy there from Sun named John Rose who had a lot of interesting things to say about the similarities between Java and .NET and also knew a lot about creating programming languages. He talked about a lot of interesting things with me at the Rock Bottom brewery. It’s really encouraging to see that it’s possible to collaborate and discuss topics such as programming languages even between competitors. It seems that programming languages might just unite nerds more than divide them after all.
Overall I’d say that this symposium really revealed an intense focus towards dynamic languages right now. Perhaps it’s just the language enthusiasts who are the most interested in dynamic languages. This was an overwhelming focal point for this event. It’s all very cool stuff and I’m completely sold on the idea of using a dynamic language for developing unit tests first then writing your application. I’m not completely sold on the idea of a dynamic language everywhere however. It seems like it’s perfect for the top tier of an application, where things change the most and need to be the most flexible, but the lower you go a nice strongly typed library with strict encapsulation is probably preferable.
I was able to see Anders Hejlsberg (C#), Jim Hugunin (Iron Ruby and the DLR), Erik Meijer and many others speak. The videos should be on Channel 9 any day now. Here is a channel9 interview that took place with some of the speakers called Erik Meijer, Gilad Bracha, Mads Torgersen: Perspectives on Programming Language Design and Evolution but this was not one of the actual presentations. I also recognized John Lam (Iron Ruby) and Miguel De Icaza (Mono) in the audience but I missed their talks because I was sick.
One other interesting thing was getting to talk to a guy from Intentional Software. Now this is real brain bending stuff and if you haven’t heard of intentional programming before I suggest you go look it up because it’s a fascinating idea… probably best left for another post.