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.

was initially interested in attending for the talk on Silverlight. 
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.  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.  Silverlight (or should I say Moonlight?) does stand to be one of the more revolutionary web technologies to be discussed in recent times.

let's start where todays talk did.  Visual Studio 2008.  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.  There
doesn't seem to be too much that's new in this version.  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. 

none of these were really enough to make me interested.  It seems
Microsoft has finally decided that a good Javascript debugger is worth
having, and integrating it with a web browser is important.  So, Visual
Studio can now debug Javascript as if it were any other program.  It's
pretty cool.  Plus, Mithun said that it works with Firefox and Opera in
addition to Internet Explorer.  I'm not sure I believe that, but if
it's true, that's really impressive for Microsoft.  This is definitely
a place where Microsoft may have a win.  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.  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

.NET 3.5 has some pretty interesting features slated for
it's release, or shortly afterward.  First up, is Extension Methods. 
Extension Methods allows a developer to tell the compiler to
functionally add a method to a class, without actually modifying the
class.  An example given was adding a Capitalize() method to the String
class, which would convert all the letters in a string to upper case. 
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 {
    public static string Capitalize(this string input)
       // Modify Input in here to convert it all to uppercase.
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.  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.  In .NET 3.5 Microsoft uses Extension Methods to extend classes if
certain features are enabled.  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

In some cases this makes a lot of sense.  If you
only need to add a method or two, and the changes have a limited
usefulness, they appear to be an invaluable tool.  I even suspect there
is almost no overhead, since the linking of the extension method could
simply occur at compile time.  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.  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.  However, this
may be more of an issue of poor coding standards than ill-conceived

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

collection.  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. 
As a trivial example, consider the following:

ArrayList data; // Initialized with random numbers

Foreach var number in (from data
                                      where value % 2 == 0
                                      select value)
    // Do something with even values in data
an example, this is pretty lame, I'll admit, but it demonstrates the
basic idea.  You actually put in SQL-like queries to get only the data
you really want from a collection.  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.  Plus, you can use Lambda Expressions in the where
clause, to provide even more power in the selection. 

new feature I use above is the 'var' syntax.  No, C# does not have
VBScript style Variants.  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.  I feel kind of strange about this feature, since it seems so
pointless.  At least in the Boo programming language, Duck Typing

is actually a variable type.  The use of the var keyword in this case
seems to encourage laziness.  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.

last new Language Feature ties in with LINQ, but it's kind of an
extension.  Microsoft calls it LINQ for Entities (codename: Astoria). 
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.  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). 
Plus, you build the relationships between objects.  For instance, in an
e-commerce application, you would have a list of Customers.  Each
Customer can have a list of Orders, and each Order would have a list of
Products on that Order.  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. 

Pretty cool.  Still, I'd rather just have an Object-Relational
Database, but this is still a good step.  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.

then there was Silverlight.  Silverlight is Microsoft's new Flash
competitor.  Unfortunately, Silverlight 1.0 is kind of lame.  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.  Silverlight 1.1, which isn't due out until next year
sometime, adds the ability to embed .NET code into the package.  This
is going to be huge.  Microsoft has really been pushing the video
aspect of SIlverlight, and to be honest, it's nice.  It does 720p
natively, and does a good job of scaling it, if it isn't available.  It
has good support for SVG overlays, so you can easily add watermarks,
subtitles, etc. to playing video.  Plus, it just runs well.  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.  The pieces
kept playing their part of the video.  It was just amazing.  I'm going
to have to look into helping Mono get Moonlight up and running.  It's
just going to be too cool.