C# 5.0 + VB 11.0                                           Windows Runtime + Asynchrony              C# 4.0 + VB 10.0     ...
varvar
var data = DownloadData(...);ProcessData(data);var
Task<T>  IAsyncOperation<T>
public async Task<XElement> GetXmlAsync(string url){    var client = new HttpClient();    var response = await client.GetA...
Demo
async        void   Task<T>await
Demo
__FILE__ and __LINE__ macros in C#?
public static class Trace{    public static void WriteLine(string message,        [CallerFilePath] string file = "",      ...
C# 5.0 + VB 11.0                                           Windows Runtime + Asynchrony              C# 4.0 + VB 10.0     ...
ClassMeta-programming                              Read-Eval-Print Loop                   public               Foo    Lang...
Language Service   Compiler APIsCompiler Pipeline   Metadata                     Import
Demo
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
The Future of C# and Visual Basic
Upcoming SlideShare
Loading in …5
×

The Future of C# and Visual Basic

2,905 views

Published on

More info on http://www.techdays.be

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • The future of C# and Visual Basic seems to be open source. Strange that Microsoft won't even answer the calls to open source the VB6 programming language. Yet VBA programming is supported in Office.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total views
2,905
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
41
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide
  • Bart De SmetDeveloper in the SQL division working on asynchronousevent processing systemsHere to talk about future directions in C# and VB
  • Brief agendaVersions of the languages included in VS 11
  • Pretty long history with managed languagesIt’s been 11 yearsReleases had a theme to them…Language parity – theme we’re continuingToday: support for the Windows Runtime and asynchronous programmingDrill into it
  • Parity!Little feature we squeezed in caller info attributesVB 11 more parity with iterators
  • Asynchronous programming is becoming the normReason it’s important: tablet form factors, touch, responsive UIAsync programming one of the best ways to ensure responsivenessInstead of waiting for return, which could take a long time, spinning toilet bowlsSpecify callbackInterim, app can do other things on the message loopRule of thumb in the WinRT – operation more than 50msLook through the WinRT library code base – how many entry points are async? 10-15% high or not? Tend to be the core operations (the file I/O, the network I/O); rest is setting up properties etc.No matter what you do in your WinRT app, you’ll deal with async
  • Different ways to represent asynchrony:Task&lt;T&gt; introduced in .NET 4WinRT’sIAsyncOperation&lt;T&gt; interfaceJS promisesObject that represents the operationCan ask for the status, for the result (some cases block)Can also tell the object the callback to continue with when the operation is doneProgress is made through callbacksChallenge – tend to turn code inside out; lambda/function; if you have a loop it gets crazyInsight: possible to automatically transform code in callback styleResearch in CPS programmingEvery programing can be transformed to CTPCommon in certain functional programming languagesWe leverage this insightAsync methods basically use the compiler to transform normal code in callback based state machine
  • Just looks like regular old method – client, string, parse, return XMLFew things stand out:Async modifier: required to return void or Task&lt;T&gt;Modifier enables to await other asynchronous operationsWhen you hit the await operator; compiler transforms the rest of the method into a callback that it makes the continuation of the GetAsync callThis is in principal what happens (ignoring exception handling etc.):Allocate factory of taskRun up to first awaitMake a lambda out of the rest of the methodAttach it to the async operation you’re awaitingImmediately return a task representing ourselvesWhere the method had a return statement, we stuff the result into the taskCascading effect
  • Async methods don’t start threads – way of composing asynchrony, not about creating asynchrony as such (orchestrating execution)The asynchrony itself comes from the lowest level function – I/O completion port, etc. yield back to the app, runs the continuation
  • The Future of C# and Visual Basic

    1. 1. C# 5.0 + VB 11.0 Windows Runtime + Asynchrony C# 4.0 + VB 10.0 Dynamic + Language Parity C# 3.0 + VB 9.0 Language Integrated Query C# 2.0 + VB 8.0 GenericsC# 1.0 + VB 7.0 Managed Code
    2. 2. varvar
    3. 3. var data = DownloadData(...);ProcessData(data);var
    4. 4. Task<T> IAsyncOperation<T>
    5. 5. public async Task<XElement> GetXmlAsync(string url){ var client = new HttpClient(); var response = await client.GetAsync(url); var text = response.Content.ReadAsString(); return XElement.Parse(text);} public Task<XElement> GetXmlAsync(string url) { var tcs = new TaskCompletionSource<XElement>(); var client = new HttpClient(); client.GetAsync(url).ContinueWith(task => { var response = task.Result; var text = response.Content.ReadAsString(); tcs.SetResult(XElement.Parse(text)); }); return tcs.Task; }
    6. 6. Demo
    7. 7. async void Task<T>await
    8. 8. Demo
    9. 9. __FILE__ and __LINE__ macros in C#?
    10. 10. public static class Trace{ public static void WriteLine(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0, [CallerMemberName] string member = "") { Console.WriteLine(string.Format("{0}:{1} – {2}: {3}", file, line, member, message)); }} void Initialize() { Trace.WriteLine("Starting services"); … } Trace.WriteLine("Starting services", "c:sourcesfoo.cs", 1123, "Initialize");
    11. 11. C# 5.0 + VB 11.0 Windows Runtime + Asynchrony C# 4.0 + VB 10.0 Dynamic + Language Parity C# 3.0 + VB 9.0 Language Integrated Query C# 2.0 + VB 8.0 GenericsC# 1.0 + VB 7.0 Managed Code
    12. 12. ClassMeta-programming Read-Eval-Print Loop public Foo Language Field DSL Embedding Object Model private X string Source .NET File Source code Assembly Source code Source code Compiler Source code
    13. 13. Language Service Compiler APIsCompiler Pipeline Metadata Import
    14. 14. Demo

    ×