The Future of VB and C# Lucian Wischik VB+C# language PM Microsoft Corporation Session Evaluations Tell us what you think, for Medecins Sans Frontiers! For each eval, I'll give $5 to MSF, and Microsoft will match $5. Outline The near future Async The distant future Compiler as a Service The near future of VB and C# C# vNext, VB vNext C#4, VB10 C#3, VB9 C#2, VB8 C#1, VB7 Async programming Co-evolution LINQ Generics Managed Code The near future of VB and C# C# vNext, VB vNext C#4, VB10 C#3, VB9 C#2, VB8 C#1, VB7 Async programming, ???, ???, ???, ??? Co-evolution, NOPIA, DLR, covariance, stmt-lambdas LINQ, lambdas, XML literals, type inference, extensions Generics, EnC, My, Disposing, partial, nullables, XML-comments Managed Code What is async? In the past… “Connected” has generally meant either a UI that freezes, or unmaintainable spaghetti code, or multithreading. C# and VB future: Async… A new easier way to write connected apps Two new keywords: Await and Async in VB and C# A new Task-based design pattern for APIs, the "T.A.P." (Task Asynchronous Pattern) A new set of .NET Framework APIs webClient.UploadString(uri); print("done"); “A waiter’s job is to wait on a table until the patrons have finished their meal. If you want to serve two tables concurrently, you must hire two waiters.” The following is from the Android dev blog. Can you spot the flaw? 1. “A good practice in creating responsive applications is to make sure your main UI thread does the minimum amount of work.” 2. “Any potentially long task that may hang your application should be handled in a different thread.” 3. “Typical examples of such tasks are network operations, which involve unpredictable delays.” How best to explain the sequence of events in a restaurant with several tables? From the perspective of the waiter? or of the patrons? try { string[] vidUrls = await ScrapeYoutubeAsync(url); Task<Video> t1 = DownloadVideoAsync(vidUrls(0)); Task<Video> t2 = DownloadVideoAsync(vidUrls(1)); Video[] vids = await TaskEx.WhenAll(t1, t2); Video v = await MashupVideosAsync(vids(0), vids(1)); await v.SaveAsync(textbox1.Text); } catch (WebException ex) { ReportError(ex); } // Network-bound // Start 2 downloads // Wait for both // CPU-bound // IO-bound TASK UNIFIES ALL THESE AREAS; ASYNC TIES THEM TOGETHER Use Async Functions to compose other tasks, for the “orchestration” of your app Co-evolution VB catches up: Iterators XNA Phone Async: was developed in both languages simultaneously The far future Compiler as a Service C# vNext, VB vNext C#4, VB10 C#3, VB9 C#2, VB8 C#1, VB7 Async Parity LINQ Generics Managed Code Compiler as a Service Dim connectionString = "server=.\sqlexpress;..." Using con = New SqlConnection(connectionString) con.Open() Dim cmd = New SqlCommand("GetSalesFormulas", con) Using reader = Await cmd.ExecuteReaderAsync() reader.Read() Dim formula As String = reader("vb").ToString() Dim result = Runtime.CompilerServices.Eval(formula) End Using End Using Class Meta-programming public Language Object Model Read-Eval-Print Loop Foo DSL Embedding Field private X string Source File code Source Source code Compiler .NET Assembly Source code Source code Other possible futures simpler INotifyPropertyChanged support and also Dependency Properties Sorry, we haven’t figured this one out yet... Oh, and check out F# F# had async before C#/VB Check out "F# type providers" Check out F# immutable programming PS. Download the Async CTP http://msdn.com/vstudio/async © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.