I haven’t spent a lot of time reviewing C# 3.0, but to say that it has left me pleasantly surprised would be an understatement. A better descriptor might be: “Shock and Awe”.
It looks like C# will some day include:
- Lambda Expressions: create functions on the fly with syntax like
names.Select( n => n.toUpper() )
- Expression Trees: limited, run-time inspectable expressions
- Extension Methods: dynamically add methods to types
- Object Initialization Expressions: initialize a complex object with syntax like
new Person { Name="Allen Frances", Age=11, CanCode=false }
- Anonymous Types: Create a person-like object with
new { Name="Allen Frances", Age=11, CanCode=false }
- Local Type Inference: types of variables are inferred from the value they are initialized to by using the var keyword, eg
var s = "inferred as a string". This also allows variables to be set to an inferred anonymous type.
- Query Syntax: syntax sugar that combines all of the features listed above (and more) to make querying data far easier.
Believe me; I am aware that MS often fails to provide promised features in many of their products. Regardless, I am excited that Microsoft has apparently recognized the usefulness of these features. Even if all of these features make it into C# 3.0, it will still be lacking in flexibility and power compared to languages that have been available for decades. But when compared to C# 1.0, these features are truly shocking.
[See The LINQ Project Overview (.DOC format) for more information.]
* * *
- If any of my (multitude of) readers is aware of any examples that make use of Expression Trees or articles that discuss them, I would really, really appreciate your adding a comment describing and/or linking to it.
Thanks so much!
— Jared Nuzzolillo Sep 19, 12:49pm #
- If you like these things Nemerle might be your ballpark.
— Erik Arvidsson Sep 19, 3:29pm #
- Hey Erik; thanks for the advice.
I am less excited about the features themselves and more excited about these developments in C# for two reasons:
# Microsoft is admitting that these features are helpful. When I try to convince someone why, eg, a simple closure syntax is beneficial, it will be easier if MS is behind the idea.
# When I am forced to use a “commercial language” at work (which is most of the time), it won’t be quite as painful as MS starts implementing these features that I am already used to using in my free time.
I am passingly familiar with Nemerle already; it seems to be a really nicely designed language, but I generally favor dynamically typed languages (Ruby, javascript, Io etc). I haven’t really spent enough time writing “functional” code to know whether I would prefer to use it. The same goes for a statically typed language with good type inference. Maybe I should write a short project in Nemerle just to get the hang of it.
Lately, I have been playing around with Squeak/Seasise and just a little with Lisp. Developing applications with Seaside is a real pleasure, but I think my heart belongs to Io and Ruby, at least for now.
Have you seen Io ? It’s really impressive!
— Jared Nuzzolillo Sep 20, 9:30am #