//build – Future Directions of C#

Anders Hejlsberg talk at build was as expected very good, my notes and thoughts:

What’s new in C# 5.0:

  • Windows Runtime Support
  • Asynchrony (async / await keywords)
  • Caller Info attributes

Asynchrony Programming:

  • Clearly there are lots of scenarios where async execution of methods is desirable, in the context of WinRT implementing polished Metro style apps that don’t block the UI requires work to be done off the UI thread, just as it does in any GUI apps. Of course UI scenarios are not the only ones that require async work!
  • Apparently 10 to 15% of the WinRT API’s are asynchronous so clearly MS has thought these through in the context of making it easy to build responsive UI’s
  • The async programming models vary across languages, for example: 
    • WinRT (C++): IAsyncOperation<T>
    • .NET: Task<T>
    • Javascript: Promisses
  • So, when writing C# libraries to be exposed for WinRT Task’s need to be converted to / from IAsyncOperation’s, the platform provides helpers to do this conversion

Caller Info attributes:

  • Not in developer preview, but will be in the final bits
  • Anyone whose done any C++ will probably have used the __FILE__ and __LINE__ macros, caller info attributes can be used for the scenarios where these macros would have been used
  • C# 5.0 introduces 3 new caller info attributes:
    • CallerFilePath
    • CallerLineNumber
    • CallerMemberName
  • At runtime the values get substituted in, these are especially useful for tracing/logging scenarios

Project Roslyn: ‘Compiler as a Service’

  • No ship vehicle / date set yet, but CPT will be release in ~4 weeks
  • The purpose of Roslyn is to opening up the compiler, making the compilers information available
    • Meta-programming
    • DSL Embedding
    • Refactoring
    • etc
  • The compiler APIs exposed broadly map onto the compiler pipeline:
    • Syntax Tree API (Parser)
    • Symbol API (Symbols, Metadata Import)
    • Binding and Flow Analysis APIs (Binder)
    • Emit API (IL Emitter)
  • Roslyn ships with a C# Interactive Window in VS – this will be included in CTP, and allows code to be dynamically created and executed in a similar manner to the F# interactive window, which is a very powerful exploration tool
  • Anders did a great demo to show off some of the potential power of Roslyn where he copied C# code and pasted it into a VB project – the code was converted to VB and pasted, likewise he then round tripped it and copied VB code and pasted it as C#

~ by kevinsmi on September 17, 2011.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: