views:

123

answers:

3

So, C# 4.0 came out yesterday. It introduced the much-debated dynamic keyword, named and optional parameters. Smaller improvements were the implicit ref and recognizing of indexed and default properties on COM methods, contra- and co-variance (really a .NET CLR feature, not C# only) and...

Is that really it? Are dynamic and optional/named params the only real improvements to C#? Or did I miss something? Not that I'm complaining, but it seems a bit meager after C# 2.0 (generics) and C# 3.0 (lambda, LINQ). Maybe the language just reached actual maturity?

A: 

I would suggest buying a textbook. I'm working my way through Visual Studio 2010 Step By Step by John Sharp, looking for new features and stuff I did't know. It's a great series of books, I'd recommend picking it up.

SLC
Sounds like you mean with "new features" means "features I didn't know of before that were already there for a long time". I mean, features introduced in C# 4.0. And unfortunately, the definitive reference on C# 4.0 by O'Reilly does not have a section "what's new".
Abel
It does, which is why I said new features _and_ stuff I didn't know.
SLC
+3  A: 

That's almost it, yes. There are some very minor changes around locking and events, but usually those won't be noticeable. For the event changes, see Chris Burrows' blog series; for locking see Eric Lippert's blog. In short, locking is now more reliable - it uses a new overload of Monitor.Enter so that it can detect whether the lock was acquired even in the face of asynchronous exceptions. Field-like events are now lock-free, and referring to a field-like event accessor (add/remove) in the declaring class will refer to the event rather than the field.

It's definitely a smaller set of changes than 2 and 3, but I think that's a good thing in many ways - I think devs need a certain amount of time for the current features to "bed in". Both 2 and 3 were really big feature releases... and some of those features still aren't really widely understood, IMO.

I'm sure that won't be the end of C#'s evolution - I've got some ideas, so I bet the C# team has rather more - but there's only so much that can be packed into one release. Although I suspect most developers won't actually use dynamic typing very often, it's a huge change in terms of the language itself, IMO - a very complex thing to get right. I'm not surprised the team didn't have much time to create many more features in the same release cycle.

Don't forget there was VS2010 to work on too, integrating all the new features into that and working on the pretty significant changes to Visual Studio itself.

One thing that's worth mentioning is that although covariance and contravariance are definitely CLR features - and indeed have been since CLR v2.0 - they're still language and library features, just like generics and nullable value types spanned CLR, framework and language.

Jon Skeet
Hi Jon, good to see you here ;-). Can you elaborate on the locking and events changes a bit, or refer to an online reference? Were they added to support the PLINQ and TPL features?
Abel
@Abel: Will edit the answer.
Jon Skeet
Thanks for the update, while small, it's good and important news. About new suggestions, among others, I've always missed support for delegates to gettors and settors (while possible, getting them is clumsy). Would you happen to know whether VB's dynamic typing received the same attention as C#'s dynamic keyword in terms of delegates and caching (http://stackoverflow.com/questions/2628424/has-object-in-vb-2010-received-the-same-optimalization-as-dynamic-in-c-4-0)?
Abel
@Abel: I'm afraid I don't know about that, sorry :(
Jon Skeet
+1  A: 

There is a list of changes here.

Mr Roys
Which apparently lists what I listed above. Well, if that's it then that's it :)
Abel