Mad, Beautiful Ideas
MSDN Tech Session: VS 2008 and Silverlight

Today I journeyed up to Spokane with some guys from work to attend a MSDN Tech Session about some of the new stuff in Visual Studio 2008, .NET 3.5 and Silverlight. The talk was presented by Mithun Dhar; a Developer Evangelist for Microsoft, and Mark Michaelis, a Systems Architect from Spokane who seems to do a fair amount of this kind of thing for Microsoft.

I was initially interested in attending for the talk on Silverlight. nbsp; VS2008 doesn't run on Linux, and Mono doesn't quite have .NET 2.0 support done, so 3.5 seems like a little ways away. nbsp; While I wasn't impressed enough to change my heathen ways, Microsoft has done some very important things in VS2008, and some of the new features in .NET 3.5 really seem interesting. nbsp; Silverlight (or should I say Moonlight?) does stand to be one of the more revolutionary web technologies to be discussed in recent times.

But let's start where todays talk did. nbsp; Visual Studio 2008. nbsp; As I said, I wasn't overly interested in this talk, since I'm not going to use it at home, and I'm not sure we'll be using it at work any time soon. nbsp; There doesn't seem to be too much that's new in this version. nbsp; Improved Intellisense, Intellisense for Javascript, a split-mode for web design (I'm pretty sure Dreamweaver has done this for several versions), a slew of new modes, and of course support for all the fancy new .NET 3.5 features. nbsp;

However, none of these were really enough to make me interested. nbsp; It seems Microsoft has finally decided that a good Javascript debugger is worth having, and integrating it with a web browser is important. nbsp; So, Visual Studio can now debug Javascript as if it were any other program. nbsp; It's pretty cool. nbsp; Plus, Mithun said that it works with Firefox and Opera in addition to Internet Explorer. nbsp; I'm not sure I believe that, but if it's true, that's really impressive for Microsoft. nbsp; This is definitely a place where Microsoft may have a win. nbsp; Venkman, the Firefox Javascript Debugger, is really not very user friendly, and neither it, nor Firebug

integrate well with any development environment I've ever seen. nbsp; I use Venkman and Firebug regularly, but the VS2008 Javascript debugger looks much, much easier to use. Of course, it won't work on Linux, so I'm going to be sticking with Venkman and Firebug, but I do hope someone can implement something like that feature in MonoDevelop or something else.

.NET 3.5 has some pretty interesting features slated for it's release, or shortly afterward. nbsp; First up, is Extension Methods. nbsp; Extension Methods allows a developer to tell the compiler to functionally add a method to a class, without actually modifying the class. nbsp; An example given was adding a Capitalize() method to the String class, which would convert all the letters in a string to upper case. nbsp; This is a technology that I can see being hugely useful, and the Syntax is pretty clear, for instance, for the previous example:

static class MyExtensions {
 nbsp; nbsp; nbsp; public static string Capitalize(this string input)
 nbsp; nbsp; nbsp; {
 nbsp; nbsp; nbsp;  nbsp; nbsp; // Modify Input in here to convert it all to uppercase.
 nbsp; nbsp; nbsp; }
The key to this is the new "this <object>" where <object> is the object or interface, you're adding the Extension Method to, in this case, string. nbsp; Scott Guthrie has a lot more to say about this subject, and this blog post

is probably much better reference than anything I could write right now. nbsp; In .NET 3.5 Microsoft uses Extension Methods to extend classes if certain features are enabled. nbsp; For instance, if you're using LINQ, which I'll discuss next, several Extension Methods, such as Where, are added to IEnumerable to extend it's functionality, without redeclaring IEnumerable. nbsp;

In some cases this makes a lot of sense. nbsp; If you only need to add a method or two, and the changes have a limited usefulness, they appear to be an invaluable tool. nbsp; I even suspect there is almost no overhead, since the linking of the extension method could simply occur at compile time. nbsp; However, I fear there will be times when people will simply write a handful of extension methods, when it really makes more sense to extend a class. nbsp; I'm afraid this may lead to more confusion down the road for people maintaining software, as some people will have needlessly and recklessly extended classes. nbsp; However, this may be more of an issue of poor coding standards than ill-conceived features.

The next new language feature we discussed were .NET Language INtegrated Queries (LINQ). nbsp; The reason LINQ is so amazing, is because it always a user to execute SQL-like statements against any

collection. nbsp; Often times, it will be used when querying a database object, but the really cool thing I saw was that it would allow you to select a subset of any IEnumerable object based on selection criteria. nbsp; As a trivial example, consider the following:

ArrayList data; // Initialized with random numbers

Foreach var number in (from data
 nbsp; nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp; nbsp; where value % 2 == 0
 nbsp; nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp;  nbsp; nbsp; nbsp; select value)
 nbsp; nbsp; nbsp; // Do something with even values in data
As an example, this is pretty lame, I'll admit, but it demonstrates the basic idea. nbsp; You actually put in SQL-like queries to get only the data you really want from a collection. nbsp; Actually, the mashed-up SQL I didn't much care for, since it's confusing to all us SQL developers, but it's done to provide cues to Intellisense, so it can help prevent programming errors. nbsp; Plus, you can use Lambda Expressions in the where clause, to provide even more power in the selection. nbsp;

Another new feature I use above is the 'var' syntax. nbsp; No, C# does not have VBScript style Variants. nbsp; It is still a strongly-typed language, but if you don't know the type of a returned variable off the top of your head, you can just use 'var', and the compiler takes care of it for you. nbsp; I feel kind of strange about this feature, since it seems so pointless. nbsp; At least in the Boo programming language, Duck Typing

is actually a variable type. nbsp; The use of the var keyword in this case seems to encourage laziness. nbsp; One of the guys I traveled with did point out one decent use, and that was when you were instantiating a class, and the type was already on the right hand side of the statement.

 nbsp;The last new Language Feature ties in with LINQ, but it's kind of an extension. nbsp; Microsoft calls it LINQ for Entities (codename: Astoria). nbsp; Basically, it's the LINQ interface I was talking about, except instead of calling the Database directly, or another IEnumerable object, you create an Entity-map of your data. nbsp; This is used by .NET to automatically turn your relational-database rows into custom Objects, where you can access and change your data through properties (presumably this can be configured somewhat in the Entity definition). nbsp; Plus, you build the relationships between objects. nbsp; For instance, in an e-commerce application, you would have a list of Customers. nbsp; Each Customer can have a list of Orders, and each Order would have a list of Products on that Order. nbsp; All of this is managed in Objects, and collections, allowing you, as the developer to abstract the data in a way that is more logical for the programming language you're using. nbsp;

Pretty cool. nbsp; Still, I'd rather just have an Object-Relational Database, but this is still a good step. nbsp; Unfortunately, it abstracts the loading into many, many calls into the database, so there are some potential performance issues a developer will need to keep in mind.

And then there was Silverlight. nbsp; Silverlight is Microsoft's new Flash competitor. nbsp; Unfortunately, Silverlight 1.0 is kind of lame. nbsp; That's not completely fair, since XAML can be used to create some fairly complex visual effects, and some Javascript-based interface tweaks that can look pretty nice, but for the most part, it's pretty basic effects. nbsp; Silverlight 1.1, which isn't due out until next year sometime, adds the ability to embed .NET code into the package. nbsp; This is going to be huge. nbsp; Microsoft has really been pushing the video aspect of SIlverlight, and to be honest, it's nice. nbsp; It does 720p natively, and does a good job of scaling it, if it isn't available. nbsp; It has good support for SVG overlays, so you can easily add watermarks, subtitles, etc. to playing video. nbsp; Plus, it just runs well. nbsp; One of the demos was playing a video with a jigsaw pattern cut into it, and then he could scramble the puzzle, so it could be reassembled. nbsp; The pieces kept playing their part of the video. nbsp; It was just amazing. nbsp; I'm going to have to look into helping Mono get Moonlight up and running. nbsp; It's just going to be too cool.