Your SlideShare is downloading. ×
.Net 4 Framework 2010
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

.Net 4 Framework 2010

2,040

Published on

Major features of .NET 4.0

Major features of .NET 4.0

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,040
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
6
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • CLR bridge for dynamic languages.Iron – Implementation Running On How it works?1. Dynamic Code Generation2. Dynamic Type System3. Dynamic Method Dispatch
  • Multi-core chip – eight or fewer homogeneous cores in one microprocessor package.Many-core chip – more than eight possibly heterogeneous cores in one microsprocessor package. Good Parallel Implementation – One thread per core.Concurrency profiler
  • Transcript

    • 1. AmirdhaGopalRajendran
      xConf
      Thoughtworks, Chennai
      .NET Framework 4.0 with Visual Studio 2010
      The evolution of a general purpose software development framework
    • 2. Setting the Scene
      .NET Roadmap
      Overview of Framework 4.0 Universe
      Overview of Visual Studio 2010
      Trends in Programming Languages
      Dynamic Language Runtime
      Parallel Programming
      C# Language Features
      Covariance & ContraVariance
      Optional and Named Parameters
      New Collection Types & Data structures
      Tuple
      SortedSet
      BigInteger
      Left overs
      References
      Introduction
    • 3. .NET Roadmap
      SP1
      3.5
      3.0
      .NET 1.0
      .NET 1.1
      .NET 2.0
      .NET 4.0
      2002
      2003
      2010 RC
      2005-08
      CLR 1.0
      CLR 1.1
      CLR 2.0
      CLR 4.0
    • 4.
    • 5.
    • 6.
    • 7.
    • 8. Trends in Programming Languages
    • 9. Dynamic Language Runtime
    • 10. Why a “Dynamic Language Runtime”?
      Dynamically-Typed
      Ruby
      Python
      Statically-Typed
      VB
      C#
      Common Language Runtime
    • 11. Why a “Dynamic Language Runtime”?
      Dynamically-Typed
      Ruby
      Python
      Statically-Typed
      VB
      Dynamic Language Runtime
      C#
      Common Language Runtime
    • 12. Dynamic Language Runtime
      .NET ?.?
      DLR2
      Script Hosting
      Compiler as
      a Service
      ???
      .NET 4.0
      DLR
      Expression
      Trees v2
      Call Site Caching
      Dynamic
      Dispatch
      .NET 3.5
      LINQ
      Expression
      Trees
      Extension
      Methods
      Silverlight
      .NET 2.0
      Generics
      In Runtime
      Fast
      Delegates
      Dynamic
      Methods
      .NET 1.0
      GC
      Reflection
      JIT
      BCL
      Dynamic
      Codegen
      Verifier
      Sandbox
    • 13. Dynamic Language Runtime
      IronPython
      IronRuby
      C#
      VB.NET
      Others…
      Dynamic Language Runtime
      Expression Trees
      Dynamic Dispatch
      Call Site Caching
      PythonBinder
      RubyBinder
      COMBinder
      JavaScriptBinder
      ObjectBinder
    • 14. The Evolution of C#
      C# 4.0
      Dynamic Programming
      C# 3.0
      Language Integrated Query
      C# 2.0
      Generics
      C# 1.0
      Managed Code
    • 15. dynamic
      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
    • 16. 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…
      • Member selection deferred to run-time
      • 17. At run-time, actual type(s) substituted for dynamic
      • 18. Static result type of operation is dynamic
    • Parallel Programming
    • 19. Parallel Programming
      Tools
      Managed Languages
      Axum
      Visual F#
      Visual Studio 2010
      Parallel
      Debugger Windows
      Native Libraries
      ManagedLibraries
      DryadLINQ
      Async
      AgentsLibrary
      Parallel Pattern Library
      Profiler Concurrency
      Analysis
      Parallel LINQ
      Rx
      Task ParallelLibrary
      Data Structures
      Data Structures
      Microsoft
      Research
      Native Concurrency Runtime
      Task Scheduler
      Race Detection
      Managed Concurrency Runtime
      Resource Manager
      ThreadPool
      Fuzzing
      Operating System
      Threads
      UMS Threads
      HPC Server
      Windows 7 / Server 2008 R2
      Research / Incubation
      Visual Studio 2010 / .NET 4
      Key:
    • 20. Minimizing the Overhead of Parallelism
      The Argument:
      Parallelization demands division
      Executing work items has overhead
      Results in increased overhead to work ratio
      We must decrease overhead
      Overhead
      Overhead
      Overhead
      Work
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
      Overhead
    • 21. Global Queue
      Worker Thread 1
      Worker Thread 1
      ThreadPool in .NET 3.5

      Item 4
      Item 5
      Program Thread
      Item 1
      Item 2
      Item 3
      Item 6
      Thread Management:
      • Starvation Detection
      • 22. Idle Thread Retirement
    • ThreadPool in .NET 4
      Local
      Work-Stealing Queue
      Local Work-Stealing Queue
      Lock-Free
      Global Queue

      Worker Thread 1
      Worker Thread p

      Task 6
      Task 3
      Program Thread
      Task 4
      Task 1
      Task 5
      Task 2
      Thread Management:
      • Starvation Detection
      • 23. Idle Thread Retirement
      • 24. Hill-climbing
    • Rev Up Your Loops
      Control flow is a primary source of work
      Parallelizable when iterations are (or can be made) independent
      Synchronous
      All work quiesces, regularly or exceptionally
      Lots of knobs
      Cancelation, breaking, task-local state, custom partitioning, scheduling, degree of parallelism
      foreach(var item in data)
      {
      work(item);
      }
      for (int i = 0; i < n; i++)
      {
      work(i);
      }
      StatementA();
      StatementB;
      StatementC();
      Parallel.ForEach(data, item=>
      {
      work(item);
      });
      Parallel.For(0, n, i=>
      {
      work(i);
      });
      Parallel.Invoke(
      () => StatementA(),
      () => StatementB,
      () => StatementC());
      from item in shows.AsParallel()
      where item.Description.Contains(keyword)
      select item;
    • 25. C# Language Features
      Co- and Contra-Variance
      Optional and Named Parameters
    • 26. 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
      }
    • 27. 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;
    • 28. Variance in C# 4.0
      Supported for interface and delegate types
      “Statically checked definition-site variance”
      Value types are always invariant
      IEnumerable<int> is notIEnumerable<object>
      Similar to existing rules for arrays
    • 29. 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>
    • 30. 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
    • 31. 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
    • 32. New Collection Types and DataStructures
      Tuple
      SortedSet
      BigInteger
    • 33. In mathematics, a tuple is a sequence (or ordered list) of finite length.
      Used in F# & Python, but also easy to use now from C#
      Tuple
      publicTuple<Int32, Int32> DivAndRemainder(Int32i, Int32 j)
      {
      returnnewTuple.Create(i/j, i%j);
      }
       
      // An example of someone accessing items in a tuple.
      for (Int16i = 0; i <= 25; i++) {
      for (Int16j = 1; j <= 5; j++) {
      vartuple = DivAndRemainder(i,j);
      Console.WriteLine("{0} {1} {2} {3} ",
      i, j, tuple.item1, tuple.item2);
      }
    • 34. Collection of UNIQUEelements in SORTED Order.
      Sorted Set
      varsetRange = newSortedSet<int>() {2,5,6,2,1,4,8 };
      foreach(variinsetRange){ Console.Write(i); }
      //output: 124568
    • 35. Used by both F# & Python.
      Big Integer
      BigIntegeri = new BigInteger(ulong.MaxValue.ToString());
      BigIntegeriSquared = i.multiply(i);
      Console.WriteLine("i: " + i);
      Console.WriteLine("i^2: " + iSquared);
      i: 18446744073709551615
      i^2: 340282366920938463426481119284349108225
    • 36. Native Code Interoperability
      Managed Extensibility Framework
      System.Numerics.Complex
      Tail Recursion (for F#)
      Code Contract
      In-Process Side-by-Side
      GC Improvements
      Profiling Improvements
      Debugging Improvements
      Etc…
      Left Overs
    • 37. Dynamic Language Runtime
      Code Plex: http://dlr.codeplex.com/
      Deep Dive: http://channel9.msdn.com/pdc2008/TL10/
      Parallel Programming
      Manycore and .NET 4.0: http://microsoftpdc.com/Sessions/P09-09
      Samples: http://code.msdn.microsoft.com/ParExtSamples
      C# Language Features
      Anders Talk (Must Watch): http://channel9.msdn.com/pdc2008/TL16/
      References
    • 38. Thank you

    ×