What’s New and Hot in .NET 4.0

1,764 views
1,658 views

Published on

Walks through the new and awesome features in the .NET 4.0 Framework

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,764
On SlideShare
0
From Embeds
0
Number of Embeds
19
Actions
Shares
0
Downloads
54
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • 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).
  • What’s New and Hot in .NET 4.0

    1. 1. What’s New & Hot in .NET 4.0?<br />Jess Chadwick<br />blog.jesschadwick.com<br />twitter.com/jchadwick<br />
    2. 2. About Me (Only one is true)<br />I invented the question mark.<br />I have several published magazine articles<br />I can swim the 100m breaststroke in under 1:30<br />
    3. 3. The boring credentials…<br />Decade of development experience<br />Recently turned independant consultant<br />Speaker & User Group Leader<br />Microsoft MVP (ASP.NET)<br />ASPInsider<br />Writer<br />Blog: blog.jesschadwick.com<br />Articles: in CoDe and DevConnections magazines<br />
    4. 4. What Is The .NET Framework?<br />WPF<br />Win Forms<br />DLR<br />ASP.NET<br />WCF<br />…and more!<br />LINQ-to-SQL<br />Base Class Libraries<br />The CLR<br />JIT & NGEN<br />Garbage Collector<br />Security Model<br />Exception Handling<br />Loader & Binder<br />
    5. 5. .NET 4.0 Overview: New & Updated<br />CLR & Framework<br />Platforms<br />The CLR<br />The Base Class Library<br />Performance, Concurrency & Parallelization<br />New Languages (F#, IronPython)<br />Language Enhancements<br />Dynamic Language Runtime<br />Code Contracts<br />Managed Extensibility Framework (MEF)<br />Entity Framework<br />WPF<br />Windows Workflow<br />ASP.NET<br />ASP.NET MVC<br />Web Forms<br />ASP.NET AJAX<br />
    6. 6. .NET 4.0 Overview: New & Updated<br />CLR & Framework<br />Platforms<br />The CLR<br />The Base Class Library<br />Performance, Concurrency &Parallelization<br />New Languages<br />Language Enhancements<br />Dynamic Language Runtime<br />Code Contracts<br />Managed Extensibility Framework (MEF)<br />Entity Framework<br />WPF<br />Windows Workflow<br />ASP.NET<br />ASP.NET MVC<br />Web Forms<br />ASP.NET AJAX<br />( Platform demos if we have time )<br />
    7. 7. .NET Framework Improvements<br />
    8. 8. The Goals of CLR 4<br />Working Better Together…<br />Faster…<br />With Fewer Bugs…<br />In-Proc SxS<br />Managed Extensibility Framework<br />Native/Managed Interop<br />DLR Integration<br />Threading<br />Parallel Extensions<br />Garbage Collection<br />Profiling<br />Code Contracts<br />Debugging<br />Corrupted State Exceptions<br />
    9. 9. Base Class Library Additions<br />Numerics<br />BigInteger<br />Data Structures<br />Tuple (newTuple<int,int,string>(1,2,”Test”))<br />ISet<T> (SortedSet<T> & HashSet<T>)<br />I/O<br />Memory-Mapped File<br />
    10. 10. Performance, Concurrency, and Parallel Extensions<br />Thread-safe collections (BlockingCollection<T>, ConcurrentDictionary<T>, etc.)<br />Task Parallel Library (TPL)<br />PLINQ<br />Lazy Initializationeg: Lazy<IEnumerable<Order>> Orders { get; set;}<br />
    11. 11. Code Contracts<br />
    12. 12. Design By Contract<br />Code Contracts provide a language-agnostic and declarative way to express coding assumptions in .NET programs.<br />
    13. 13. A Code Contract contains…<br />Pre-conditions: must be true before<br />public Rational(int numerator, int denominator)<br />{<br />Contract.Requires(denominator > 0);<br /> …<br />}<br />Post-conditions: must be true after<br />public string GetPassword()<br />{<br />Contract.Ensures(Contract.Result<string>() != null);<br /> …<br /> return password;<br />}<br />
    14. 14. A Code Contract contains…<br />Invariants - must always be true<br />[ContractInvariantMethod]<br />protected void ObjectInvariant()<br />{<br />Contract.Invariant(denominator > 0);<br />}<br />
    15. 15. Code Contracts<br />
    16. 16. Why are Contracts Useful?<br /><ul><li>Debugging
    17. 17. Tooling!
    18. 18. Pex (research.microsoft.com/projects/pex/)</li></li></ul><li>Language Enhancements<br />C#, Visual Basic, plus new Functional & Dynamic Languages<br />
    19. 19. New C# 4.0 Features<br />Improved COM Inter-op<br />Named and Optional Parameters<br />Covariance and Contravariance<br />
    20. 20. New VB10 Features<br />Auto-Implemented Properties<br />Collection Initializers<br />Statement Lambdas<br />Implicit Line Continuation<br />Covariance and Contravariance<br />
    21. 21. New VB10 Features<br />Automatic Properties<br />Collection Initializers<br />Statement Lambdas<br />Implicit Line Continuation<br />Covariance and Contravariance<br />
    22. 22. Covariance & Contravariance<br />“Fix” generics<br />
    23. 23. Covariance<br />Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved<br />
    24. 24. Covariance<br />Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is preserved<br />class Derived : Base { } <br />IEnumerable<Derived> d = new List<Derived>(); <br />IEnumerable<Base> b = d; <br />
    25. 25. Contravariance<br />Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed.<br />
    26. 26. Contravariance<br />Describes the substitution of related types, such that the ordering from the more restrictive type to the less restrictive type is reversed.<br />class Derived : Base { } <br />public void DoSomething(Action<Derived> func);<br />DoSomething((Base x) => x.Foo());<br />
    27. 27. New Language Features<br />
    28. 28. Emerging Language Trends<br />
    29. 29. Emerging Language Trends<br />
    30. 30. Introducing… F#!<br />F# Is…<br /><ul><li>A functional programming language derived from OCaml and the ML family of languages
    31. 31. Very good for computation-intensive problems, highly-parallel problems, and language-oriented programming
    32. 32. A first-class .NET 4.0 language, with full Visual Studio 2010 support</li></li></ul><li>Emerging Language Trends<br />
    33. 33. New C# 4.0 Features<br />Improved COM Inter-op<br />Named and Optional Parameters<br />Covariance and Contravariance<br />Late-binding support (via dynamic keyword)<br />(Will show up in our demos coming up next!)<br />
    34. 34. Dynamic Language Runtime<br />
    35. 35. Why a “Dynamic Language Runtime”?<br />Dynamically-Typed<br />Ruby<br />Python<br />Statically-Typed<br />VB<br />Dynamic Language Runtime<br />C#<br />Common Language Runtime<br />
    36. 36. .NET Dynamic Programming<br />IronPython<br />IronRuby<br />C#<br />VB.NET<br />…whatever!<br />Dynamic Language Runtime<br />Expression Trees<br />Dynamic Dispatch<br />Call Site Caching<br />PythonBinder<br />RubyBinder<br />COMBinder<br />JScriptBinder<br />ObjectBinder<br />
    37. 37. Dynamic Language Runtime<br />
    38. 38. Emerging Language Trends<br />
    39. 39. Declarative Development<br />ASP.NET Web Forms (ASPX)<br />XAML (WPF & Silverlight)<br />Code Contracts<br />MEF!<br />
    40. 40. Managed Extensibility Framework (MEF)<br />
    41. 41. What is MEF?<br />MEF is…<br />A way to manage dependencies<br />A way to provide extensibility in your apps<br />A framework to encourage loose coupling and reusability<br />A new addition to the Base Class Library <br />System.ComponentModel.Composition<br />
    42. 42. What is MEF? (Simple Answer)<br />Imports and Exports<br />
    43. 43. What is MEF? (Simple Answer)<br />Imports and Exports<br />of components(“parts”)<br />
    44. 44. What is MEF? (Complex Answer)<br />Imports and Exports<br />of components(“parts”)<br />wired together via containers<br />
    45. 45. Implementing MEF…and, heck – everything else!<br />
    46. 46. What’s New in the Platforms?<br />WPF, ASP.NET, Workflow, etc!<br />
    47. 47. Windows Presentation Framework (WPF)<br />
    48. 48. Lots of Good Stuff for WPF<br />Multitouch<br />Windows 7 taskbar<br />Windows 7 ribbon <br />Full Trust XBaps<br />Cached compositions<br />Textclarity<br />Layout rounding<br />ClickOnce improvements<br />Focus mgt improvements<br />Support for UIAccessible2<br />VSM integration<br />Media element improvements<br />Client profile<br />Data controls<br />Accessibility improvements<br />Control themes<br />Chart controls<br />… hundreds of good bug fixes too!<br />
    49. 49. Entity Framework<br />It’s not just for databases anymore!<br />
    50. 50. EF4 Enhancements<br />Model-First Development<br />Persistence Ignorance (POCO support!)<br />Application Patterns (Repository, Unit of Work, etc.)<br />Customization of Queries & Generated Code<br />
    51. 51. Windows Workflow<br />
    52. 52. WF challenges today<br />Limited support for XAML-only workflows<br />Versioning is problematic<br />Composition difficult or impossible<br />Writing custom activities and managing data flow is not easy enough today<br />Limited WCF integration and activity support<br />No generic server host environment<br />Bottom line: A high bar to get to enough value to make it worth the tax<br />
    53. 53. Moving towards .NET 4.0<br />XAML-only workflows are the new default<br />Unified model between WF, WCF, and WPF<br />Extended base activity library<br />Simplified WF programming model<br />Support for arguments, variables, expressions<br />Major improvements to WCF integration<br />Runtime and designer improvements<br />Hosting & management via "Dublin"<br />
    54. 54. Extended base activity library<br />.NET 4.0 comes with several new activities<br />Microsoft is planning to ship more activities via CodePlex<br />
    55. 55. New flow chart model<br />Flowcharts offer a middle ground between the sequential and state machine models<br />Simple step-by-step model, <br />with decisions and switches<br />Allows you to return to previous<br />activities in the workflow<br />
    56. 56. Improving the Web<br />ASP.NET MVC, Web Forms, and ASP.NET AJAX<br />
    57. 57. ASP.NET MVC<br />v.2 “Officially” part of the framework<br />New Features for v2:<br />Areas<br />Data Annotations support<br />Templated Helpers<br />Client-Side Validation<br />
    58. 58. Web Forms<br /><ul><li>Client ID manipulation
    59. 59. Fine-Grained ViewState control</li></li></ul><li>ASP.NET AJAX<br /><ul><li>Client-Side Templates
    60. 60. Client-Side Data Controls (DataView & DataContext)
    61. 61. Declarative Instantiation
    62. 62. Command Bubbling
    63. 63. Live Bindings</li></li></ul><li>Questions?<br />Please complete the online evaluation form<br />
    64. 64. Thank you!<br />Resources<br /><ul><li> Visual Studio 2010:msdn.microsoft.com/en-us/vstudio
    65. 65. MEF Homepage: mef.codeplex.com
    66. 66. DLR Homepage: dlr.codeplex.com
    67. 67. IronPython Homepage: ironpython.codeplex.com</li></ul>Contact Info<br />Email: jesschadwick@gmail.com<br />Blog: blog.jesschadwick.com<br />Twitter: twitter.com/jchadwick<br />

    ×