Comments on C# 4.0 and .Net 4.0

January 7th, 2009 by jason Leave a reply »

The C# team at Microsoft keeps churning out new versions. They recently released a Community Technology Preview of C# 4.0 with .Net 4.0 and Visual Studio 2010. The bits are here if you want to download this preview in the form of a Microsoft Virtual Machine. The download, or I should 8 downloads, are huge; 7 X 700 MB + 1 x 286 MB.

I got the VM up and running and I immediately jumped into VS 2010. I don’t have much of an opinion on that subject. For the most part it looks and feels like a spiffy version of VS 2008.  It is pretty obvious it is written in WPF.

The release of C# 4.0 introduces 4 groups of changes to the languages (get it, 4).

  1. Compile-time and run-time dynamic type handling,
  2. Named arguments and default argument values,
  3. Variance, meaning covariance and contra-variance,
  4. Better COM support.

Along with these buckets of C# features, .Net 4.0 is expected to support the functionality in the Parrallel FX Library and perhaps ASP.Net MVC.  Here are some quick opinions/rants on the new features.

  • Dynamic types: When I first heard about this feature I thought it was stupid.  After seeing how it is implimented and watching the videos (One, Two) I am excited.  I can see where this type would have made my life much easier in the past in a few ways.  First, this type will work well with the new Office integration.  I vividly remember programming against version X of some Word interop, and having that code *not* work on version Y.  The dynamic type should handle those situations, assuming the portions of the API being used look the same.  Second, this will allow two .Net types that have some of their function singnatures the same but do not share a common ancestor or impliment a common interface to be treated polymorphically at run-time.  Third, interop with scripting will be easier.  And, this type will perform better than reflection.  See Dynamic Language Runtime aka DLR for more info on some of the plumbing the type will be using.
  • Named arguments and default values:  Whatever.  I have gotten by without these for years.  I have used them in other lanuages, and did not miss them when I moved to C#.  I don’t need them now.
  • Variance:  It would be great if they actually implemented really covariance and contra-variance for types like List<T>, but they aren’t.  The implementation in the current beta sucks.  It is cumbersome.  I would go so far as to call it stupid.  Come on guys!   You have done such a great job until now; don’t crap on C# now with this junk.  Does it sound like I am being melodramatic?  Well, its because it is fucking stupid the way this is implimented in the CTP.  That might be the first time I have ever cursed on my blog, and it was for a good reason.
  • Better COM Interop: As much as we would all like COM to go away, it isn’t going anywhere soon.  Better interop with COM is a good thing.
  • Parrallel FX: Very cool threading library.  Me likey.
  • ASP.Net MVC: Whether this gets released before hand or with .Net 4.0, who knows.  But having played around with it in the various CTP/beta releases, I do like it.

So there you go.  Hopefully MS will fix the pathetically moronic impimentation of variance they are proposing and release the best version of C# yet!  I am really looking forward to the future betas.  .Net has been a great platform to program on, and it just keeps getting better.

Advertisement

Leave a Reply

You must be logged in to post a comment.