SlideShare ist ein Scribd-Unternehmen logo
1 von 34
The Future of C# TL16  Anders Hejlsberg 	Technical Fellow 	Microsoft Corporation
The Evolution of C# C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code
Trends
Declarative Programming What How Imperative Declarative
Dynamic vs. Static
Concurrency
Co-Evolution
The Evolution of C# C# 4.0 Dynamic Programming C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code
Dynamically Typed Objects Optional and Named Parameters Improved COM Interoperability Co- and Contra-variance C# 4.0 Language Innovations
.NET Dynamic Programming IronPython IronRuby C# VB.NET Others
 Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching PythonBinder RubyBinder COMBinder JavaScriptBinder ObjectBinder
Dynamically Typed Objects Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc = GetCalculator(); TypecalcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, newobject[] { 10, 20 }); int sum = Convert.ToInt32(res); ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res); Statically typed to be dynamic dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Dynamic method invocation Dynamic conversion
Dynamically Typed Objects Compile-time typedynamic Run-time typeSystem.Int32 dynamic x = 1; dynamic y = "Hello"; dynamic z = newList<int> { 1, 2, 3 }; When operand(s) are dynamic
 ,[object Object]
 At run-time, actual type(s) substituted for dynamic
 Static result type of operation is dynamic,[object Object]
Dynamically Typed Objects demo
IDynamicObject publicabstractclassDynamicObject : IDynamicObject { publicvirtualobjectGetMember(GetMemberBinder info); publicvirtualobjectSetMember(SetMemberBinder info, object value); publicvirtualobjectDeleteMember(DeleteMemberBinder info);   publicvirtualobjectUnaryOperation(UnaryOperationBinder info); publicvirtualobjectBinaryOperation(BinaryOperationBinder info, objectarg); publicvirtualobject Convert(ConvertBinder info);   publicvirtualobject Invoke(InvokeBinder info, object[] args); publicvirtualobjectInvokeMember(InvokeMemberBinder info, object[] args); publicvirtualobjectCreateInstance(CreateInstanceBinder info, object[] args);   publicvirtualobjectGetIndex(GetIndexBinder info, object[] indices); publicvirtualobjectSetIndex(SetIndexBinder info, object[] indices, object value); publicvirtualobjectDeleteIndex(DeleteIndexBinder info, object[] indices);   publicMetaObjectIDynamicObject.GetMetaObject(); }
Implementing IDynamicObject demo
Optional and Named Parameters Primary method publicStreamReaderOpenTextFile(     string path,     Encodingencoding, booldetectEncoding, intbufferSize); Secondary overloads publicStreamReaderOpenTextFile(     string path,     Encodingencoding, booldetectEncoding); publicStreamReaderOpenTextFile(     string path,     Encodingencoding); publicStreamReaderOpenTextFile(     string path); Call primary with default values
Optional and Named Parameters Optional parameters publicStreamReaderOpenTextFile(     string path,     Encodingencoding, booldetectEncoding, intbufferSize); publicStreamReaderOpenTextFile(     string path,     Encodingencoding = null, booldetectEncoding = true, intbufferSize = 1024); Named argument OpenTextFile("foo.txt", Encoding.UTF8); OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4096); Arguments evaluated in order written Named arguments can appear in any order Named arguments must be last OpenTextFile( bufferSize: 4096,     path: "foo.txt", detectEncoding: false); Non-optional must be specified
Improved COM Interoperability objectfileName = "Test.docx"; object missing  = System.Reflection.Missing.Value; doc.SaveAs(reffileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); doc.SaveAs("Test.docx");
Automatic object  dynamic mapping Optional and named parameters Indexed properties Optional “ref” modifier Interop type embedding (“No PIA”) Improved COM Interoperability
Improved COM Interoperability demo
Co- and Contra-variance .NET arrays are co-variant string[] strings = GetStringArray(); Process(strings); 
but not safelyco-variant void Process(object[] objects) { 
 } void Process(object[] objects) {    objects[0] = "Hello";       // Ok    objects[1] = newButton();  // Exception! } Until now, C# generics have been invariant List<string> strings = GetStringList(); Process(strings); C# 4.0 supports safe co- and contra-variance void Process(IEnumerable<object> objects) { 
 } void Process(IEnumerable<object> objects) { // IEnumerable<T> is read-only and // therefore safely co-variant }
Safe Co- and Contra-variance publicinterfaceIEnumerable<T> { IEnumerator<T> GetEnumerator(); } publicinterfaceIEnumerable<out T> { IEnumerator<T> GetEnumerator(); } out= Co-variantOutput positions only Can be treated asless derived publicinterfaceIEnumerator<T> {    T Current { get; } boolMoveNext(); } publicinterfaceIEnumerator<out T> {    T Current { get; } boolMoveNext(); } IEnumerable<string> strings = GetStrings(); IEnumerable<object> objects = strings; in= Contra-variantInput positions only publicinterfaceIComparer<T> { int Compare(T x, T y); } publicinterfaceIComparer<in T> { int Compare(T x, T y); } Can be treated asmore derived IComparer<object> objComp = GetComparer(); IComparer<string> strComp = objComp;
Variance in C# 4.0 Supported for interface and delegate types “Statically checked definition-site variance” Value types are always invariant IEnumerable<int> is not IEnumerable<object> Similar to existing rules for arrays ref and out parameters need invariant type
Variance in .NET Framework 4.0 Interfaces System.Collections.Generic.IEnumerable<out T> System.Collections.Generic.IEnumerator<out T> System.Linq.IQueryable<out T> System.Collections.Generic.IComparer<in T> System.Collections.Generic.IEqualityComparer<in T> System.IComparable<in T> Delegates System.Func<in T, 
, out R> System.Action<in T, 
> System.Predicate<in T> System.Comparison<in T> System.EventHandler<in T>
The Evolution of C# C# 4.0 Dynamic Programming C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code
Compiler as a Service Class Meta-programming Read-Eval-Print Loop public Foo Field Language Object Model DSL Embedding private X string Compiler Compiler SourceFile .NET Assembly Source code Source code Source code Source code
Compiler as a Service demo
Book Signing Bookstore Monday 3:30 PM
Related Sessions TL10: Deep Dive: Dynamic Languages in .NET TL54: Natural Interop with Silverlight, Office, 
 TL12: Future Directions for Microsoft Visual Basic TL57: Panel: The Future of Programming Languages TL11: An Introduction to Microsoft F# C# 4.0 Samples and Whitepaper http://code.msdn.microsoft.com/csharpfuture Visual C# Developer Center http://csharp.net Additional Resources
Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
Please use the microphones provided Q&A
© 2008 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.

Weitere Àhnliche Inhalte

Was ist angesagt?

Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
C# for C++ programmers
C# for C++ programmersC# for C++ programmers
C# for C++ programmersMark Whitaker
 
Introduction to-csharp
Introduction to-csharpIntroduction to-csharp
Introduction to-csharpSDFG5
 
Introduction toc sharp
Introduction toc sharpIntroduction toc sharp
Introduction toc sharpSDFG5
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesEelco Visser
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoPaulo Morgado
 
What's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutWhat's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutPaulo Morgado
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Geeks Anonymes
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Gostrikr .
 
Objective c intro (1)
Objective c intro (1)Objective c intro (1)
Objective c intro (1)David Echeverria
 
C# for C++ Programmers
C# for C++ ProgrammersC# for C++ Programmers
C# for C++ Programmersrussellgmorley
 
FTD JVM Internals
FTD JVM InternalsFTD JVM Internals
FTD JVM InternalsFelipe Mamud
 

Was ist angesagt? (20)

Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
Managed Compiler
Managed CompilerManaged Compiler
Managed Compiler
 
C# for C++ programmers
C# for C++ programmersC# for C++ programmers
C# for C++ programmers
 
C++11
C++11C++11
C++11
 
Introduction to-csharp
Introduction to-csharpIntroduction to-csharp
Introduction to-csharp
 
C++11
C++11C++11
C++11
 
Introduction toc sharp
Introduction toc sharpIntroduction toc sharp
Introduction toc sharp
 
Deep C
Deep CDeep C
Deep C
 
Constructor and destructor in C++
Constructor and destructor in C++Constructor and destructor in C++
Constructor and destructor in C++
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
Whats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPontoWhats New In C# 4 0 - NetPonto
Whats New In C# 4 0 - NetPonto
 
What's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOutWhat's New In C# 5.0 - Rumos InsideOut
What's New In C# 5.0 - Rumos InsideOut
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Reflection in Go
Reflection in GoReflection in Go
Reflection in Go
 
Objective c intro (1)
Objective c intro (1)Objective c intro (1)
Objective c intro (1)
 
C# for C++ Programmers
C# for C++ ProgrammersC# for C++ Programmers
C# for C++ Programmers
 
FTD JVM Internals
FTD JVM InternalsFTD JVM Internals
FTD JVM Internals
 

Andere mochten auch

US health care system overview 2
US health care system  overview 2US health care system  overview 2
US health care system overview 2nithinmohantk
 
US health care system overview 5
US health care system  overview 5US health care system  overview 5
US health care system overview 5nithinmohantk
 
Microsoft.Net Platform Basics
Microsoft.Net Platform BasicsMicrosoft.Net Platform Basics
Microsoft.Net Platform Basicsnithinmohantk
 
US health care system overview 3
US health care system  overview 3US health care system  overview 3
US health care system overview 3nithinmohantk
 
US health care system overview 2
US health care system  overview 2US health care system  overview 2
US health care system overview 2nithinmohantk
 
Us Healthcare Presentation
Us Healthcare PresentationUs Healthcare Presentation
Us Healthcare Presentationesilbert
 
Us health care system final presentation.
Us health care system final presentation.Us health care system final presentation.
Us health care system final presentation.Wendi Lee
 
US health care system overview 1
US health care system  overview 1US health care system  overview 1
US health care system overview 1nithinmohantk
 

Andere mochten auch (8)

US health care system overview 2
US health care system  overview 2US health care system  overview 2
US health care system overview 2
 
US health care system overview 5
US health care system  overview 5US health care system  overview 5
US health care system overview 5
 
Microsoft.Net Platform Basics
Microsoft.Net Platform BasicsMicrosoft.Net Platform Basics
Microsoft.Net Platform Basics
 
US health care system overview 3
US health care system  overview 3US health care system  overview 3
US health care system overview 3
 
US health care system overview 2
US health care system  overview 2US health care system  overview 2
US health care system overview 2
 
Us Healthcare Presentation
Us Healthcare PresentationUs Healthcare Presentation
Us Healthcare Presentation
 
Us health care system final presentation.
Us health care system final presentation.Us health care system final presentation.
Us health care system final presentation.
 
US health care system overview 1
US health care system  overview 1US health care system  overview 1
US health care system overview 1
 

Ähnlich wie PDC Video on C# 4.0 Futures

Introduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamicIntroduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamicGieno Miao
 
Dynamic languages for .NET CLR
Dynamic languages for .NET CLRDynamic languages for .NET CLR
Dynamic languages for .NET CLRpy_sunil
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?Kevin Pilch
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 IronPython and Dynamic Languages on .NET by Mahesh Prakriya IronPython and Dynamic Languages on .NET by Mahesh Prakriya
IronPython and Dynamic Languages on .NET by Mahesh Prakriyacodebits
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Tomas Petricek
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overviewbwullems
 
2.dynamic
2.dynamic2.dynamic
2.dynamicbashcode
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Juan Pablo
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language PerformanceKevin Hazzard
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Jimmy Schementi
 
Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10KulveerSingh
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0Thomas Conté
 
HexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profitHexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profitAlex Matrosov
 
Whidbey old
Whidbey old Whidbey old
Whidbey old grenaud
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008Luis Enrique
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
1204csharp
1204csharp1204csharp
1204csharpg_hemanth17
 

Ähnlich wie PDC Video on C# 4.0 Futures (20)

Introduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamicIntroduction to c sharp 4.0 and dynamic
Introduction to c sharp 4.0 and dynamic
 
Dynamic languages for .NET CLR
Dynamic languages for .NET CLRDynamic languages for .NET CLR
Dynamic languages for .NET CLR
 
devLink - What's New in C# 4?
devLink - What's New in C# 4?devLink - What's New in C# 4?
devLink - What's New in C# 4?
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 IronPython and Dynamic Languages on .NET by Mahesh Prakriya IronPython and Dynamic Languages on .NET by Mahesh Prakriya
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 
Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#Accessing loosely structured data from F# and C#
Accessing loosely structured data from F# and C#
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overview
 
2.dynamic
2.dynamic2.dynamic
2.dynamic
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
Dynamic Language Performance
Dynamic Language PerformanceDynamic Language Performance
Dynamic Language Performance
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10Whats New In C Sharp 4 And Vb 10
Whats New In C Sharp 4 And Vb 10
 
The Future of C# and Visual Basic
The Future of C# and Visual BasicThe Future of C# and Visual Basic
The Future of C# and Visual Basic
 
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
MS Day EPITA 2010: Visual Studio 2010 et Framework .NET 4.0
 
HexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profitHexRaysCodeXplorer: object oriented RE for fun and profit
HexRaysCodeXplorer: object oriented RE for fun and profit
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
 
Visual studio 2008
Visual studio 2008Visual studio 2008
Visual studio 2008
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
1204csharp
1204csharp1204csharp
1204csharp
 

KĂŒrzlich hochgeladen

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

KĂŒrzlich hochgeladen (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

PDC Video on C# 4.0 Futures

  • 1. The Future of C# TL16  Anders Hejlsberg Technical Fellow Microsoft Corporation
  • 2. The Evolution of C# C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code
  • 4. Declarative Programming What How Imperative Declarative
  • 8. The Evolution of C# C# 4.0 Dynamic Programming C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code
  • 9. Dynamically Typed Objects Optional and Named Parameters Improved COM Interoperability Co- and Contra-variance C# 4.0 Language Innovations
  • 10. .NET Dynamic Programming IronPython IronRuby C# VB.NET Others
 Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching PythonBinder RubyBinder COMBinder JavaScriptBinder ObjectBinder
  • 11. Dynamically Typed Objects Calculator calc = GetCalculator(); int sum = calc.Add(10, 20); object calc = GetCalculator(); TypecalcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, newobject[] { 10, 20 }); int sum = Convert.ToInt32(res); ScriptObject calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = Convert.ToInt32(res); Statically typed to be dynamic dynamic calc = GetCalculator(); int sum = calc.Add(10, 20); Dynamic method invocation Dynamic conversion
  • 12.
  • 13. At run-time, actual type(s) substituted for dynamic
  • 14.
  • 16. IDynamicObject publicabstractclassDynamicObject : IDynamicObject { publicvirtualobjectGetMember(GetMemberBinder info); publicvirtualobjectSetMember(SetMemberBinder info, object value); publicvirtualobjectDeleteMember(DeleteMemberBinder info);   publicvirtualobjectUnaryOperation(UnaryOperationBinder info); publicvirtualobjectBinaryOperation(BinaryOperationBinder info, objectarg); publicvirtualobject Convert(ConvertBinder info);   publicvirtualobject Invoke(InvokeBinder info, object[] args); publicvirtualobjectInvokeMember(InvokeMemberBinder info, object[] args); publicvirtualobjectCreateInstance(CreateInstanceBinder info, object[] args);   publicvirtualobjectGetIndex(GetIndexBinder info, object[] indices); publicvirtualobjectSetIndex(SetIndexBinder info, object[] indices, object value); publicvirtualobjectDeleteIndex(DeleteIndexBinder info, object[] indices);   publicMetaObjectIDynamicObject.GetMetaObject(); }
  • 18. Optional and Named Parameters Primary method publicStreamReaderOpenTextFile( string path, Encodingencoding, booldetectEncoding, intbufferSize); Secondary overloads publicStreamReaderOpenTextFile( string path, Encodingencoding, booldetectEncoding); publicStreamReaderOpenTextFile( string path, Encodingencoding); publicStreamReaderOpenTextFile( string path); Call primary with default values
  • 19. Optional and Named Parameters Optional parameters publicStreamReaderOpenTextFile( string path, Encodingencoding, booldetectEncoding, intbufferSize); publicStreamReaderOpenTextFile( string path, Encodingencoding = null, booldetectEncoding = true, intbufferSize = 1024); Named argument OpenTextFile("foo.txt", Encoding.UTF8); OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4096); Arguments evaluated in order written Named arguments can appear in any order Named arguments must be last OpenTextFile( bufferSize: 4096, path: "foo.txt", detectEncoding: false); Non-optional must be specified
  • 20. Improved COM Interoperability objectfileName = "Test.docx"; object missing = System.Reflection.Missing.Value; doc.SaveAs(reffileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); doc.SaveAs("Test.docx");
  • 21. Automatic object  dynamic mapping Optional and named parameters Indexed properties Optional “ref” modifier Interop type embedding (“No PIA”) Improved COM Interoperability
  • 23. Co- and Contra-variance .NET arrays are co-variant string[] strings = GetStringArray(); Process(strings); 
but not safelyco-variant void Process(object[] objects) { 
 } void Process(object[] objects) { objects[0] = "Hello"; // Ok objects[1] = newButton(); // Exception! } Until now, C# generics have been invariant List<string> strings = GetStringList(); Process(strings); C# 4.0 supports safe co- and contra-variance void Process(IEnumerable<object> objects) { 
 } void Process(IEnumerable<object> objects) { // IEnumerable<T> is read-only and // therefore safely co-variant }
  • 24. Safe Co- and Contra-variance publicinterfaceIEnumerable<T> { IEnumerator<T> GetEnumerator(); } publicinterfaceIEnumerable<out T> { IEnumerator<T> GetEnumerator(); } out= Co-variantOutput positions only Can be treated asless derived publicinterfaceIEnumerator<T> { T Current { get; } boolMoveNext(); } publicinterfaceIEnumerator<out T> { T Current { get; } boolMoveNext(); } IEnumerable<string> strings = GetStrings(); IEnumerable<object> objects = strings; in= Contra-variantInput positions only publicinterfaceIComparer<T> { int Compare(T x, T y); } publicinterfaceIComparer<in T> { int Compare(T x, T y); } Can be treated asmore derived IComparer<object> objComp = GetComparer(); IComparer<string> strComp = objComp;
  • 25. Variance in C# 4.0 Supported for interface and delegate types “Statically checked definition-site variance” Value types are always invariant IEnumerable<int> is not IEnumerable<object> Similar to existing rules for arrays ref and out parameters need invariant type
  • 26. Variance in .NET Framework 4.0 Interfaces System.Collections.Generic.IEnumerable<out T> System.Collections.Generic.IEnumerator<out T> System.Linq.IQueryable<out T> System.Collections.Generic.IComparer<in T> System.Collections.Generic.IEqualityComparer<in T> System.IComparable<in T> Delegates System.Func<in T, 
, out R> System.Action<in T, 
> System.Predicate<in T> System.Comparison<in T> System.EventHandler<in T>
  • 27. The Evolution of C# C# 4.0 Dynamic Programming C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code
  • 28. Compiler as a Service Class Meta-programming Read-Eval-Print Loop public Foo Field Language Object Model DSL Embedding private X string Compiler Compiler SourceFile .NET Assembly Source code Source code Source code Source code
  • 29. Compiler as a Service demo
  • 30. Book Signing Bookstore Monday 3:30 PM
  • 31. Related Sessions TL10: Deep Dive: Dynamic Languages in .NET TL54: Natural Interop with Silverlight, Office, 
 TL12: Future Directions for Microsoft Visual Basic TL57: Panel: The Future of Programming Languages TL11: An Introduction to Microsoft F# C# 4.0 Samples and Whitepaper http://code.msdn.microsoft.com/csharpfuture Visual C# Developer Center http://csharp.net Additional Resources
  • 32. Evals & Recordings Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
  • 33. Please use the microphones provided Q&A
  • 34. © 2008 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.