OK, OK, so C# 3.0 is only just out of the door. As anyone who has been reading my stuff for a while will have realized, I like what they've done with the language. Here at PH, we have now fully migrated all our solutions to Visual Studio 2008, and can now use C# 3.0 language and .Net 3.5 framework features everywhere they're useful. This makes me happy (though some annoying issues migrating to Web Deployment Projects 2008 decidedly aren't making me happy).
I haven't thought long and hard about what I'd really like in C# 4.0. I think I need C# 3.0 to settle in a bit more. I've used it quite a bit, but it takes a while to fully realize the power of all that is there, and I certainly don't want to start suggesting additions to the language when there is already a perfectly good solution to that problem.
There are many principles in programming language design. I'm quite heavily influenced by Larry Wall, designer of Perl, probably because I've listened to him talking about language design more than anyone else. One of the principles he has is known as huffmanization. Huffman coding is an approach to compression where you give the most frequently occurring things the shortest codes, so the things that occur most in the file you are compressing have the shortest representations. The analogy in programming language design is things that you do regularly should have a compact syntax, whereas things you do infrequently can be longer - because you do them less.
C# doesn't score badly overall alongside this principle generally, but there is one area that I really feel could use some improvement. How often do you write:
private string _Foo;
And then an accessor and mutator method:
public string Foo
{
get { return _Foo; }
set { _Foo = value; }
}
I find myself doing this a lot, and it's 6 lines of boilerplate (OK, only four lines if you ignore the braces, which don't have any understanding cost, but do take up screen space). By contrast, anonymous types let you declare fields and and accessors all in one go (and yes, I know it's a tad different).
What I'd really like is a way, in a single declaration, to declare an underlying private field with either protected, internal or public simple accessors. I'm not sure how it could look, or of some nice syntax for it. I guess an attribute could do it:
[Accessor("Foo", Scope.Public)]
private int _Foo;
Though that's still quite a bit to type. I've still not found any syntax to suggest that I like, though. Ideas, anyone? But anyway, I'd really like to see some improvement here. It's not a Big New Feature, but it would save a lot of trivial, boring code.