1. What’s New & Hot in .NET 4.0? Jess Chadwick blog.jesschadwick.com twitter.com/jchadwick
2. About Me (Only one is true) I invented the question mark. I have several published magazine articles I can swim the 100m breaststroke in under 1:30
3. The boring credentials… Decade of development experience Recently turned independant consultant Speaker & User Group Leader Microsoft MVP (ASP.NET) ASPInsider Writer Blog: blog.jesschadwick.com Articles: in CoDe and DevConnections magazines
4. What Is The .NET Framework? WPF Win Forms DLR ASP.NET WCF …and more! LINQ-to-SQL Base Class Libraries The CLR JIT & NGEN Garbage Collector Security Model Exception Handling Loader & Binder
5. .NET 4.0 Overview: New & Updated CLR & Framework Platforms The CLR The Base Class Library Performance, Concurrency & Parallelization New Languages (F#, IronPython) Language Enhancements Dynamic Language Runtime Code Contracts Managed Extensibility Framework (MEF) Entity Framework WPF Windows Workflow ASP.NET ASP.NET MVC Web Forms ASP.NET AJAX
6. .NET 4.0 Overview: New & Updated CLR & Framework Platforms The CLR The Base Class Library Performance, Concurrency &Parallelization New Languages Language Enhancements Dynamic Language Runtime Code Contracts Managed Extensibility Framework (MEF) Entity Framework WPF Windows Workflow ASP.NET ASP.NET MVC Web Forms ASP.NET AJAX ( Platform demos if we have time )
12. Design By Contract Code Contracts provide a language-agnostic and declarative way to express coding assumptions in .NET programs.
13. A Code Contract contains… Pre-conditions: must be true before public Rational(int numerator, int denominator) { Contract.Requires(denominator > 0); … } Post-conditions: must be true after public string GetPassword() { Contract.Ensures(Contract.Result<string>() != null); … return password; }
14. A Code Contract contains… Invariants - must always be true [ContractInvariantMethod] protected void ObjectInvariant() { Contract.Invariant(denominator > 0); }
23. Covariance Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved
24. Covariance Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved class Derived : Base { } IEnumerable<Derived> d = new List<Derived>(); IEnumerable<Base> b = d;
25. Contravariance Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed.
26. Contravariance Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed. class Derived : Base { } public void DoSomething(Action<Derived> func); DoSomething((Base x) => x.Foo());
31. Very good for computation-intensive problems, highly-parallel problems, and language-oriented programming
32.
33. New C# 4.0 Features Improved COM Inter-op Named and Optional Parameters Covariance and Contravariance Late-binding support (via dynamic keyword) (Will show up in our demos coming up next!)
41. What is MEF? MEF is… A way to manage dependencies A way to provide extensibility in your apps A framework to encourage loose coupling and reusability A new addition to the Base Class Library System.ComponentModel.Composition
42. What is MEF? (Simple Answer) Imports and Exports
43. What is MEF? (Simple Answer) Imports and Exports of components(“parts”)
44. What is MEF? (Complex Answer) Imports and Exports of components(“parts”) wired together via containers
48. Lots of Good Stuff for WPF Multitouch Windows 7 taskbar Windows 7 ribbon Full Trust XBaps Cached compositions Textclarity Layout rounding ClickOnce improvements Focus mgt improvements Support for UIAccessible2 VSM integration Media element improvements Client profile Data controls Accessibility improvements Control themes Chart controls … hundreds of good bug fixes too!
52. WF challenges today Limited support for XAML-only workflows Versioning is problematic Composition difficult or impossible Writing custom activities and managing data flow is not easy enough today Limited WCF integration and activity support No generic server host environment Bottom line: A high bar to get to enough value to make it worth the tax
53. Moving towards .NET 4.0 XAML-only workflows are the new default Unified model between WF, WCF, and WPF Extended base activity library Simplified WF programming model Support for arguments, variables, expressions Major improvements to WCF integration Runtime and designer improvements Hosting & management via "Dublin"
54. Extended base activity library .NET 4.0 comes with several new activities Microsoft is planning to ship more activities via CodePlex
55. New flow chart model Flowcharts offer a middle ground between the sequential and state machine models Simple step-by-step model, with decisions and switches Allows you to return to previous activities in the workflow
BigInteger: an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower boundsTuple: a small, finite list of objects; used to pass around multiple values in one object. Kind of like a dynamic struct.ISet<T>:collections that have unique elements and specific operations.Memory-Mapped File: gives you ability to work with files without loading them into memory and locking them from other processes
MESSAGING:Late-Binding Support: The ability to do runtime call dispatch rather than being forced into compile-time verification. Named and Optional Parameters: This allows us to clean up our code as we can see. It also goes hand-in-hand with #3, Improved COM interop (bye-bye “ref MissingValue”)Improved COM Interop: Better interop with COM, along with easier deployment via Type Equivalent and embedding of types.Covariance and Contravariance: This is really about patching a problem in our generic type system as it exists today. Most developers won’t be using the generic variance features directly, they will simply be able to do stuff they couldn’t do before.
MESSAGING:We show all these features in our demo.
MESSAGING:We show all these features in our demo.
MESSAGING:There are several trends in modern programming languages that we feel are important to address and capture with our programming language that we will continue to target. DeclarativeImperative languages focus heavily on the how.Programming logic is achieved via if statements, for loops, while loops, etc.Declarative languages focus on the whatTell the computer “what” you want done, and let it focus on how to get it done (so the language decides whether to achieve the goal via a for loop, foreach loop, recursion, etc.)Focusing on the what instead of the “how” is an important part of “stepping away from the compiler” and better expressing your true intent in code.DynamicAround dynamic languages, you often hear the comparison of dynamically-typed versus statically-typed languages.A better way to express this difference is thinking “late-bound” versus early-bound.Early-bound languages enforce calling conventions, matching contracts (method calls on specific types, for instance), at compile time. However, late-bound languages “punt” this decision until runtime. While early-bound languages gain me benefits like compile-time type-safety, they also enforce rigid constraints on the design of your codeIn this way, code written in early-bound languages becomes more difficult to change.For more information on this “flexibility”, check out Duck Typing in Ruby.ConcurrentConcurrency is a topic that is very important to start addressing ASAP. The “concurrency problem” is already here, not 5 years from now, but today.Functional languages like F# are very powerful when it comes to addressing concurrencyThis power comes from the immutable-by-default approach when enables easier-to-parallelize code since assumptions can be made about the behavior of the code because of no shared-stateF# introduces a very powerful mechanism for achieving concurrency called Asynchronous Workflows (has nothing to do with Workflow Foundation workflows)Async Workflows use Parallel Extensions to the .NET Framework under-the-hoodFor shared-stated languages like C# and Visual Basic, concurrency features are primarily coming from library features like Parallel ExtensionsLanguage teams are thinking hard about how to possibly integrate concurrency into the core language (this is a hard space).
MESSAGING:There are several trends in modern programming languages that we feel are important to address and capture with our programming language that we will continue to target. DeclarativeImperative languages focus heavily on the how.Programming logic is achieved via if statements, for loops, while loops, etc.Declarative languages focus on the whatTell the computer “what” you want done, and let it focus on how to get it done (so the language decides whether to achieve the goal via a for loop, foreach loop, recursion, etc.)Focusing on the what instead of the “how” is an important part of “stepping away from the compiler” and better expressing your true intent in code.DynamicAround dynamic languages, you often hear the comparison of dynamically-typed versus statically-typed languages.A better way to express this difference is thinking “late-bound” versus early-bound.Early-bound languages enforce calling conventions, matching contracts (method calls on specific types, for instance), at compile time. However, late-bound languages “punt” this decision until runtime. While early-bound languages gain me benefits like compile-time type-safety, they also enforce rigid constraints on the design of your codeIn this way, code written in early-bound languages becomes more difficult to change.For more information on this “flexibility”, check out Duck Typing in Ruby.ConcurrentConcurrency is a topic that is very important to start addressing ASAP. The “concurrency problem” is already here, not 5 years from now, but today.Functional languages like F# are very powerful when it comes to addressing concurrencyThis power comes from the immutable-by-default approach when enables easier-to-parallelize code since assumptions can be made about the behavior of the code because of no shared-stateF# introduces a very powerful mechanism for achieving concurrency called Asynchronous Workflows (has nothing to do with Workflow Foundation workflows)Async Workflows use Parallel Extensions to the .NET Framework under-the-hoodFor shared-stated languages like C# and Visual Basic, concurrency features are primarily coming from library features like Parallel ExtensionsLanguage teams are thinking hard about how to possibly integrate concurrency into the core language (this is a hard space).
MESSAGING:F# is a functional programming language for the .NET Framework. It combines the succinct, expressive, and compositional style of functional programming with the runtime, libraries, interoperability, and object model of .NET. F# is included in Visual Studio 2010 and is now a first-class language just like Visual Basic, C#, and C++. F# is very good for compute-intensive problems, highly parallel problems, and language-oriented programming. Since F# just generates normal MSIL and .NET assemblies, you can develop a library in F# that does your computations, and call your F# code from your C# application.
MESSAGING:There are several trends in modern programming languages that we feel are important to address and capture with our programming language that we will continue to target. DeclarativeImperative languages focus heavily on the how.Programming logic is achieved via if statements, for loops, while loops, etc.Declarative languages focus on the whatTell the computer “what” you want done, and let it focus on how to get it done (so the language decides whether to achieve the goal via a for loop, foreach loop, recursion, etc.)Focusing on the what instead of the “how” is an important part of “stepping away from the compiler” and better expressing your true intent in code.DynamicAround dynamic languages, you often hear the comparison of dynamically-typed versus statically-typed languages.A better way to express this difference is thinking “late-bound” versus early-bound.Early-bound languages enforce calling conventions, matching contracts (method calls on specific types, for instance), at compile time. However, late-bound languages “punt” this decision until runtime. While early-bound languages gain me benefits like compile-time type-safety, they also enforce rigid constraints on the design of your codeIn this way, code written in early-bound languages becomes more difficult to change.For more information on this “flexibility”, check out Duck Typing in Ruby.ConcurrentConcurrency is a topic that is very important to start addressing ASAP. The “concurrency problem” is already here, not 5 years from now, but today.Functional languages like F# are very powerful when it comes to addressing concurrencyThis power comes from the immutable-by-default approach when enables easier-to-parallelize code since assumptions can be made about the behavior of the code because of no shared-stateF# introduces a very powerful mechanism for achieving concurrency called Asynchronous Workflows (has nothing to do with Workflow Foundation workflows)Async Workflows use Parallel Extensions to the .NET Framework under-the-hoodFor shared-stated languages like C# and Visual Basic, concurrency features are primarily coming from library features like Parallel ExtensionsLanguage teams are thinking hard about how to possibly integrate concurrency into the core language (this is a hard space).
MESSAGING:Late-Binding Support: The ability to do runtime call dispatch rather than being forced into compile-time verification. Named and Optional Parameters: This allows us to clean up our code as we can see. It also goes hand-in-hand with #3, Improved COM interop (bye-bye “ref MissingValue”)Improved COM Interop: Better interop with COM, along with easier deployment via Type Equivalent and embedding of types.Covariance and Contravariance: This is really about patching a problem in our generic type system as it exists today. Most developers won’t be using the generic variance features directly, they will simply be able to do stuff they couldn’t do before.
MESSAGING:The DLR provides core services that are necessary for dynamically-typed languages to work on the CLRThe DLR also provides other services that can be used by statically-typed languages as well to achieve more dynamic behavior:Expression Trees (including Statements)Dynamic DispatchCall Site Caching
MESSAGING:The power of the DLR is that there are many binders for the DLR. Yes, we can interop with dynamic languages like Python and Ruby like we expect to. However, perhaps even more importantly, there are binders available for .NET, Silverlight, and Office. This allows us to interact between these platforms in very powerful ways that we were unable to currently.
MESSAGING:There are several trends in modern programming languages that we feel are important to address and capture with our programming language that we will continue to target. DeclarativeImperative languages focus heavily on the how.Programming logic is achieved via if statements, for loops, while loops, etc.Declarative languages focus on the whatTell the computer “what” you want done, and let it focus on how to get it done (so the language decides whether to achieve the goal via a for loop, foreach loop, recursion, etc.)Focusing on the what instead of the “how” is an important part of “stepping away from the compiler” and better expressing your true intent in code.DynamicAround dynamic languages, you often hear the comparison of dynamically-typed versus statically-typed languages.A better way to express this difference is thinking “late-bound” versus early-bound.Early-bound languages enforce calling conventions, matching contracts (method calls on specific types, for instance), at compile time. However, late-bound languages “punt” this decision until runtime. While early-bound languages gain me benefits like compile-time type-safety, they also enforce rigid constraints on the design of your codeIn this way, code written in early-bound languages becomes more difficult to change.For more information on this “flexibility”, check out Duck Typing in Ruby.ConcurrentConcurrency is a topic that is very important to start addressing ASAP. The “concurrency problem” is already here, not 5 years from now, but today.Functional languages like F# are very powerful when it comes to addressing concurrencyThis power comes from the immutable-by-default approach when enables easier-to-parallelize code since assumptions can be made about the behavior of the code because of no shared-stateF# introduces a very powerful mechanism for achieving concurrency called Asynchronous Workflows (has nothing to do with Workflow Foundation workflows)Async Workflows use Parallel Extensions to the .NET Framework under-the-hoodFor shared-stated languages like C# and Visual Basic, concurrency features are primarily coming from library features like Parallel ExtensionsLanguage teams are thinking hard about how to possibly integrate concurrency into the core language (this is a hard space).