Future of C#
New and exciting functionality is coming our way with C#4. The dynamic programming support being the most interesting of all, along with “Compiler as a Service” approach, which I am hoping to see in not too distant future. Continuing the trend from my previous two posts, here are the notes I made while watching the PDC presentation by Anders Hejlsberg.
- Declarative programming = Less of how it should be done and more of what should be done as compared to Imperative programming which is the opposite
- C#4
- Major feature is dynamic programming
- Talking to anything that is not a .NET class
- Innovations
- Dynamically typed objects
- Optional and Named parameters
- Improved COM interoperability
- Co- and Contra-variance
- .NET Dynamic Programming
- DLR
- Expression Trees
- Dynamic Dispatch
- Call Site Caching
- Object binders allow communication with .NET, Silverlight, Python, Ruby and Office
- DLR
- Declaring dynamic types in C#4
- New keyword ‘dynamic’
- dynamic car = GetCar();
- So things can be statically typed to be dynamic
- Dynamic conversion when you are using dynamically typed objects
- Anything can be assigned to a dynamic type
- Member type gets differed to runtime type
- How does this work under the hood
- Objects implement IDynamicObject
- Optional and Named Parameters
- You can default values in method parameters making them optional
- You can specify the named parameter in the method call e.g. Car.GetTyre(1, tyreType: “Back”)
- Improved COM Interoperability
- Automatic object > Dynamic mapping. This will automatically convert objects to dynamic.
- Optional and named parameters
- Indexed properties
- Optional “ref” modifier
- Interop type embedding (“No PIA”): Primary interop assembly
- No more ref.missing
- Co- and Contra-variance
- Generics have been invariant
- C# supports co-variance but not safe co-variance
- C#4 you can specify ‘in’ or ‘out’ parameters for co and contra variance
- out = co-variant, can be treated as less derived
- in = contra-variant: Input precision only, can be treated as more derived
- Compiler as a service
- Opening up the compiler
- Meta – programming
- Language Object Model
- DSL Embedding
- Compiler as an API
- Bad news:Dont know when this will ship
No comments yet
Leave a reply




