Your SlideShare is downloading. ×
The Future of C# and Visual Basic
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

The Future of C# and Visual Basic


Published on

More info on

More info on

Published in: Technology
1 Comment
  • 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.
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

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<T> introduced in .NET 4WinRT’sIAsyncOperation<T> 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<T>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
  • Transcript

    • 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. varvar
    • 3. var data = DownloadData(...);ProcessData(data);var
    • 4. Task<T> IAsyncOperation<T>
    • 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. Demo
    • 7. async void Task<T>await
    • 8. Demo
    • 9. __FILE__ and __LINE__ macros in C#?
    • 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. 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. 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. Language Service Compiler APIsCompiler Pipeline Metadata Import
    • 14. Demo