C# 3.0 new features

Miksu

Regular
Noticed this at GameDev. Sahil Malik is keeping a good blog about C# 3.0's new features. You can find the direct list from Gamedev right here.

This far these features have been introduced:
- Implicitly Typed Local Variables "var"
- Anonymous Types
- Extension Methods
- Lambda Expressions
- Object and Collection Initializers
- (LINQ) Query Expression Translation (to C# 3.0)
- Expression Trees

LINQ is so sweet!
 
Many of these features look like they've been lifted straight out of traditional functional languages in the OCaml/Haskell vein and shoehorned into a syntax that looks less intimidating to C-family-language programmers. LINQ itself looks like syntactic sugar on top of these features; its main asset over ordinary functional programming appears to be readability and familiarity to people familiar with SQL-like query languages.
 
LINQ sucks. Most of those other features have been available in other languages, and in Java we have Groovy, JSR-241. Extension methods == Groovy Categories. Lambda = Groovy Closures (but not as powerful). Query syntax = Groovy GPath/Criteria API/Builders. Duck typing? Check. There are already libraries that provide SQL style abstractions for other datamodels. Groovy is a superset of Java and goes further by providing meta-programming facilities.

Microsoft's approach to language design is interesting to say the least: Kitchen Sink. Java has avoided tossing all of these features in (which routinely are proposed by voted down by the community) because Java developers want to avoid a kitchen sink. About the only future feature I think that will make it into Java is closures (similar to C# lambdas).

Java isn't going to die for precisely the reason that the language is avoiding a rush to featuritis. Although there is a really dumb proposal for Java 7 flowing around to include XML literals integrated into the language just like strings. C++'s language spec was so damn complicated that few vendors could muster a marginally compliant compiler for years.

I prefer a clean and simple language with powerful building block components. Look at Scheme. Deceptively simple, yet still way more powerful and expressive than C# 3.0. C# still has nothing to compare to Scheme's macro facility for example.
 
Back
Top