Upload
evan-kelley
View
230
Download
0
Tags:
Embed Size (px)
Citation preview
www.buildwindows.com
Future directions for C# and Visual Basic
Anders HejlsbergTechnical FellowMicrosoft Corporation
TOOL-816T
www.buildwindows.com
Agenda
• What’s new in C# 5.0 and VB 11.0?• Asynchronous Metro style C#/VB applications• Hybrid C#/VB and Javascript applications• A look into the future: The Roslyn project
www.buildwindows.com
C# and VB evolution
Managed Code
Generics
Language Integrated Query
Dynamic + Language Parity
C# 5.0 + VB 11.0Windows Runtime + Asynchrony
C# 1.0 + VB 7.0
C# 2.0 + VB 8.0
C# 3.0 + VB 9.0
C# 4.0 + VB 10.0
www.buildwindows.com
What’s new?
C# 5.0
• Windows Runtime support• Asynchronous programming• Caller info attributes
VB 11.0
• Windows Runtime support• Asynchronous programming• Caller info attributes• Iterators
www.buildwindows.com
Asynchronous programming is becoming the norm in modern,
connected applications
www.buildwindows.com
Asynchronous programming models
• Windows Runtime: IAsyncOperation<T>• .NET Framework: Task<T>• Javascript: Promises• All are objects representing “ongoing operations”• All use callbacks to signal completion of operation• Challenge: Callbacks turn your code inside out• Insight: Automatic transformation to callbacks is
possible
www.buildwindows.com
Asynchronous methods automatically transform normal code into a callback
state machine
Asynchronous methods
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;}
www.buildwindows.com
Metro style asynchrony
demo
www.buildwindows.com
Asynchronous methods…
• Are marked with new “async” modifier• Must return void or Task<T>• Use “await” operator to cooperatively yield control• Are resumed when awaited operation completes• Can await anything that implements the “awaiter
pattern”• Execute in the synchronization context of their
caller• Allow composition using regular programming
constructs• Feel just like good old synchronous code!
www.buildwindows.com
C# and Javascript
demo
www.buildwindows.com
Caller Info attributes
__FILE__ and __LINE__ macros in C#?
Caller Info attributespublic static class Trace{ public static void WriteLine(string message, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0, [CallerMemberName] string member = "") { var s = string.Format("{0}:{1} – {2}: {3}", file, line, member, message); Console.WriteLine(s); }}
void Initialize() { Trace.WriteLine("Starting services"); ...}
Trace.WriteLine("Starting services", "c:\\sources\\foo.cs", 1123, "Initialize");
www.buildwindows.com
C# and VB evolution
Managed Code
Generics
Language Integrated Query
Dynamic + Language Parity
C# 5.0 + VB 11.0Windows Runtime + Asynchrony
C# 1.0 + VB 7.0
C# 2.0 + VB 8.0
C# 3.0 + VB 9.0
C# 4.0 + VB 10.0
www.buildwindows.com
Class
Field
public Foo
private
string
X
The Roslyn project
CompilerCompilerSource codeSource code
SourceFile
Source codeSource code
.NET Assembly
Meta-programming Read-Eval-Print Loop
LanguageObject Model
DSL Embedding
www.buildwindows.com
Roslyn APIs
Language Service
Compiler APIs
Compiler Pipeline Syntax Tree API
Symbol APIBinding and Flow
Analysis APIsEmit API
Form
atte
r
Colo
rizer
Ou
tlinin
g
Navig
ate
To
Ob
ject
Bro
wse
r
Com
ple
tion
List
Find
All
Refe
ren
ces
Ren
am
e
Qu
ick Info
Sig
natu
re
Help
Extra
ct M
eth
od
Go To
D
efin
ition
Ed
it an
d
Con
tinu
e
ParserMetadata
Import
Binder IL Emitter
Symbols
www.buildwindows.com
Visual Studio Roslyn CTP
announcing
www.buildwindows.com
Visual Studio Roslyn CTP
demo
www.buildwindows.com
Summary
• C# and VB deeply support the Windows Runtime
• C# and VB make asynchronous programming easy
• You can create hybrid C#/VB and Javascript apps
• Visual Studio Roslyn CTP will be available soon
www.buildwindows.com
For more information
• [PLAT-203T] Async everywhere: creating responsive APIs & apps
• [TOOL-531T] Using the Windows Runtime from C# and Visual Basic
• [SAC-804T] Building IIS and ASP.NET apps with the power of async
• [TOOL-810T] Async made simple in Windows 8, with C# and Visual Basic
• [TOOL-829T] The zen of async: Best practices for best performance
RELATED SESSIONS• Visual Studio Asynchronous
Programmingwww.msdn.com/vstudio/async
• What's New for Visual C# inVisual Studio 11 Developer Preview
• http://go.microsoft.com/fwlink/?LinkId=228087
• What's New for Visual Basic inVisual Studio 11 Developer Preview
• http://go.microsoft.com/fwlink/?LinkId=228088
DOCUMENTATION & ARTICLES
www.buildwindows.com
• Feedback and questions http://forums.dev.windows.com
• Session feedbackhttp://bldw.in/SessionFeedback
thank you
© 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.